# PHP syntax?

**URL:** https://forum.kirupa.com/t/php-syntax/116933
**Category:** Uncategorized
**Created:** [July 22, 2004, 4:56pm UTC](https://forum.kirupa.com/t/php-syntax/116933 "2004-07-22T16:56:29Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![The\_Vulcan](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/the_vulcan/32/145_2.png) [@The\_Vulcan](https://forum.kirupa.com/u/The_Vulcan)
#### Post date: [July 22, 2004, 4:56pm UTC](https://forum.kirupa.com/t/php-syntax/116933/1 "2004-07-22T16:56:29Z")

</div>

**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 ?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 22, 2004, 5:38pm UTC](https://forum.kirupa.com/t/php-syntax/116933/2 "2004-07-22T17:38:32Z")

</div>

I think I’ve got it! In the start, you are doing &writename **0** = 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 😃

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 22, 2004, 5:47pm UTC](https://forum.kirupa.com/t/php-syntax/116933/3 "2004-07-22T17:47:40Z")

</div>

and in the for loop you’re missing a $

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

lol 😛

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 22, 2004, 6:02pm UTC](https://forum.kirupa.com/t/php-syntax/116933/4 "2004-07-22T18:02:20Z")

</div>

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…

```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](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]

```php
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 ?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 22, 2004, 6:09pm UTC](https://forum.kirupa.com/t/php-syntax/116933/5 "2004-07-22T18:09:01Z")

</div>

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”

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 22, 2004, 6:19pm UTC](https://forum.kirupa.com/t/php-syntax/116933/6 "2004-07-22T18:19:09Z")

</div>

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;

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 22, 2004, 6:50pm UTC](https://forum.kirupa.com/t/php-syntax/116933/7 "2004-07-22T18:50:58Z")

</div>

almost there…

I had my for loop set to short.

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