andrew6607 Posted December 17, 2007 Share Posted December 17, 2007 PHP Version: 5 Mysql Version 5 Error: INSERT 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 2 Here is the code im using. <?php $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $positon = $_POST['positon']; $exp = $_POST['exp']; $username = $_POST['username']; $password = $_POST['password']; $user = "root"; $pass = "##########"; $db = "#########"; $table = "#########"; $link = mysql_connect( "localhost", $user, $pass ); if ( ! $link ) { die( "Couldn't connect to the MySQL Server: ".mysql_error() ); } mysql_select_db( $db ) or die ( "Couldn't open $db: ".mysql_error() ); $query = "INSERT INTO staff( fname, lname, email, positon, exp, username, password ) values( $fname, $lname, $email, $positon, $exp, $username, $password )"; mysql_query( $query, $link ) or die ( "INSERT error: ".mysql_error() ); mysql_close( $link ); ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted December 17, 2007 Share Posted December 17, 2007 You need single quotes around all your variables. Quote Link to comment Share on other sites More sharing options...
andrew6607 Posted December 17, 2007 Author Share Posted December 17, 2007 Thanks ALOT! Quote Link to comment Share on other sites More sharing options...
rlindauer Posted December 17, 2007 Share Posted December 17, 2007 You also want to properly escape them as well. Look up mysql_real_escape_string() Quote Link to comment 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.