duffman014 Posted July 27, 2009 Share Posted July 27, 2009 still very new... trying to figure all this out... i get an error on line 28 i dont know why... take a look tell me what i did do right thx... if someone has aim or something and wanna help me for quick questions i'd be very gratefull ... <?php $host="LOCAL"; // Host name $username="bludgeonaccount"; // Mysql username $password="RANDOM"; // Mysql password $db_name="bludgeonaccount"; // Database name $tbl_name="members"; // Table name mysql_connect ("$host, $username, $password") or die ("cannot connect"); mysql_select_db ("$db_name")or die("cannot select DB"); $name=$_POST['username']; $pass=$_POST['password']; $pass_conf=$_POST['pass_conf']; $email=$_POST['email']; $ip=$_POST['ip']; if($name == false || $pass == false || $email ==false) { echo "Please fill in all the required fields."; }; if($pass != $pass_conf){ echo "Passwords do not match."; } else { mysql_connect ("$host, $username, $password") or die ("cannot connect"); mysql_select_db ("$db_name")or die("cannot select DB"); $sql="INSERT INTO $tbl_name(username, password, email)VALUES('$username','$password','$email')"; $result=mysql_query($sql)or die("MySQL ERROR: ".mysql_error()); echo "thank you for your registration to cndalliance.com"; }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/ Share on other sites More sharing options...
mmarif4u Posted July 27, 2009 Share Posted July 27, 2009 <?php $host="LOCAL"; // Host name $username="bludgeonaccount"; // Mysql username $password="RANDOM"; // Mysql password $db_name="bludgeonaccount"; // Database name $tbl_name="members"; // Table name mysql_connect ("$host, $username, $password") or die ("cannot connect"); mysql_select_db ("$db_name")or die("cannot select DB"); $name=$_POST['username']; $pass=$_POST['password']; $pass_conf=$_POST['pass_conf']; $email=$_POST['email']; $ip=$_POST['ip']; if($name == false || $pass == false || $email ==false) { echo "Please fill in all the required fields."; } if($pass != $pass_conf){ echo "Passwords do not match."; } else { $sql="INSERT INTO $tbl_name(username, password, email)VALUES('$username','$password','$email')"; $result=mysql_query($sql)or die("MySQL ERROR: ".mysql_error()); echo "thank you for your registration to cndalliance.com"; } ?> 1- There should no semicolon after if statement. 2- No need to include twice db code. Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883677 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 Semicolons after if should not produce any errors though. What is the error message? Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883678 Share on other sites More sharing options...
duffman014 Posted July 27, 2009 Author Share Posted July 27, 2009 Semicolons after if should not produce any errors though. What is the error message? well i would have an answer for you but now all of a sudden i cant connect to my database... i have no idea what i messed up now.. i'll have my code up and error messages shorts... Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883681 Share on other sites More sharing options...
mmarif4u Posted July 27, 2009 Share Posted July 27, 2009 Post your updated code. Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883682 Share on other sites More sharing options...
duffman014 Posted July 27, 2009 Author Share Posted July 27, 2009 Post your updated code. Still dont know whats wrong... i keep getting the error below... if any one has a good tutorial i could go look at that will show me how to make a safe login registration form/database WOULD BE GREATLY APPRECIATED Parse error: syntax error, unexpected ')' in D:\Hosting\4688039\html\login2\do_reg.php on line 28 <?php $host="bludgeonaccount.db.4688039.hostedresource.com"; // Host name $username="bludgeonaccount"; // Mysql username $password="Greater99"; // Mysql password $db_name="bludgeonaccount"; // Database name $tbl_name="user"; // Table name mysql_connect ("$host, $username, $password") or die ("cannot connect"); mysql_select_db ("$db_name")or die("cannot select DB"); $name=$_POST['username']; $pass=$_POST['password']; $pass_conf=$_POST['pass_conf']; $email=$_POST['email']; $ip=$_POST['ip']; if($name == false || $pass == false || $email ==false) { echo "Please fill in all the required fields."; }; if($pass != $pass_conf){ echo "Passwords do not match."; } else { mysql_connect ("$host, $username, $password") or die ("cannot connect"); mysql_select_db ("$db_name")or die("cannot select DB"); $sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip"); $result = mysql_query($sql); echo "thank you for your registration to cndalliance.com"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883703 Share on other sites More sharing options...
Philip Posted July 27, 2009 Share Posted July 27, 2009 $sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip"); Should be $sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip)"; Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883706 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 There are plenty of log in tutorials available. Try Google. Try looking at a few to understand the logic behind them. Not all are good for every situation and you may wish to adjust them slightly. Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883707 Share on other sites More sharing options...
duffman014 Posted July 27, 2009 Author Share Posted July 27, 2009 $sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip"); Should be $sql = "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip)"; ok i fixed that now it looks as if i screwd up somewere on the database side wtih sql... does it look like i made an error up there... i double checked all of it it say its correct.. but i have no idea what to do now... Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883709 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 ALWAYS post the error message. That way it will make it much easier to spot the problem. Simply saying "what's wrong with my code?" is like asking someone to help you look for your keys in your entire home town when you know they're in your house... Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883713 Share on other sites More sharing options...
Philip Posted July 27, 2009 Share Posted July 27, 2009 You're going to want to put single quotes around the values ... VALUES ('$name', '$pass', '$email', '$ip') Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883714 Share on other sites More sharing options...
mmarif4u Posted July 27, 2009 Share Posted July 27, 2009 Answer to PM: Are you using free web hosting? Try it in your local PC. Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883720 Share on other sites More sharing options...
duffman014 Posted July 27, 2009 Author Share Posted July 27, 2009 Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'bludgeonaccount.db.4688039.hostedresource.com, bludgeonaccount, Greater99' (11004) in D:\Hosting\4688039\html\login2\do_reg.php on line 9 cannot connect thats the error i keep recieving <?php $host="bludgeonaccount.db.4688039.hostedresource.com"; // Host name $username="bludgeonaccount"; // Mysql username $password="Greater99"; // Mysql password $db_name="bludgeonaccount"; // Database name $tbl_name="user"; // Table name mysql_connect ("$host, $username, $password") or die ("cannot connect"); mysql_select_db ("$db_name")or die("cannot select DB"); $name=$_POST['username']; $pass=$_POST['password']; $pass_conf=$_POST['pass_conf']; $email=$_POST['email']; $ip=$_POST['ip']; if($name == false || $pass == false || $email ==false) { echo "Please fill in all the required fields."; }; if($pass != $pass_conf){ echo "Passwords do not match."; } else { mysql_connect ("$host, $username, $password") or die ("cannot connect"); mysql_select_db ("$db_name")or die("cannot select DB"); $sql = "INSERT INTO user (username,password,email,ip) VALUES ('$name','$pass','$email','$ip')"; $result = mysql_query($sql); echo "thank you for your registration to cndalliance.com"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883722 Share on other sites More sharing options...
duffman014 Posted July 27, 2009 Author Share Posted July 27, 2009 Answer to PM: Are you using free web hosting? Try it in your local PC. Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'bludgeonaccount.db.4688039.hostedresource.com, bludgeonaccount, Greater99' (11004) in C:\xampp\htdocs\login2\do_reg.php on line 9 cannot connect i did that on xampp same error... sorry guys i'm terrible at this lol... and im using go daddy.com as a hosting service... www.cndalliance.com/login2/registration.php Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883723 Share on other sites More sharing options...
mmarif4u Posted July 27, 2009 Share Posted July 27, 2009 You have to change this on local PC: Also input correct username, pass, db name in local Pc and try. $host="localhost"; // Host name $username="bludgeonaccount"; // Mysql username $password="Greater99"; // Mysql password $db_name="bludgeonaccount"; // Database name $tbl_name="user"; // Table name Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883725 Share on other sites More sharing options...
duffman014 Posted July 27, 2009 Author Share Posted July 27, 2009 ok i got more of it to work YAY... there is hope after all ... ok enough of the good news... bak to my horrific problems lol... YOU GUYS ARE AWESOME BY THE WAY... alright next up to bat.. its automatically echoing my check to see if all lines are filled. 2. it wont check my password check to see if they are the same... and i have an ip check on there and it wont show the ip for me... is my whole statment wrong and if so how should i rewrite it... one last question how do u chek and make sure that there is an at symbol in your email line // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get values from form $uname=$_POST['uname']; $pw=$_POST['pw']; $vpw=$_POST['vpw']; $email=$_POST['email']; $ip=$_POST['ip']; // Insert data into mysql $sql="INSERT INTO $tbl_name(uname, pw, email, ip)VALUES('$uname', '$pw', '$email', 'ip')"; $result=mysql_query($sql); if($name == false || $pass == false || $email == false) { echo "Please fill in all the required fields."; }; if($pass != $pass_conf){ echo "Passwords do not match."; } else { echo "thank you for your registration to cndalliance.com"; mysql_close(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883750 Share on other sites More sharing options...
cs.punk Posted July 27, 2009 Share Posted July 27, 2009 I would change your password btw... Try not to post it next time lol... You never know which evil eyes are looking... Im evil too lol. Quote Link to comment https://forums.phpfreaks.com/topic/167571-can-someone-check-this-code-tell-me-what-i-missed-plz/#findComment-883772 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.