pudge1 Posted March 30, 2009 Share Posted March 30, 2009 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 ')' I keep getting that error whenever I try and run my script. Here is my script: $my = mysql_connect("localhost","nintendo_pudge","*****"); if(!$my) { echo "Failed to Connect to MySQL Database<br />"; echo mysql_error(); exit; } else{} $con2 = mysql_select_db("nintendo_urlblurusers", $my); if(!$con2) { echo mysql_error(); exit; } else { } $var = "CREATE TABLE Users ( userID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(userID), Username varchar(15), Password varchar(15), Email varchar(35), AccountType varchar(10), PayPalEmail varchar(35), )"; $con3 = mysql_query($var,$my); if(!$con3) { echo mysql_error(); exit; } else { } $con4 = mysql_query("INSERT INTO urlblur_users (Username,Password,Email,AccountType,PPEmail) VALUES ($username,$password,$email,$atype,$ppemail)"); if(!$con4) { echo myql_error(); exit; } else { } mysql_close($my); Anyway I am really new to MySQL this is my first MySQL form I have started. I am really good with PHP though. Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/ Share on other sites More sharing options...
FaT3oYCG Posted March 30, 2009 Share Posted March 30, 2009 $var = "CREATE TABLE Users ( userID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(userID), Username varchar(15), Password varchar(15), Email varchar(35), AccountType varchar(10), PayPalEmail varchar(35), )"; change to $var = "CREATE TABLE Users ( userID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(userID), Username varchar(15), Password varchar(15), Email varchar(35), AccountType varchar(10), PayPalEmail varchar(35))"; Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796507 Share on other sites More sharing options...
pudge1 Posted March 30, 2009 Author Share Posted March 30, 2009 Fixed that problem thank you for that. But now I get this 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 '@yahoo.com,free,)' at line 2 Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796509 Share on other sites More sharing options...
FaT3oYCG Posted March 30, 2009 Share Posted March 30, 2009 what is line 2? Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796516 Share on other sites More sharing options...
pudge1 Posted March 30, 2009 Author Share Posted March 30, 2009 I don't know. MySQL's line system is a lot different than PHPs. However it must be where the $email variable is because I see @yahoo.com which is from the e-mail Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796524 Share on other sites More sharing options...
Infinitive Posted March 30, 2009 Share Posted March 30, 2009 Your strings should be in quotes: '$email' Also be careful about data validation, if you haven't guarded against injection (or accidental problems) yet. I use something like: $SafeVariable = addslashes(htmlspecialchars($RawVariable)); Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796525 Share on other sites More sharing options...
pudge1 Posted March 30, 2009 Author Share Posted March 30, 2009 Thank you for that both of those things. Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796527 Share on other sites More sharing options...
pudge1 Posted March 30, 2009 Author Share Posted March 30, 2009 Hmm now I am getting a query is empty error. Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796528 Share on other sites More sharing options...
Infinitive Posted March 30, 2009 Share Posted March 30, 2009 Might want to repaste your code now, if there have been a few changes. Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796529 Share on other sites More sharing options...
pudge1 Posted March 30, 2009 Author Share Posted March 30, 2009 $my = mysql_connect("localhost","nintendo_pudge","*********"); if(!$my) { echo "Failed to Connect to MySQL Database<br />"; echo mysql_error(); exit; } else{} $con2 = mysql_select_db("nintendo_urlblurusers", $my); if(!$con2) { echo mysql_error(); exit; } else { } $con3 = mysql_query($var,$my); if(!$con3) { echo mysql_error(); exit; } else { } $con4 = mysql_query("INSERT INTO URLBlurUsers (Username,Password,Email,AccountType,PPEmail) VALUES ('$username','$password','$email','$atype','$ppemail')"); if(!$con4) { echo mysql_error(); exit; } else { } mysql_close($my); echo '<div id="output"><br />You Have Registered Successfully<br /><br /></div>'; Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796530 Share on other sites More sharing options...
corbin Posted March 30, 2009 Share Posted March 30, 2009 $SafeVariable = addslashes(htmlspecialchars($RawVariable)); mysql_real_escape_string() is preferred over addslashes() now. Also, generally HTML is escaped when outputting to the web browser, not when inserting. pudge1, $var isn't defined anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796540 Share on other sites More sharing options...
pudge1 Posted March 30, 2009 Author Share Posted March 30, 2009 lol Guess there is a lot of problems with my script. I forgot to take out that thing after I removed something. Anyway thank you. But now I have another problem ughhhh Unknown Column PPEmail in Field List Updated Code: $my = mysql_connect("localhost","nintendo_pudge","Franz5211-"); if(!$my) { echo "Failed to Connect to MySQL Database<br />"; echo mysql_error(); exit; } else{} $con2 = mysql_select_db("nintendo_urlblurusers", $my); if(!$con2) { echo mysql_error(); exit; } else { } $con4 = mysql_query("INSERT INTO URLBlurUsers (Username,Password,Email,AccountType,PPEmail) VALUES ('$username','$password','$email','$atype','$ppemail')"); if(!$con4) { echo mysql_error(); exit; } else { } mysql_close($my); echo '<div id="output"><br />You Have Registered Successfully<br /><br /></div>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796543 Share on other sites More sharing options...
pudge1 Posted March 30, 2009 Author Share Posted March 30, 2009 Nevermind fixed it. Works perfectly now. Thanks to all who helped or attempted to help. Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-796547 Share on other sites More sharing options...
fenway Posted April 1, 2009 Share Posted April 1, 2009 Nevermind fixed it. Works perfectly now. Thanks to all who helped or attempted to help. How? Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-798572 Share on other sites More sharing options...
pudge1 Posted April 1, 2009 Author Share Posted April 1, 2009 The column on the Table wasn't called something a little different. Quote Link to comment https://forums.phpfreaks.com/topic/151676-solved-mysql-problem/#findComment-799034 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.