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 Quote Link to comment 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?! Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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()); ?> Quote Link to comment 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? Quote Link to comment 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;" Quote Link to comment 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.