Akenatehm Posted November 28, 2008 Share Posted November 28, 2008 Hey Guys, the following script is showing up with this error: Parse error: syntax error, unexpected ',' in /home/kaurlcom/public_html/relayadmin/add_user/add_user_test.php on line 41 in this script: <?PHP include "connect.php"; // Checks the database for a user with a particular user name $check = mysql_query("select ID from users where username='$username' limit 1;"); // get a row count of the number of rows found if(mysql_num_rows($check) == 1) { echo "Username Already In Use."; } else { if(isset($_POST['submit'])) { $username=$_POST['username']; $password=$_POST['password']; $email=$_POST['email']; if(strlen($username)<1) { print "You did not enter a username."; } else if(strlen($password)<1) { print "You did not enter a password."; } else { $insert = "INSERT INTO `users` (username,password,email)", mysql_real_escape_string($username), mysql_real_escape_string($password), mysql_real_escape_string($email)); mysql_query($insert) or die("Could not insert comment" . mysql_error()); echo "User Added. <A href''<a href=\"home.html\">Click here</a> To Go Home."; } } ?> } ?> Link to comment https://forums.phpfreaks.com/topic/134693-solved-script-parsing-error/ Share on other sites More sharing options...
DeanWhitehouse Posted November 28, 2008 Share Posted November 28, 2008 <?PHP include "connect.php"; // Checks the database for a user with a particular user name $check = mysql_query("select ID from users where username='$username' limit 1;"); // get a row count of the number of rows found if(mysql_num_rows($check) == 1) { echo "Username Already In Use."; } else { if(isset($_POST['submit'])) { $username=$_POST['username']; $password=$_POST['password']; $email=$_POST['email']; if(strlen($username)<1) { print "You did not enter a username."; } else if(strlen($password)<1) { print "You did not enter a password."; } else { $insert = "INSERT INTO `users` (username,password,email) VALUES ('".mysql_real_escape_string($username)."','".mysql_real_escape_string($password)."','".mysql_real_escape_string($email)."'"); mysql_query($insert) or die("Could not insert comment" . mysql_error()); echo "User Added. <a href=\"home.html\">Click here</a> To Go Home."; } } ?> } ?> Link to comment https://forums.phpfreaks.com/topic/134693-solved-script-parsing-error/#findComment-701368 Share on other sites More sharing options...
Akenatehm Posted November 28, 2008 Author Share Posted November 28, 2008 Can you explain where the errors were please, so I can learn from my mistakes. Link to comment https://forums.phpfreaks.com/topic/134693-solved-script-parsing-error/#findComment-701371 Share on other sites More sharing options...
DeanWhitehouse Posted November 29, 2008 Share Posted November 29, 2008 $insert = "INSERT INTO `users` (username,password,email)", mysql_real_escape_string($username), mysql_real_escape_string($password), mysql_real_escape_string($email)); You end the sql statement with the )", And that also caused a parse error because you are trying to connect strings using commas . So fixed that, now the second error, a HTML one echo "User Added. <A href''<a href=\"home.html\">Click here</a> To Go Home."; You have set the href attribute of the anchor as another anchor. Edit: 3rd error i didn't see or fix ?> } ?> You end PHP so the last closing tag is printed as HTML not run as php. Link to comment https://forums.phpfreaks.com/topic/134693-solved-script-parsing-error/#findComment-701374 Share on other sites More sharing options...
Akenatehm Posted November 29, 2008 Author Share Posted November 29, 2008 Ahh, I see now, sweet. Thanks alot mate. Link to comment https://forums.phpfreaks.com/topic/134693-solved-script-parsing-error/#findComment-701380 Share on other sites More sharing options...
DeanWhitehouse Posted November 29, 2008 Share Posted November 29, 2008 NP, solved button bottom left hand side. Link to comment https://forums.phpfreaks.com/topic/134693-solved-script-parsing-error/#findComment-701382 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.