pocobueno1388 Posted June 19, 2006 Share Posted June 19, 2006 I am using Phpmyadmin to build my tables, but yet when I submit a form from my website to add information in my tables 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 '' at line 4I did not manually create this SQL, so I don't know how phpmyadmin could mess it up. Is this an SQL problem or is it my script? From the error message it seems like the SQL and database is where the problem is. If you could help me with this, that woud be great. By the way, I am hosting with godaddy.com, not sure if that will help or not. Maybe they don't support something. I don't know. I a fairly new to programming, but I didn't know I could have a problem like this with phpmyadmin(if that is really the problem.).Thanks in advance for you help =D Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/ Share on other sites More sharing options...
Ninjakreborn Posted June 19, 2006 Share Posted June 19, 2006 Don't waste your time letting it do that for you, sql itself is very simple to learn, it's when you are using php to access sql is when it starts getting hard, go to someplace with simple to understand sql syntax if you are trying to just create a table just doCREATE TABLE tablenamehereand it will create a table, build onto that to do more with your tables, if you need more help just ask, BUT BE SPECIFIC.Like something specific you want to do. Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-47392 Share on other sites More sharing options...
pocobueno1388 Posted June 19, 2006 Author Share Posted June 19, 2006 Well...I am trying to access the table through php, but I am sure I don't have it wrong. Why would I need to create the table using PHP when I already have it created? I know how to build a table from scratch with SQL, but not with php. So I guess I am not sure what to do with your advice. Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-47487 Share on other sites More sharing options...
poirot Posted June 20, 2006 Share Posted June 20, 2006 Your query is not correct. Print it out and try to check out what is not correct. Or post your script here. Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-47503 Share on other sites More sharing options...
pocobueno1388 Posted June 20, 2006 Author Share Posted June 20, 2006 <?phpinclude "config.php";include "header.php";if($_POST['login_name']){// Define post fields into simple variables$loginname = $_POST['login_name'];$username = $_POST['username'];$password = $_POST['password'];$vpassword = $_POST['vpassword'];$email = $_POST['email'];/* Let's strip some slashes in case the user enteredany escaped characters. */$loginname = stripslashes($login_name);$username = stripslashes($username);$password = stripslashes($password);$vpassword = stripslashes($vpassword);$email = stripslashes($email);/* Do some error checking on the form posted fields */if((!$loginname) || (!$username) || (!$password) || (!$email)){ echo 'You did not submit the following required information! <br />'; if(!$login_name){ echo "Login Name is a required field. Please enter it below.<br />"; } if(!$username){ echo "Desired Username is a required field. Please enter it below.<br />"; } if(!$password){ echo "Password is a required field. Please enter it below."; } if(!$email){ echo "Email is a required field. Please enter it below.<br />"; } include 'join_form.html'; // Show the form again! /* End the error checking and if everything is ok, we'll move on to creating the user account */ exit(); // if the error checking has failed, we'll exit the script!} /* Let's do some checking and ensure that the user's email address or username does not exist in the database */ $sql_email_check = mysql_query("SELECT email FROM players WHERE email='$email'"); $sql_username_check = mysql_query("SELECT username FROM players WHERE username='$username'"); $email_check = mysql_num_rows($sql_email_check); $username_check = mysql_num_rows($sql_username_check); if(($email_check > 0) || ($username_check > 0)){ echo "Please fix the following errors: <br />"; if($email_check > 0){ echo "<strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br />"; unset($email_address); } if($username_check > 0){ echo "The username you have selected has already been used by another member in our database. Please choose a different Username!<br />"; unset($username); } include 'join_form.html'; // Show the form again! exit(); // exit the script so that we do not create this account! } /* Everything has passed both error checks that we have done.It's time to create the account! */// Enter info into the Database.$info2 = htmlspecialchars($info);$sql = mysql_query("INSERT INTO users (loginname, username, password, vpassword, email) VALUES('$loginname', '$username', '$password', '$vpassword', '$email'") or die (mysql_error());if(!$sql){ echo 'There has been an error creating your account. Please contact the webmaster.';} else { $userid = mysql_insert_id(); // Let's mail the user! $subject = "Dog Game"; $message = "Hello $username, Thank you for registering at our website, www..com you will be able to login with the following information: Username: $username Password: $password Thanks! Colin (Game Owner/creator) This is an automated response, please do not reply!"; mail($email, $subject, $message, "From: Dogs Webmaster<colin@mydomain.com>\n X-Mailer: PHP/" . phpversion()); echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';}exit;}?><form name="form1" method="post" action="join_form.php"> <table border="0" cellpadding="4" cellspacing="0" width="100%" valign="center"> <tbody><tr> <td align="left" valign="top" width="24%">Login Name</td> <td width="76%"><input name="login_name" id="loginname" value="" type="text"></td> </tr> <tr> <td align="left" valign="top">Desired Username</td> <td><input name="username" id="username" value="" type="text"></td> </tr> <tr> <td align="left" valign="top">Password</td> <td><input name="password" id="password" value="" type="password"></td> </tr> <tr> <td align="left" valign="top">Re-type Password</td> <td><input name="vpassword" id="vpassword" value="" type="password"></td> </tr> <tr> <td align="left" valign="top">Email</td> <td><input name="email" id="email" value="" type="text"></td> </tr> <tr> <td align="left" valign="top"> </td> <td><input name="Submit" value="Join Now!" type="submit"></td> </tr> </tbody></table></form> Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-47527 Share on other sites More sharing options...
fenway Posted June 20, 2006 Share Posted June 20, 2006 Which query are you getting this error for? Just post the SQL statement and the corresponding error, not all of the PHP code. Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-47653 Share on other sites More sharing options...
pocobueno1388 Posted June 20, 2006 Author Share Posted June 20, 2006 Here is the query:$sql = mysql_query("INSERT INTO users (loginname, username,password, vpassword, email)VALUES('$loginname', '$username', '$password','$vpassword', '$email'")or die (mysql_error());Here is the 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 '' at line 4 Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-47665 Share on other sites More sharing options...
pocobueno1388 Posted June 20, 2006 Author Share Posted June 20, 2006 I really want to get started, so I really want someone to help me :/ Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-47797 Share on other sites More sharing options...
fenway Posted June 21, 2006 Share Posted June 21, 2006 [!--quoteo(post=386017:date=Jun 20 2006, 10:02 AM:name=Colin1388)--][div class=\'quotetop\']QUOTE(Colin1388 @ Jun 20 2006, 10:02 AM) [snapback]386017[/snapback][/div][div class=\'quotemain\'][!--quotec--]Here is the query:$sql = mysql_query("INSERT INTO users (loginname, username,password, vpassword, email)VALUES('$loginname', '$username', '$password','$vpassword', '$email'")or die (mysql_error());Here is the 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 '' at line 4[/quote]Post the value of the statement itself, not the PHP code that generates it... the error will be quite obvious. Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-47929 Share on other sites More sharing options...
pocobueno1388 Posted June 21, 2006 Author Share Posted June 21, 2006 I guess I don't understand. The values will be what the user enters, so I really can't give you a straight answer on that. Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-48065 Share on other sites More sharing options...
Ninjakreborn Posted June 21, 2006 Share Posted June 21, 2006 '$email'")get rid of those 2 quotation marks at the end just leave'$email') Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-48072 Share on other sites More sharing options...
pocobueno1388 Posted June 21, 2006 Author Share Posted June 21, 2006 businessman332211 - When I do that the entire page just goes blank. So they obviously need to be there. This is so frustrating. Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-48137 Share on other sites More sharing options...
pocobueno1388 Posted June 22, 2006 Author Share Posted June 22, 2006 Anyone have anymore ideas? Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-48307 Share on other sites More sharing options...
poirot Posted June 22, 2006 Share Posted June 22, 2006 Try to change this:[code]$sql = mysql_query("INSERT INTO users (loginname, username,password, vpassword, email)VALUES('$loginname', '$username', '$password','$vpassword', '$email'")or die (mysql_error());[/code]To:[code]$sql = mysql_query("INSERT INTO users (loginname, username, password, vpassword, email)VALUES('$loginname', '$username', '$password', '$vpassword', '$email')") or die (mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-48358 Share on other sites More sharing options...
pocobueno1388 Posted June 23, 2006 Author Share Posted June 23, 2006 poirot has solved all my problems =D I have gotten so many things done today, thanks to poirot. -worships- Thank you so much. I should have caught that error myself, but I am rather new...so my eyes are not trained enough yet to see those kinds of mistakes. I am sure I will be needing help again soon with something else, I will probably be having a lot more questions as I go through my current project. Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-48708 Share on other sites More sharing options...
fenway Posted June 23, 2006 Share Posted June 23, 2006 [!--quoteo(post=387084:date=Jun 23 2006, 01:33 AM:name=Colin1388)--][div class=\'quotetop\']QUOTE(Colin1388 @ Jun 23 2006, 01:33 AM) [snapback]387084[/snapback][/div][div class=\'quotemain\'][!--quotec--]poirot has solved all my problems =D I have gotten so many things done today, thanks to poirot. -worships- Thank you so much. I should have caught that error myself, but I am rather new...so my eyes are not trained enough yet to see those kinds of mistakes. I am sure I will be needing help again soon with something else, I will probably be having a lot more questions as I go through my current project.[/quote]FYI, if you keep your SQL statements in their own string variables, it will be much easier to echo them to the browser for debugging -- it would have been trivial to see that your string was closing too soon. Quote Link to comment https://forums.phpfreaks.com/topic/12351-phpmyadmin-messing-up-sql/#findComment-48720 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.