Jump to content


Photo

Using if else with forms and variables


  • Please log in to reply
2 replies to this topic

#1 dprichard

dprichard
  • Members
  • PipPipPip
  • Advanced Member
  • 139 posts
  • LocationTampa, FL

Posted 12 April 2006 - 03:09 PM

I am not sure what I am doing wrong here, but I am trying to make a form that changes based on the status of a gallery in my script. Here is the If statement, but I am getting the followin error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in D:\sitename\admin\admin-gallery-add-1.php on line 161

Any help would be greatly appreciated. Thank you!


<?php 
                        
if ($row_galleries['gallery_status'] == 0) {

echo "<input name="gallery_status" type="hidden" id="gallery_status" value="1">
<input name="gallery_id" type="hidden" id="gallery_id" value="$row_galleries['gallery_id']">
<input type="image" name="submit2" src="../images/icons/forbidden.png" width="16" height="16">";
                       
} if ($row_galleries['gallery_status'] == 1) {
                      
echo '<input name="gallery_status" type="hidden" id="gallery_status" value="0">
<input name="gallery_id" type="hidden" id="gallery_id" value="echo $row_galleries['gallery_id']">
 <input type="image" name="submit2" src="../images/icons/add.png" width="16" height="16">'; }
                      
?>

dprichard

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 12 April 2006 - 03:14 PM

Too many double quotes in this line:
<?php
echo "<input name="gallery_status" type="hidden" id="gallery_status" value="1">
<input name="gallery_id" type="hidden" id="gallery_id" value="$row_galleries['gallery_id']">
<input type="image" name="submit2" src="../images/icons/forbidden.png" width="16" height="16">";
?>
try
</php
echo '<input name="gallery_status" type="hidden" id="gallery_status" value="1">
<input name="gallery_id" type="hidden" id="gallery_id" value="' . $row_galleries['gallery_id'] .'">
<input type="image" name="submit2" src="../images/icons/forbidden.png" width="16" height="16">';
?>
You almost got it right with the second "echo", change it from:
<?php
echo '<input name="gallery_status" type="hidden" id="gallery_status" value="0">
<input name="gallery_id" type="hidden" id="gallery_id" value="echo $row_galleries['gallery_id']">
<input type="image" name="submit2" src="../images/icons/add.png" width="16" height="16">';
?>
to
<?php
echo '<input name="gallery_status" type="hidden" id="gallery_status" value="0">
<input name="gallery_id" type="hidden" id="gallery_id" value="' .  $row_galleries['gallery_id'] . '">
<input type="image" name="submit2" src="../images/icons/add.png" width="16" height="16">';
?>

Ken


#3 dprichard

dprichard
  • Members
  • PipPipPip
  • Advanced Member
  • 139 posts
  • LocationTampa, FL

Posted 12 April 2006 - 05:26 PM

Thanks, that worked...
dprichard




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users