prcollin Posted May 28, 2008 Share Posted May 28, 2008 <?php $host="localhost"; $user="fixxxxxr_xxxxxxn"; $passwd="nxxxxxx"; $database="fxxxxxx_xxxxx"; $con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not connect:".mysql_error()); mysql_select_db("findzer_Users", $con); $sql= "insert into newuser ("user_name", "user_pass", "full_name", "user_email", "confirm_email", "alt_email", "user_city") Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']} Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}"; if (!mysql_query($sql,$con)) { die("Error: ". mysql_error()); } echo "1 record added"; mysql_close($con) ?> Getting error Parse error: syntax error, unexpected T_STRING in /home/findzer/public_html/philsshit/login.php on line 12 I had all the values in the "insert into" part in single quotes and got error 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 ''user_name', 'user_pass', 'full_name', 'user_email', 'confirm_email', 'alt_email' at line 1 so what is my problem? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 28, 2008 Share Posted May 28, 2008 So clearly you forgot to change a ". >_> Quote Link to comment Share on other sites More sharing options...
prcollin Posted May 28, 2008 Author Share Posted May 28, 2008 So clearly you forgot to change a ". >_> this is what i have now for code and gettingthe error <?php $host="localhost"; $user="fxxxxxxr_pxxxxx"; $passwd="nxxxxxxxx"; $database="fixxxxr_Uxxxx"; $con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not connect:".mysql_error()); mysql_select_db("findzer_Users", $con); $sql= "insert into newuser ('user_name', 'user_pass', 'full_name', 'user_email', 'confirm_email', 'alt_email', 'user_city') Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']} Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}"; if (!mysql_query($sql,$con)) { die("Error: ". mysql_error()); } echo "1 record added"; mysql_close($con) ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted May 28, 2008 Share Posted May 28, 2008 Remove all those double quotes and now single quotes around the INTO fields. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 fixed version (syntatically speaking...) <?php $host="localhost"; $user="fixxxxxr_xxxxxxn"; $passwd="nxxxxxx"; $database="fxxxxxx_xxxxx"; $con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not connect:".mysql_error()); mysql_select_db("findzer_Users", $con); $sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, `confirm_email`, `alt_email`, `user_city`) Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']} Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}"; if (!mysql_query($sql,$con)) { die("Error: ". mysql_error()); } echo "1 record added"; mysql_close($con) ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted May 28, 2008 Share Posted May 28, 2008 Now you have Values twice. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 28, 2008 Share Posted May 28, 2008 Still not correct. <?php $host="localhost"; $user="fixxxxxr_xxxxxxn"; $passwd="nxxxxxx"; $database="fxxxxxx_xxxxx"; $con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not connect:".mysql_error()); mysql_select_db("findzer_Users", $con); $sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, `confirm_email`, `alt_email`, `user_city`) Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}'"; if (!mysql_query($sql,$con)) { die("Error: ". mysql_error()); } echo "1 record added"; mysql_close($con) ?> And you used VALUES twice. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 first half of an insert, you don't use any quotes, or if you do, you use "con ascento" (which is the key with the tilda on it, above the tab key). I didn't change your code, except to remove double quotes. YOU used value twice. Fixed code: <?php $host="localhost"; $user="fixxxxxr_xxxxxxn"; $passwd="nxxxxxx"; $database="fxxxxxx_xxxxx"; $con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not connect:".mysql_error()); mysql_select_db("findzer_Users", $con); $sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, `confirm_email`, `alt_email`, `user_city`) Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}';"; if (!mysql_query($sql,$con)) { die("Error: ". mysql_error()); } echo "1 record added"; mysql_close($con) ?> Quote Link to comment Share on other sites More sharing options...
trq Posted May 28, 2008 Share Posted May 28, 2008 Also, does the $_post array exist? Its not a built in. Try $_POST. And seriously, inserting posted vars directly into your query like that is begging for trouble. You need to escape data properly before letting it into your queries. Quote Link to comment Share on other sites More sharing options...
prcollin Posted May 28, 2008 Author Share Posted May 28, 2008 fixed version (syntatically speaking...) <?php $host="localhost"; $user="fixxxxxr_xxxxxxn"; $passwd="nxxxxxx"; $database="fxxxxxx_xxxxx"; $con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not connect:".mysql_error()); mysql_select_db("findzer_Users", $con); $sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, `confirm_email`, `alt_email`, `user_city`) Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']} Values('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['use r_email']}','{$_post['confir_memail']}','{$_post['alt_email']}','{$_post['user_city']}"; if (!mysql_query($sql,$con)) { die("Error: ". mysql_error()); } echo "1 record added"; mysql_close($con) ?> Now i get 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 5 Quote Link to comment Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 not fixed: here's the fixed: <?php $host="localhost"; $user="fixxxxxr_xxxxxxn"; $passwd="nxxxxxx"; $database="fxxxxxx_xxxxx"; $con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not connect:".mysql_error()); mysql_select_db("findzer_Users", $con); $sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, `confirm_email`, `alt_email`, `user_city`) Values('{$_POST['user_name']}','{$_POST['user_pass']}','{$_POST['full_name']}','{$_POST['user_email']}','{$_POST['confir_memail']}','{$_POST['alt_email']}','{$_POST['user_city']}';"; if (!mysql_query($sql,$con)) { die("Error: ". mysql_error()); } echo "1 record added"; mysql_close($con) ?> Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 28, 2008 Share Posted May 28, 2008 Stop using Values twice and use my code. Try it at least. Quote Link to comment Share on other sites More sharing options...
revraz Posted May 28, 2008 Share Posted May 28, 2008 Or at least read what has been said 3 times now. Quote Link to comment Share on other sites More sharing options...
prcollin Posted May 28, 2008 Author Share Posted May 28, 2008 Stop using Values twice and use my code. Try it at least. Its not used twice inthe ocde i dont know why it keeps showing up twice on here. with your code i get 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 3 Quote Link to comment Share on other sites More sharing options...
prcollin Posted May 28, 2008 Author Share Posted May 28, 2008 Or at least read what has been said 3 times now. Ive tried all their codes i dont know what it keeps givign the " error I tried switching out for ' and tried everything else i have found on the forums that I have read so far to try to elim this error. LOL sorry i just do know the error correcting yet very well. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 my last version is the fixed version. Quote Link to comment Share on other sites More sharing options...
prcollin Posted May 28, 2008 Author Share Posted May 28, 2008 jonsjava your code gives me 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 5 Quote Link to comment Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 found the problem <?php $host="localhost"; $user="fixxxxxr_xxxxxxn"; $passwd="nxxxxxx"; $database="fxxxxxx_xxxxx"; $con = mysql_connect("$host", "$user", "$passwd", "$database") or die("Could not connect:".mysql_error()); mysql_select_db("findzer_Users", $con); $sql= "insert into newuser (`user_name`, `user_pass`, `full_name`, `user_email`, `confirm_email`, `alt_email`, `user_city`) Values('{$_POST['user_name']}','{$_POST['user_pass']}','{$_POST['full_name']}','{$_POST['user_email']}','{$_POST['confirm_email']}','{$_POST['alt_email']}','{$_POST['user_city']}');"; if (!mysql_query($sql,$con)) { die("Error: ". mysql_error()); } echo "1 record added"; mysql_close($con) ?> Quote Link to comment Share on other sites More sharing options...
prcollin Posted May 28, 2008 Author Share Posted May 28, 2008 Ok that worked!!! Now another problem. When the user enters values and clicks submit and I go to phpmyadmin it shows entries added (Primary key value increases ) but no values are in the corresponding columns any idea? probably just a clerical error? Quote Link to comment Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 clerical, most likely due to mis-named POST values. Quote Link to comment Share on other sites More sharing options...
prcollin Posted May 28, 2008 Author Share Posted May 28, 2008 clerical, most likely due to mis-named POST values. THANKS AND TOPIC SOLVED 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.