Jump to content

Using if else with forms and variables


dprichard

Recommended Posts

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!


[code]
<?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">'; }
                      
?>
[/code]
Link to comment
Share on other sites

Too many double quotes in this line:
[code]<?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">";
?>[/code]
try
[code]</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">';
?>[/code]
You almost got it right with the second "echo", change it from:
[code]<?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">';
?>[/code]
to
[code]<?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">';
?>[/code]

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.