Jump to content

[SOLVED] stupid mysql syntax error


thewooleymammoth

Recommended Posts

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

<?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?!  ;)

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

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());
?>

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.