thewooleymammoth Posted September 16, 2007 Share Posted September 16, 2007 this returns a syntax 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 'updatenumber=2 WHERE num='1'' at line 1 <?php $query=mysql_query("SELECT*FROM $table WHERE num='1'") or die(mysql_error()); $result=mysql_fetch_assoc($query); $newresult=$result['updatenumber']+1; $connectmysql=mysql_connect('localhost',$username,$password) or die(mysql_error()); $selectdb=mysql_select_db($database) or die(mysql_error()); $connectmysql; $selectdb; $filehandle = fopen($filename, "w"); $query; mysql_query("UPDATE $database $table updatenumber=$newresult WHERE num='1';") or die(mysql_error()); ?> in mysql i want it to update a number, there are two columns in the database one is num one is update number... thanks. idk what the syntax error is but i cant figure it out. help appreciated Link to comment https://forums.phpfreaks.com/topic/69530-solved-stupid-mysql-syntax-error/ Share on other sites More sharing options...
Crew-Portal Posted September 16, 2007 Share Posted September 16, 2007 <?php $query=mysql_query("SELECT*FROM $table WHERE num='1'") or die(mysql_error()); $result=mysql_fetch_assoc($query); $newresult=$result['updatenumber']+1; $connectmysql=mysql_connect('localhost',$username,$password) or die(mysql_error()); $selectdb=mysql_select_db($database) or die(mysql_error()); $connectmysql; $selectdb; $filehandle = fopen($filename, "w"); $query; mysql_query("'UPDATE' . `$database` . `$table` . 'updatenumber=' . `$newresult` . 'WHERE num='1';") or die(mysql_error()); ?> Hope this helps?! Link to comment https://forums.phpfreaks.com/topic/69530-solved-stupid-mysql-syntax-error/#findComment-349366 Share on other sites More sharing options...
thewooleymammoth Posted September 16, 2007 Author Share Posted September 16, 2007 nope 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 ''UPDATE' . `userlist` . `filenames` . 'updatenumber=' . `2` . 'WHERE num='1'' at line 1 i hate errors i cant figure out Link to comment https://forums.phpfreaks.com/topic/69530-solved-stupid-mysql-syntax-error/#findComment-349367 Share on other sites More sharing options...
Casalen Posted September 16, 2007 Share Posted September 16, 2007 . [edit] I had an issue with posting this, but it's a bit late anyway. Nevermind. Link to comment https://forums.phpfreaks.com/topic/69530-solved-stupid-mysql-syntax-error/#findComment-349371 Share on other sites More sharing options...
Crew-Portal Posted September 16, 2007 Share Posted September 16, 2007 Wow was I ewver wrong bumped your error to the first line whoops! Okay sorry but try this one! Just making sure you had a backup the time before lol! <?php $query=mysql_query("SELECT*FROM $table WHERE num='1'") or die(mysql_error()); $result=mysql_fetch_assoc($query); $newresult=$result['updatenumber']+1; $connectmysql=mysql_connect('localhost',$username,$password) or die(mysql_error()); $selectdb=mysql_select_db($database) or die(mysql_error()); $connectmysql; $selectdb; $filehandle = fopen($filename, "w"); $query; mysql_query("UPDATE $database $table updatenumber=`$newresult` WHERE num='1';") or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/69530-solved-stupid-mysql-syntax-error/#findComment-349373 Share on other sites More sharing options...
thewooleymammoth Posted September 16, 2007 Author Share Posted September 16, 2007 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 'updatenumber=`2` WHERE num='1'' at line 1 lol nope, thanks for the help btw Im using wamp5 do you think htat could be the problem? perhaps because its not a regularly installed apche php and mysql its not evaluating things correctly? Link to comment https://forums.phpfreaks.com/topic/69530-solved-stupid-mysql-syntax-error/#findComment-349375 Share on other sites More sharing options...
thewooleymammoth Posted September 16, 2007 Author Share Posted September 16, 2007 Alright i solved it, the correct syntax was "UPDATE $table SET `updatenumber` = '$newresult' WHERE `$table`.`num` =1;" Link to comment https://forums.phpfreaks.com/topic/69530-solved-stupid-mysql-syntax-error/#findComment-349643 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.