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

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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