Jump to content

Archived

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

dprichard

Using if else with forms and variables

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]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.