prcollin Posted May 27, 2008 Share Posted May 27, 2008 Can someone please help me with this. I thought I was doing well then I got a couple errors thrown at me Parse error: syntax error, unexpected T_STRING in /home/f8888r/public_html/p8888t/login.php on line 17 <?php $host="localhost"; $user="fin888r_pr8888"; $passwd="ni888888"; $database="fin888r_U88rs"; $con = mysql_connect("$host", "$user", "$passwd", "$database"); if (!$con) ( 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[co nfir_memail]','$_post[alt_email]','$_post[user_city]"; if (!mysql_query($sql,$con)) ( die('Error: ' . mysql_error()); ) echo "1 record added"; mysql_close($con) ?> is there something I am typing wrong? I also tried it without the ' ' in the insert into part Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/ Share on other sites More sharing options...
DarkWater Posted May 27, 2008 Share Posted May 27, 2008 Whenever using arrays in double quotes, they must be enclosed in { }. {$_POST['key']}. Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551064 Share on other sites More sharing options...
jonsjava Posted May 27, 2008 Share Posted May 27, 2008 <?php $host="localhost"; $user="fin888r_pr8888"; $passwd="ni888888"; $database="fin888r_U88rs"; $con = mysql_connect("$host", "$user", "$passwd", "$database"); if (!$con) { 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['co nfir_memail']}','{$_post['alt_email']}','{$_post['user_city']}"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551066 Share on other sites More sharing options...
prcollin Posted May 27, 2008 Author Share Posted May 27, 2008 <?php $host="localhost"; $user="fin888r_pr8888"; $passwd="ni888888"; $database="fin888r_U88rs"; $con = mysql_connect("$host", "$user", "$passwd", "$database"); if (!$con) { 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['co nfir_memail']}','{$_post['alt_email']}','{$_post['user_city']}"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> when I use this code it give 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 ''user_name', 'user_pass', 'full_name', 'user_email', 'confirm_email', 'alt_e' at line 1 Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551080 Share on other sites More sharing options...
jonsjava Posted May 27, 2008 Share Posted May 27, 2008 change the query to: 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']}" Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551085 Share on other sites More sharing options...
prcollin Posted May 27, 2008 Author Share Posted May 27, 2008 now i get Parse error: syntax error, unexpected T_STRING in /home/findzer/public_html/philsshit/login.php on line 21 sorry guys i dont have phpedit at work so i cant check all this on my own that is why I am asking for your help so much. THANKS ALOT AHEAD OF TIME!!! Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551102 Share on other sites More sharing options...
jonsjava Posted May 27, 2008 Share Posted May 27, 2008 I'm putting it through Zend Studion 5.5.1, and getting a clean bill of health. I'm guessing you aren't sending the full code. Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551108 Share on other sites More sharing options...
prcollin Posted May 27, 2008 Author Share Posted May 27, 2008 I'm putting it through Zend Studion 5.5.1, and getting a clean bill of health. I'm guessing you aren't sending the full code. this is my exact code <?php $host="lxxxxt"; $user="fixxxx_pxxxxxn"; $passwd="nxxxxx7"; $database="fixxxxr_Uxxxs"; $con = mysql_connect("$host", "$user", "$passwd", "$database"); if (!$con) { 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']}" Values ('{$_post['user_name']}','{$_post['user_pass']}','{$_post['full_name']}','{$_post['user_email']}','{$_post['co nfir_memail']}','{$_post['alt_email']}','{$_post['user_city']}"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> and the form that feeds this script the information is <html> <body> <form action="login.php" method="post"> Username: <input type="text" name="user_name"> Password: <input type="password" name="user_pass"> Full Name: <input type="text" name="full_name"> E-Mail : <input type="text" name="user_email"> Confirm E-mail: <input type="text" name="confirm_email"> Alt Email: <input type="text" name="alt_email"> City: <input type="text" name="user_city"> <input type="submit" /> Thats all of it Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551118 Share on other sites More sharing options...
jonsjava Posted May 27, 2008 Share Posted May 27, 2008 cleaned up your code: <?php $host="lxxxxt"; $user="fixxxx_pxxxxxn"; $passwd="nxxxxx7"; $database="fixxxxr_Uxxxs"; $con = mysql_connect("$host", "$user", "$passwd", "$database"); if (!$con) { 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']} 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) ?> Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551120 Share on other sites More sharing options...
prcollin Posted May 27, 2008 Author Share Posted May 27, 2008 now getting 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 i am using mysql version 4.1.22-standard Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551125 Share on other sites More sharing options...
jonsjava Posted May 27, 2008 Share Posted May 27, 2008 oops, my fault. should have error checked the sql too: <?php $host="lxxxxt"; $user="fixxxx_pxxxxxn"; $passwd="nxxxxx7"; $database="fixxxxr_Uxxxs"; $con = mysql_connect("$host", "$user", "$passwd", "$database"); if (!$con) { 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']} 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) ?> Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551129 Share on other sites More sharing options...
prcollin Posted May 28, 2008 Author Share Posted May 28, 2008 oops, my fault. should have error checked the sql too: <?php $host="lxxxxt"; $user="fixxxx_pxxxxxn"; $passwd="nxxxxx7"; $database="fixxxxr_Uxxxs"; $con = mysql_connect("$host", "$user", "$passwd", "$database"); if (!$con) { 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']} 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($c ?> 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 1 Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551319 Share on other sites More sharing options...
prcollin Posted May 28, 2008 Author Share Posted May 28, 2008 bump Link to comment https://forums.phpfreaks.com/topic/107506-parse-error-syntax-error-unexpected-t_string-in-home8888public_htmlphil/#findComment-551340 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.