shadiadiph Posted December 31, 2008 Share Posted December 31, 2008 Hi as some of you probably realise I am quite new to php I have been pulling my hair out trying to get my images to edit or delete I have come up with a solution that in theory should work but my coding is a bit messed up any help will be appreciated I am always learning new things. Here is my code which is producing the error Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /home/hmtcompa/public_html/user/myaccount/updatepix.php on line 168 which is the first if clause in the scripta anyway any help or comments would be great I am sure it is worded wrong ;( I am basically trying to work out if thre vaule of $file1 has a value if not then return the else statment. <?php $sql01 = "SELECT thumbnail1,thumbnail2,thumbnail3,thumbnail4 FROM zloads WHERE intProductID='$id'"; $temps = $DB_site->query($sql); if($row=$DB_site->fetch_array($temps)) { $file1 = $row["thumbnail1"]; $file2 = $row["thumbnail2"]; $file3 = $row["thumbnail3"]; $file4 = $row["thumbnail4"]; } if ($file1==1) { echo'<td><img src="editpic1.php?adid='.$id.'" /><br /> <a href="updatepix.php?id='.$id.'&action=delete1">Delete</a> <a href="updatepix.php?id='.$id.'&action=edit1">Edit</a></td>'; } else { echo '<td>hello</td>'; } ?> <? if ($file2==1) { echo'<td><img src="editpic2.php?adid='.$id.'" /><br /> <a href="updatepix.php?id='.$id.'&action=delete2">Delete</a> <a href="updatepix.php?id='.$id.'&action=edit2">Edit</a></td>'; } else { echo '<td>hello</td>'; } ?> Link to comment https://forums.phpfreaks.com/topic/138943-solved-how-can-i-make-this-if-else-statement-work/ Share on other sites More sharing options...
awpti Posted December 31, 2008 Share Posted December 31, 2008 You've got some pretty obvious typos/syntax errors here. I'll assume you copied/pasted this as-is. We can't magically determine which line is really 168, so why not point that one out for us? Link to comment https://forums.phpfreaks.com/topic/138943-solved-how-can-i-make-this-if-else-statement-work/#findComment-726676 Share on other sites More sharing options...
shadiadiph Posted December 31, 2008 Author Share Posted December 31, 2008 the error is where if ($file1==1) Link to comment https://forums.phpfreaks.com/topic/138943-solved-how-can-i-make-this-if-else-statement-work/#findComment-726680 Share on other sites More sharing options...
shadiadiph Posted December 31, 2008 Author Share Posted December 31, 2008 sorry actually i just noticed the error yes i copied and pasted the top and edited it from another part of my script as it is easier than rewriting it i just changed $temps = $DB_site->query($sql); to $temps = $DB_site->query($sql01); and the script works but it doesn't as it always shows the else value even though $file1 has a value? Link to comment https://forums.phpfreaks.com/topic/138943-solved-how-can-i-make-this-if-else-statement-work/#findComment-726686 Share on other sites More sharing options...
shadiadiph Posted December 31, 2008 Author Share Posted December 31, 2008 if ($file1==0) if ($file2==0) always returns the image even a blank one where there is not one in the database? never returns the else statement Link to comment https://forums.phpfreaks.com/topic/138943-solved-how-can-i-make-this-if-else-statement-work/#findComment-726694 Share on other sites More sharing options...
shadiadiph Posted December 31, 2008 Author Share Posted December 31, 2008 ok no problem solved it with <?php $sql01 = "SELECT thumbnail1,thumbnail2,thumbnail3,thumbnail4 FROM zloads WHERE intProductID='$id'"; $temps = $DB_site->query($sql01); if($row=$DB_site->fetch_array($temps)) { $file1 = $row["thumbnail1"]; $file2 = $row["thumbnail2"]; $file3 = $row["thumbnail3"]; $file4 = $row["thumbnail4"]; } if ($file1 ==true ) { echo'<td><img src="editpic1.php?adid='.$id.'" /><br /> <a href="updatepix.php?id='.$id.'&action=delete1">Delete</a> <a href="updatepix.php?id='.$id.'&action=edit1">Edit</a></td>'; } else { echo '<td><img src="../../pix/noimage.png" /></td>'; } if ($file2 ==true) { echo'<td><img src="editpic2.php?adid='.$id.'" /><br /> <a href="updatepix.php?id='.$id.'&action=delete2">Delete</a> <a href="updatepix.php?id='.$id.'&action=edit2">Edit</a></td>'; } else { echo '<td><img src="../../pix/noimage.png" /></td>'; } ?> Link to comment https://forums.phpfreaks.com/topic/138943-solved-how-can-i-make-this-if-else-statement-work/#findComment-726710 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.