Jump to content

[SOLVED] how can i make this if else statement work?


shadiadiph

Recommended Posts

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>';
}
?>

 

 

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?

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>';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.