Jump to content

[SOLVED] query help


adamlacombe

Recommended Posts

I keep getting this error:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(`status`) values('') where id='1'' at line 1

 

and this is what my query is:

<?
include "db.php";

mysql_query("UPDATE settings set (`status`) values('$status') where id='1'") or die(mysql_error());
echo '<div class=\'msg\'>Settings updated</div><p>';
?>

 

Whats wrong with the query?

Link to comment
Share on other sites

You can just use the more conventional style of UPDATE:

 

UPDATE settings SET`status` = '$status' where id=1

 

Don't need single quotes around '1', assuming id is an integer.

Link to comment
Share on other sites

still not working..

 

This is what I have:

<?
include "db.php";

if($_POST['submit']){
mysql_query("UPDATE settings SET `status` = '$status' where id=1") or die(mysql_error());
echo '<div class=\'msg\'>Settings updated</div><p>';
}else{

echo'
<table>
<form action="settings.php" method="POST">
<tr>
<td class="content">Status:</td>
<td class="content"><input name="status" type="text" size="50"></td>
</tr>

<td class="content" colspan="4">
<input type="submit" name="submit" id="submit" value="Submit Changes">
</td>
</tr>
</table></form>';
}
?>

Link to comment
Share on other sites

That's because there is no code settings $status to anything (damn those register_globals and all the wasted time they have caused.)

 

I share the same feelings.

 

oh, DUH. lol. thanks!

 

A reminder that you should never use shorthand () PHP tags for a couple reasons but mainly portability.  Use full <?php opening tags.

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.