Pyro4816 Posted December 3, 2006 Share Posted December 3, 2006 [code] <?phprequire_once('../includes/dbconnector.php');$connector = new dbconnector();if ($HTTP_GET_VARS['action'] == 'edit'){ $connector->query("UPDATE admin SET about,advertise,announcements,articles,contact,FAQ,downloads,index,members,news,sponsors,tutorials,header,footer =' ".$HTTP_POST_VARS['about']."',' ".$HTTP_POST_VARS['advertise']."',' ".$HTTP_POST_VARS['announcements']."',' ".$HTTP_POST_VARS['articles']."',' ".$HTTP_POST_VARS['contact']."',' ".$HTTP_POST_VARS['faq']."',' ".$HTTP_POST_VARS['downloads']."',' ".$HTTP_POST_VARS['index']."',' ".$HTTP_POST_VARS['members']."',' ".$HTTP_POST_VARS['news']."',' ".$HTTP_POST_VARS['sponsors']."',' ".$HTTP_POST_VARS['tutorials']."',' ".$HTTP_POST_VARS['header']."',' ".$HTTP_POST_VARS['footer']."' WHERE ID='0'"); echo '<center><b>Updated</b></center><br>',mysql_error(); }else{ echo '<center>Sorry, there was a problem!</center>',mysql_error(); }?>[/code]Well there are 2 errors with the script, one of them is i set my error up wrong, but thats not really a problem, the other is the syntax for inserting it, i am not sure what it is, but when i use it on only one it works fine, but when i use this setup (multiple inputs) it says that the query is empty. Any ideas o what i am doing wrong?it gives me this error if that helps?[quote]ou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'advertise,announcements,articles,contact,FAQ,downloads,index,members,news,sponso' at line 1[/quote] Link to comment https://forums.phpfreaks.com/topic/29272-syntax-error-with-updating-a-database/ Share on other sites More sharing options...
kenrbnsn Posted December 3, 2006 Share Posted December 3, 2006 Do not use $HTTP_GET_VARS and HTTP_POST_VARS, use $_GET and $_POST instead. But that's not your problem.You have:[code]<?php $connector->query("UPDATE admin SET about,advertise,announcements,articles,contact,FAQ,downloads,index,members,news,sponsors,tutorials,header,footer =' ".$HTTP_POST_VARS['about']."',' ".$HTTP_POST_VARS['advertise']."',' ".$HTTP_POST_VARS['announcements']."',' ".$HTTP_POST_VARS['articles']."',' ".$HTTP_POST_VARS['contact']."',' ".$HTTP_POST_VARS['faq']."',' ".$HTTP_POST_VARS['downloads']."',' ".$HTTP_POST_VARS['index']."',' ".$HTTP_POST_VARS['members']."',' ".$HTTP_POST_VARS['news']."',' ".$HTTP_POST_VARS['sponsors']."',' ".$HTTP_POST_VARS['tutorials']."',' ".$HTTP_POST_VARS['header']."',' ".$HTTP_POST_VARS['footer']."' WHERE ID='0'"); ?>[/code]But then say:[code]<?php$connector->query($insertQuery)?>[/code]Where is the variable $insertQuery being set?Ken Link to comment https://forums.phpfreaks.com/topic/29272-syntax-error-with-updating-a-database/#findComment-134174 Share on other sites More sharing options...
Pyro4816 Posted December 3, 2006 Author Share Posted December 3, 2006 I adapted it from another script where i insert into the database and set that variable, but i fixed that, any ideas about what my problem may be? Link to comment https://forums.phpfreaks.com/topic/29272-syntax-error-with-updating-a-database/#findComment-134182 Share on other sites More sharing options...
Pyro4816 Posted December 3, 2006 Author Share Posted December 3, 2006 OK, close please, i figured out what my problem was. Link to comment https://forums.phpfreaks.com/topic/29272-syntax-error-with-updating-a-database/#findComment-134185 Share on other sites More sharing options...
kenrbnsn Posted December 3, 2006 Share Posted December 3, 2006 Please post what your problem was.Ken Link to comment https://forums.phpfreaks.com/topic/29272-syntax-error-with-updating-a-database/#findComment-134212 Share on other sites More sharing options...
Pyro4816 Posted December 3, 2006 Author Share Posted December 3, 2006 the syntax was completely wrong, here is a copy of the fixed code. [code] <?phprequire_once('../includes/dbconnector.php');$connector = new dbconnector();if ($HTTP_GET_VARS['action'] == 'edit'){ $connector->query("UPDATE admin SET about='" .$_POST['about']."',advertise='" .$_POST['advertise']."' ,announcements='" .$_POST['announcements']."' ,articles='" .$_POST['articles']."' ,contact='" .$_POST['contact']."' ,downloads='" .$_POST['downloads']."' ,FAQ='" .$_POST['faq']."' ,indecs='" .$_POST['indecs']."' ,members='" .$_POST['members']."' ,news='" .$_POST['news']."' ,sponsors='" .$_POST['sponsors']."' ,tutorials='" .$_POST['tutorials']."' ,header='" .$_POST['header']."' ,footer='" .$_POST['footer']."' WHERE ID=0"); echo '<center><b>Updated</b></center><br>'; }else{ echo '<center>Sorry, there was a problem, contact Joey ASAP!</center>'; }?>[/code] Link to comment https://forums.phpfreaks.com/topic/29272-syntax-error-with-updating-a-database/#findComment-134214 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.