duffman014 Posted July 28, 2009 Share Posted July 28, 2009 I'm making just a basic registration script... i want it to compare the passwords to see if they are the same? when i run it. i get this error Parse error: syntax error, unexpected T_ELSE in D:\Hosting\4688039\html\test1\registration.php on line 21 i think i just wrote the if statment incorrectly.... if so could u please show me what i did wrong.. <?php $host="********"; // Host name $username="*****"; // Mysql username $password="****"; // Mysql password $db_name="*****"; // Database name $tbl_name="registration"; // Table name mysql_connect ("$host, $username, $password") or die ("cannot connect"); mysql_select_db ("$db_name")or die("cannot select DB"); $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $verifypassword=$_POST['verifypassword']; $email=$_POST['email']; IF ($mypassword == $verifypassword) { header("location: registration.php") else { echo "finaly got one " } } $sql="INSERT INTO $tbl_name(myusername, mypassword, email)VALUES('$myusername', '$password', '$email')"; $result=mysql_query($sql); ?> Quote Link to comment https://forums.phpfreaks.com/topic/167875-i-know-its-a-simple-mistake-were-is-it-_/ Share on other sites More sharing options...
lonewolf217 Posted July 28, 2009 Share Posted July 28, 2009 bad brackets and missing semi-colons <?php IF ($mypassword == $verifypassword) { header("location: registration.php"); } else { echo "finaly got one "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/167875-i-know-its-a-simple-mistake-were-is-it-_/#findComment-885421 Share on other sites More sharing options...
duffman014 Posted July 28, 2009 Author Share Posted July 28, 2009 bad brackets and missing semi-colons <?php IF ($mypassword == $verifypassword) { header("location: registration.php"); } else { echo "finaly got one "; } ?> still getting this error????? Parse error: syntax error, unexpected '}' in D:\Hosting\4688039\html\test1\registration.php on line 21 Quote Link to comment https://forums.phpfreaks.com/topic/167875-i-know-its-a-simple-mistake-were-is-it-_/#findComment-885422 Share on other sites More sharing options...
ldougherty Posted July 28, 2009 Share Posted July 28, 2009 Did you copy/paste his code? I ask because there is no line 21 and there is no included file in his code. <?php IF ($mypassword == $verifypassword) { header("location: registration.php"); } else { echo "finaly got one "; } ?> If you are still having the problem post up the full code for registration.php Quote Link to comment https://forums.phpfreaks.com/topic/167875-i-know-its-a-simple-mistake-were-is-it-_/#findComment-885426 Share on other sites More sharing options...
lonewolf217 Posted July 28, 2009 Share Posted July 28, 2009 i do not see any other syntax errors in the code you posted. post the full page or show us exactly which line is line 21 Quote Link to comment https://forums.phpfreaks.com/topic/167875-i-know-its-a-simple-mistake-were-is-it-_/#findComment-885428 Share on other sites More sharing options...
duffman014 Posted July 28, 2009 Author Share Posted July 28, 2009 i do not see any other syntax errors in the code you posted. post the full page or show us exactly which line is line 21 i fixed the if statment.. but now it just keeps saying that i cant connect to my database.... i dont understand one second it'll connect but why does it say it wont connect.... OMG so confused.. HELP <?php $host="********"; // Host name $username="*****"; // Mysql username $password="****"; // Mysql password $db_name="*****"; // Database name $tbl_name="registration"; // Table name mysql_connect ("$host, $username, $password") or die ("cannot connect"); mysql_select_db ("$db_name")or die("cannot select DB"); $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $verifypassword=$_POST['verifypassword']; $email=$_POST['email']; IF ($mypassword == $verifypassword) { header("location: registration.php"); } else { echo "finaly got one "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/167875-i-know-its-a-simple-mistake-were-is-it-_/#findComment-885430 Share on other sites More sharing options...
ldougherty Posted July 28, 2009 Share Posted July 28, 2009 Maybe there is an issue with the database server connection, ie the database server isn't reliable? Try changing // Table name mysql_connect ("$host, $username, $password") or die ("cannot connect"); to mysql_connect ("$host, $username, $password") or die(mysql_error()); This will give you the actual mySQL error. Quote Link to comment https://forums.phpfreaks.com/topic/167875-i-know-its-a-simple-mistake-were-is-it-_/#findComment-885435 Share on other sites More sharing options...
lonewolf217 Posted July 28, 2009 Share Posted July 28, 2009 the connect statement takes three parameters. With the way your quotes are set up, you have it sent as a single string parameter. You do not need quotes around variables. Also, it returns a parameter Use a color-coded editor so you can see silly mistakes like this. Ive corrected a couple things so far <?php $connection = mysql_connect($host, $username, $password) or die ("cannot connect"); mysql_select_db ($db_name,$connection)or die("cannot select DB"); Quote Link to comment https://forums.phpfreaks.com/topic/167875-i-know-its-a-simple-mistake-were-is-it-_/#findComment-885436 Share on other sites More sharing options...
duffman014 Posted July 29, 2009 Author Share Posted July 29, 2009 i got it to work.. thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/167875-i-know-its-a-simple-mistake-were-is-it-_/#findComment-885469 Share on other sites More sharing options...
lonewolf217 Posted July 29, 2009 Share Posted July 29, 2009 dont forget to mark the topic solved Quote Link to comment https://forums.phpfreaks.com/topic/167875-i-know-its-a-simple-mistake-were-is-it-_/#findComment-885472 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.