adamlacombe Posted June 29, 2009 Share Posted June 29, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/164150-solved-query-help/ Share on other sites More sharing options...
Maq Posted June 29, 2009 Share Posted June 29, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164150-solved-query-help/#findComment-865902 Share on other sites More sharing options...
PFMaBiSmAd Posted June 29, 2009 Share Posted June 29, 2009 FYI: An INSERT has the two different syntaxes. An UPDATE only has the one syntax (i.e. the way Maq posted it.) Quote Link to comment https://forums.phpfreaks.com/topic/164150-solved-query-help/#findComment-865906 Share on other sites More sharing options...
adamlacombe Posted June 29, 2009 Author Share Posted June 29, 2009 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>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/164150-solved-query-help/#findComment-865907 Share on other sites More sharing options...
Maq Posted June 29, 2009 Share Posted June 29, 2009 Did you receive and error? Quote Link to comment https://forums.phpfreaks.com/topic/164150-solved-query-help/#findComment-865908 Share on other sites More sharing options...
adamlacombe Posted June 29, 2009 Author Share Posted June 29, 2009 no, it just inserted nothing.. Quote Link to comment https://forums.phpfreaks.com/topic/164150-solved-query-help/#findComment-865909 Share on other sites More sharing options...
PFMaBiSmAd Posted June 29, 2009 Share Posted June 29, 2009 That's because there is no code settings $status to anything (damn those register_globals and all the wasted time they have caused.) Quote Link to comment https://forums.phpfreaks.com/topic/164150-solved-query-help/#findComment-865912 Share on other sites More sharing options...
adamlacombe Posted June 29, 2009 Author Share Posted June 29, 2009 oh, DUH. lol. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/164150-solved-query-help/#findComment-865915 Share on other sites More sharing options...
Maq Posted June 29, 2009 Share Posted June 29, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164150-solved-query-help/#findComment-865945 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.