I am using the code below to add information to a mysql database. I always get the error 'can't add record'.. here is the code below:
<?
if ((!$userid) || (!$password)) {
header("location: http://www.retroarts.com/placeshare2/mylogin.php");
exit;
}
mysql_connect("localhost", "mydb", "password")
or die ("Unable to connect to database.");
mysql_select_db("mydb")
or die ("Unable to select database.");
$sql = "select id from users where userid='$userid' and password='$password'";
$result = mysql_query($sql) or die ("Couldn't get results.");
$num = mysql_numrows($result) or die("That username and password are not in the database. You need to sign up
first.");
if ($num == 1) {
setcookie("site_user", $userid, time() + 31536000, "/");
setcookie("site_pass", $password, time() + 31536000, "/");
setcookie("site_id", $id, time(), +31536000, "/");
session_start();
$date = "current_date";
$sql = "insert into mynewads values (\"$userid\",\"$email\", \"$city\", \"$housing\", \"$phone\", \"$parking\",
\"$smoking\", \"$pets\", \"$description\", \"$date\")";
if (!$sql_result) {
echo "Couldn't Add Record";
} else {
echo "Record Added! ";
}
}
else if ($num == 0) {
echo "You are not authorized!";
exit;
}
?>