I am receiving the following error:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '','ax@yahoo.com','132344545','y8khoob5')' at line 3
Here is my code:
<?php
if (!isset($_POST['submit'])) {
$link = mysql_connect("localhost","root","");
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("sh", $link);
function createRandomPassword() {
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$confirmation = createRandomPassword();
$datein = $_POST['start'];
$dateout = $_POST['end'];
$name = $_POST['name'];
$address = $_POST['address'];;
$email = $_POST['email'];
$contact = $_POST['contact'];
$status= 'Active';
$sql="INSERT INTO reservation (datein, dateout, name, address, email, contact, confirmation)
VALUES
('$datein','$dateout','$name',$address','$email','$contact','$confirmation')";
mysql_query("INSERT INTO resinvent (datein, dateout, confirmation, status) VALUES ('$datein','$dateout','$confirmation','$status')");
if (!mysql_query($sql,$link))
{
die('Error: ' . mysql_error());
}
}
mysql_close($link)
?>