I cannont get connected to my database, is there something Im doing wrong? I am not using a local host but GoDaddy MyPHPAdmin. This is my first time coding in PHP and my first time setting up a Database. So I can be perfectly clear I have a registration form on one HTML page and the PHP code that pushes to the database on the next page (which I saved as a PHP). Also the passwords dont check to see if they match.
What I’m trying to do is have a registration form push to MySQL.
Here is my configuration:
DRIVER={MySQL ODBC 3.51 Driver}; SERVER=myelstonfamily.db.##########.hostedresource.com; PORT=3306; DATABASE=myelstonfamily; USER=myelstonfamily; PASSWORD=‘your password’; OPTION=0;
My PHP code
[php]
$host=“myelstonfamily.db.##########.hostedresource.com”;
$username=“myelstonfamily”;
$password=“password”;
$dbname=“myelstonfamily”;
$usertable=“Registration”;
mysql_connect("$host","$username", “$password”) or die (“”);
mysql_select_db($dbname) or die (“cannot select DB”);
$id=$_POST[‘id’];
$username=$_POST[‘username’];
$password=$_POST[‘password’];
$password=md5($pass);
$confirm_password=$_POST[‘confirm_password’];
if ($password == $confirm_pasword)
{
echo “Passwords Match”;
}
else
{
echo “Passwords Don’t Match”;
};
$Fname =$_POST[‘fname’];
$lname =$_POST[‘lname’];
$email =$_POST[‘email’];
$address =$_POST[‘address’];
$city =$_POST[‘city’];
$state =$_POST[‘state’];
$zip =$_POST[‘zip’];
$phone =$_POST[‘phone1’];
$phone =$_POST[‘phone2’];
$dob =$_POST[‘Birthday’];
$sex =$_POST[‘sex’];
$spouse =$_POST[‘spouse’];
$sdob =$_POST[‘sBirthday’];
$anniversary =$_POST[‘anniversary’];
$facebook =$_POST[‘facebook’];
$twitter =$_POST[‘twitter’];
$google =$_POST[‘googleplus’];
$linage =$_POST[‘linage’];
$parents =$_POST[‘parents’];
$grandparents =$_POST[‘grandparents’];
$result = mysql_query
(“SELECT * FROM Registration WHERE
username=’$username’”);
if($result == 1)
{
echo "Error User name already exists";
}
else
{
mysql_query("INSERT INTO Registration
( username, password,fname,lname,email,address,city,state,zip,phone1,phone2,birthday,sex,spouse,
sbirthday,anniversary,facebook,twitter,googleplus,linage,parents,grandparents)
VALUES ('$username','$password','$firstname','$lastname','$email','$address','$city','$state','$zip','$phone',
'$dob','$sex','$spous','$sdob,'$anniversary','$facebook','$twitter','$google','$linage','$parents',
'$grandparents')");
mysql_close($con);
?>
[/php]