Join 132,685 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,259 people online right now. Registration is fast and FREE... Join Now!
Invalid query: 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 ''users' ('user_name','password','email','faction','confirmed','admin','beta_test' at line 1
I am not sure why this is erroring out after staring at it and trying to make adjustments for awhile to it.
I'm using:
PHP 5 MySQL
Here is the page code [long]:
CODE
<?php
include("smarty_include.php"); include ('db_var.php');
You have a syntax error in your SQL query. Specifically, you left a trailing comma after '$rank'
CODE
$query="INSERT INTO 'users' ('user_name','password','email','faction','confirmed','admin','beta_tester','wins','losses','points','rank') VALUES ('$user',(md5('$password')),'$email','$faction','$confirmed','$admin','$beta_tester','$wins','$losses','$points','$rank',);";
should be
CODE
$query="INSERT INTO 'users' ('user_name','password','email','faction','confirmed','admin','beta_tester','wins','losses','points','rank') VALUES ('$user',(md5('$password')),'$email','$faction','$confirmed','$admin','$beta_tester','$wins','$losses','$points','$rank')";
you also don't need both those semicolons. Just the one outside the double quotes will be fine. If you were running multiple queries at the same time you'd need the other one.
You have a syntax error in your SQL query. Specifically, you left a trailing comma after '$rank'
you also don't need both those semicolons. Just the one outside the double quotes will be fine. If you were running multiple queries at the same time you'd need the other one.
Hope that fixes your problem.
I fixed that [over looked that and THANKS!] but I'm getting the same error.
I've done an insert via PHPMyAdmin and the syntax follows what they produce so I'm at a loss.
You have a syntax error in your SQL query. Specifically, you left a trailing comma after '$rank'
you also don't need both those semicolons. Just the one outside the double quotes will be fine. If you were running multiple queries at the same time you'd need the other one.
Hope that fixes your problem.
I fixed that [over looked that and THANKS!] but I'm getting the same error.
I've done an insert via PHPMyAdmin and the syntax follows what they produce so I'm at a loss.
Well it says that the error is on line 1, so it's probably not what we though it was. I have a feeling the issue actually lies in your 'smart_include.php' or 'db_var.php' files. Can you post those without the login information? Just substitute anything sensitive with xxxxxxxx.
Well it says that the error is on line 1, so it's probably not what we though it was. I have a feeling the issue actually lies in your 'smart_include.php' or 'db_var.php' files. Can you post those without the login information? Just substitute anything sensitive with xxxxxxxx.
Ha ha, yeah I know that feeling. It kinda flagged when I looked at it but I didn't think anything of it. I'm working on work stuff, freelance stuff and trying to write part 2 of my regex tutorial, so I think my brain just collapsed. Ha ha.
lol... when I threw it into my PHP editor, it flew right out at me =P
i'm like "wait a minute, that doesn't look right!"
Thanks for the help guys. If fixed everything you pointed out.
I finally tracked it down when the error persisted.
For some reason, putting ' ' around the fields in user made it choke. When I took the ' ' from around the field names and left them around the '$somevariable' names it worked flawlessly.
Wow, definitely should've caught that. My bad. Glad you got it fixed!
So should I!! Staring at it didn't help and the SQL code generaged in MyPHPAdmin generated the same style I was using. So I'm not sure where the mismatch was THERE.
I can tell you this has been a major learning experience and I think my brain is melting!