Jump to content

You have an error in your SQL syntax.......


kurtis

Recommended Posts

yes its the annoying "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 '' at line 1" error!
im follwing the user system tutorial but made my own registration page becuase i couldnt get the other one working so i made my own which seems to promise more but i still get this error and i dont know why  ???
anyone got any ideas?
thanks
Link to comment
https://forums.phpfreaks.com/topic/16481-you-have-an-error-in-your-sql-syntax/
Share on other sites

db.php:
[code]
<?
$link = mysql_CONNECT(localhost,root);
mysql_select_db(dijeridooo);
if (!$link) {
die('could not connect:' . mysql_error());
}
echo 'connection succesful';
?>
[/code]
(i added the echo just to make sure it was connecting)

registration file:
[code]
$query = mysql_query('INSERT INTO users VALUES(id, username, encryptpass, password, name, prov, style, hist, infl, open, webs, email, photo, signupdate') or die (mysql_error());
[/code]
ye i thought that :S i rote it originally i had a few errors so i asked my mate for advice(hes been doing it longer than me) n he just messed round with the connection till it came up with this error and the he didnt know what to do :S this is the one i had before:
[code]
$query = mysql_query('INSERT INTO users VALUES(id=$id, username=$username, encryptpass=$encryptpass, password=$password, name=$name, prov=$prov, style=$style, hist=$hist, infl=$infl, open=$open, webs=$webs, email=$email, signupdate=now()') or die (mysql_error());
[/code]
While you can use a variation of the UPDATE syntax for inserts, I prefer to use the more conventional approach:

[code]
$query = mysql_query('INSERT INTO users (id, username, encryptpass, password, name, prov, style, hist, infl, open, webs, email, photo, signupdate ) VALUES('$id', '$username', '$encryptpass', '$password', '$name', '$prov', '$style', '$hist', '$infl', '$open', '$webs', '$email', now()) or die (mysql_error());
[/code]

What Fenway meant of course was

[code]
$query = mysql_query("INSERT INTO users (id, username, encryptpass, password, name, prov, style, hist, infl, open, webs, email, photo, signupdate ) VALUES('$id', '$username', '$encryptpass', '$password', '$name', '$prov', '$style', '$hist', '$infl', '$open', '$webs', '$email', now()") or die (mysql_error());
[/code]

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.