Forum Moderators: coopster

Message Too Old, No Replies

Parse error....

Cant solve parse error problem...

         

PSWorx

10:12 am on Jan 5, 2005 (gmt 0)

10+ Year Member



Problem: Parse error: parse error in #*$!#*$!xxxxxxxxxxxxxxxxx.php on line 62 ("where line 62 reads: $imageField=mysql_fetch_array($imageResult){")

//Source

for($imageCount = 1; $imageCount <= 3; $imageCount ++){
$imageResult=mysql_query("SELECT * FROM dni_products WHERE prod_id='$product_id'");
$imageField=mysql_fetch_array($imageResult){
$imageRef="$imageField[prod_pic_".$imageCount."]";
if(($imageRef=="")OR($imageRef=="images/catalogue/noItem.gif")){
echo"<td valign=\"top\" align=\"center\">&nbsp;</td>";
}else{
echo"<td valign=\"top\" align=\"center\"><div class=\"itemBGsV\" align=\"center\"><img src=\"images/main/spacer.gif\" width=\"1\" height=\"4\" border=\"0\"><br clear=\"all\"><a href=\"#\" onClick=\"MM_swapImage('singleSwap','','".$dirSub."images/catalogue/products/".$imageField[prod_id]."/large/".$imageField[prod_pic_".$imageCount."]."',1)\"><img src=\"images/catalogue/products/".$imageFieldield[prod_id]."/thumbs/".$imageField[prod_pic_$imageCount]."\" alt=\"".$imageField[prod_name]."\" width=\"55\" height=\"62\" border=\"0\"></a><br clear=\"all\"><img src=\"images/main/spacer.gif\" width=\"1\" height=\"4\" border=\"0\"><br clear=\"all\"></div></td>";
}
}
}

//End Source

For the life of me i can not seem to sort this out, if you cant figure out what its meant to do then here it is:

It finds a row according to the product id, then in that row are three image name place holder columns, the script should go thru those columns deciding weather or not to display a full image box or just an empty table cell.

Anyone, anyone at all, a solution would be much appreciated.

TIA

Mr Davidson

dreamcatcher

10:35 am on Jan 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The parse error doesn`t always mean that the line in question has the error. In this case, the error will be from this line:

for($imageCount = 1; $imageCount <= 3; $imageCount ++){

You are missing a semi colon after $imageCount++. Should be:

for( $imageCount = 1; $imageCount <= 3; $imageCount++; ){

dc

PSWorx

6:35 pm on Jan 5, 2005 (gmt 0)

10+ Year Member



Ok, did as you said and had no luck, it seems it wants to cut off the parameters of the for statement before i declare $var++ - i tried a simple example to check, here it is:

for( $x=1; $x<=10; $x++;){
echo"\$x=".$x."\n";
}

Which resulted in this parse error:
Parse error: parse error, expecting `')'' in BLAH BLAH

I space out each parameter so as to determine where the problem lies and this is the result when using the following code setup:

for(
$x=1;
$x<=10;
$x++;
){
echo"\$x=".$x."\n";
}

The line in which the error lies seems to be with the last parameter, as u can see stating a missing ")" or "'" i cant quite tell nor decide let alone fathem it out. I've solved the issue with a work around altho if possible would like to resolve the problem with regards to the for statement.

Any help again would be apprecited

NOTE: I'm testing using apache/mysql on a win xp pro, not sure if this could be the root of the problem but every bit of info helps.

TIA

Birdman

6:58 pm on Jan 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




for($imageCount = 1; $imageCount <= 3; $imageCount++)
{
$imageResult=mysql_query("SELECT ....");
$imageField=mysql_fetch_array($imageResult){ //error is here
$imageRef="$imageField[prod_pic_".$imageCount."]";
if(($imageRef=="")OR($imageRef=="...gif")){
echo"<td>&nbsp;</td>";
} else {
echo"<td>...YOUR IMAGE CODE HERE...</td>";
}
}
}

Now, looking at error line closely:

$imageField=mysql_fetch_array($imageResult){ //error is here

You have an opening bracket( { ), which usually signals that there is some sort of loop or if/else. So, to fix the above, incorporate you loop(I think while() loop is what you want).

while( $imageField=mysql_fetch_array($imageResult) ){

That should take care of it.

PSWorx

1:11 am on Jan 6, 2005 (gmt 0)

10+ Year Member



I can see what your getting there but i don't quite understand why the problem still occurs using the simplest of 'for' statements as presented in the third post of the given topic i am replying too, i will try this out tomorrow when i get back from work and correspond with the results, thanks again for your time and advice.

Mr Davidson