I'm trying to write to a database with PHP and it's not working and I don't know why. Any help would be very much appreciated!
I've had a couple of people look at it with no avail so I'm hoping that a few extra eyes can help me find what is preventing it from working.
<html>
<head>
<title> Test </title>
</head>
<body>
<p>
<?php
$servername = 'localhost3306';
$username = 'root';
$password = 'root';
$dbname = 'database';
try {
$conn = new PDO('mysql:host=$servername;dbname=$dbname', $username, $password);
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);d
$sql = "INSERT INTO resgisterdusers(Password, FirstName, LastName, Hometown1, State1,
Zip1, Hometown2, State2, Zip2, PhoneNum, Email, Car, GraduationMonth,
GraduationYear, AccountActivated, DateActivated, ActivationCode, RouteID1, RouteID2);
VALUES ('Password1', 'joe', 'sixpack', 'city', 'MT', '59595', '', '', '', '55555555555',
'email@email.edu', '1', '05', '2012', '1', '2/28/2015', 'XXX', '', '2')";
exec($sql);
echo "New record created successfully";
}
catch(PDOException $ec
)
{
echo "Error!";
getmessage();
}
$conn = null;
?>
</p>
</body >
</html>