PHP syntax?

If this works.
[color=blue]print “&writename0=”; $name = mysql_result($fewComments, $i, ‘name’);
print “&writename1=”; $name = mysql_result($fewComments, $i, ‘name’);
print “&writename2=”; $name = mysql_result($fewComments, $i, ‘name’); [/color]

I don’t see why this wouldn’t.
[color=blue]while ($i <3){
print “&writename=$i”; $name = mysql_result($fewComments, $i, ‘name’);
$i++;}[/color]

or this
[color=blue]for($i=0; $i<3; i++){
print “&writename=$i”; $name = mysql_result($fewComments, $i, ‘name’);
}[/color]

To me they all look like the exact same thing, yet the loops won’t work.
Can any tell me why and show me the correct way to write that ?

I think I’ve got it! In the start, you are doing &writename0= but in the loop you are doing &writename=0

See the difference?
The number is on two different sides of the equal sign. Hope this helps :smiley:

and in the for loop you’re missing a $

for($i=0; $i<3; i++){ ----------> for($i=0; $i<3; ***$***i++){

lol :stuck_out_tongue:

I dont know if [color=#0000ff]"&writename=$i"; [/color][color=black]or [/color][color=#0000ff]"&writename$i="; [/color][color=black]it the correct syntax.[/color]

And

the missing $ was just a copy and past thing… here is the code straight from PHP…

if($numallComments == 0) { print "	 No entries yet.."; }
 
else {	 
for($i=0; $i<3; $i++){
print "&writename=$i";	 $name = mysql_result($fewComments, $i, 'name');		 print''. $name .'';
print "&writelocation$i="; $location = mysql_result($fewComments, $i, 'location'); print'<b>Location: </b><br>'. $location .'';
print "&writeage$i="; $dob = mysql_result($fewComments, $i, 'dob');
		 $today	 = date("Y"); 
		 $dob	 = $today - $dob;				 print'<b>Age: </b>'. $dob .'';
print "&writedate$i=";	$time = mysql_result($fewComments, $i, 'time');
		 $time = date("d-m-Y");			 print'<b>Date: </b>'. $time .'';
print "&writecomments$i="; $comments = mysql_result($fewComments, $i, 'comments'); print'<b>Commnets: </b><br>'. $comments .'';
$i++;
}}

Here is the link to the above code, as it is now, only movie 3 of 10 is getting its info.
http://www.cathyschultz.com/boylen/Girls%20of%20Boylen7.html

Since it is in the loop it seems strange that the 3rd one is the only one to show up ?

Below is manual code no-loop where [color=black]1 to 10 is manually done.[/color]
[color=black]That code works that way. But as soon as I try to put it in a loop it stops working.[/color]

print "&writename=$i";	 $name = mysql_result($fewComments, $i, 'name');		 print''. $name .'';
print "&writelocation=$i"; $location = mysql_result($fewComments, $i, 'location'); print'<b>Location: </b><br>'. $location .'';
print "&writeage=$i";	 $dob = mysql_result($fewComments, $i, 'dob');
		 $today	 = date("Y"); 
		 $dob	 = $today - $dob;				 print'<b>Age: </b>'. $dob .'';
print "&writedate=$i";	$time = mysql_result($fewComments, $i, 'time');
		 $time = date("d-m-Y");			 print'<b>Date: </b>'. $time .'';
print "&writecomments=$i"; $comments = mysql_result($fewComments, $i, 'comments'); print'<b>Commnets: </b><br>'. $comments .'';
//****************************************************************************************************
//****************************************************************************************************
print "&writename1=";	 $name = mysql_result($fewComments, 1, 'name');		 print''. $name .'';
print "&writelocation1="; $location = mysql_result($fewComments, 1, 'location'); print'<b>Location: </b><br>'. $location .'';
print "&writeage1="; $dob = mysql_result($fewComments, 1, 'dob');
		 $today	 = date("Y"); 
		 $dob	 = $today - $dob;				 print'<b>Age: </b>'. $dob .'';
print "&writedate1=";	$time = mysql_result($fewComments, 1, 'time');
		 $time = date("d-m-Y");			 print'<b>Date: </b>'. $time .'';
print "&writecomments1="; $comments = mysql_result($fewComments, 1, 'comments'); print'<b>Commnets: </b><br>'. $comments .'';

hmmmmm, is it possible that PHP is trying to pass the info to flash faster than it can handle ?

well, it’s not about syntax, it’s two different things. If you’re trying to do multiple variables with the same name, it’s &writename$i because the $i gets evaluated to the number, but with the $i on the other side of thevariable, you’re setting the variable equal to 0 1 2 or whatever iteration of the loop you’re on. So therefore your flash won’t be able to interperet it because it has multiple names of the same variable or whatever, and none of them have that number at the end. That’s why you were getting “Undefined”

Did you click on the above link by anychance ?

they should all show entry #

but only entry 19 shows up.

when you go to the next ten, only entry 9 shows up.

Now that makes no sense, as that would mean that
&writename$i=
was
&writename2=

Why would number 2 in the loop and none of the others show up ?

Flash:
ring.writename.text = this.writename;
ring.writeage.text = this.writeage;
ring.writedate.text = this.writedate;
ring.writelocation.text = this.writelocation;
ring.writecomments.text = this.writecomments;


i=1;
eval(“ring”+i).writename.text = this.writename1;
eval(“ring”+i).writeage.text = this.writeage1;
eval(“ring”+i).writedate.text = this.writedate1;
eval(“ring”+i).writelocation.text = this.writelocation1;
eval(“ring”+i).writecomments.text = this.writecomments1;


i=2;
eval(“ring”+i).writename.text = this.writename2;
eval(“ring”+i).writeage.text = this.writeage2;
eval(“ring”+i).writedate.text = this.writedate2;
eval(“ring”+i).writelocation.text = this.writelocation2;
eval(“ring”+i).writecomments.text = this.writecomments2;

almost there…

I had my for loop set to short.

I had i++; at the bottom, in a for () loop. <DOH>