I keep getting 'Can't Add Record'. What is wrong with it? I am inserting info into a php database..
<?
if ((!$userid) || (!$password)) {
header("location: http://www.retroarts.com/placeshare2/mylogin.php");
exit;
}
mysql_connect("localhost", "blah", "blah")
or die ("Unable to connect to database.");
mysql_select_db("blah")
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_num_rows($result) or die("That username and password are not in the database. You need to sign up
first.");
if ($num == 1) {
mysql_connect("localhost", "blah", "blah")
or die ("Unable to connect to database.");
mysql_select_db("retroart")
or die ("Unable to select database.");
session_start();
$date = getdate();
$datestamp = "$date[mon]/$date[mday]/$date[year]";
$sql = "insert into mynewads (userid, email, city, housing, phone, parking, smoking, pets, description, date) values (\"$userid\",\"$email\", \"$city\", \"$housing\", \"$phone\", \"$parking\",
\"$smoking\", \"$pets\", \"$description\", \"$datestamp\")";
$result = mysql_query($sql) or die ("Couldn't get results.");
if (!$sql_result) {
echo "Couldn't Add Record"; exit;
} else {
echo "Record Added! "; exit;
}
}
else if ($num == 0) {
echo "You are not authorized!";
exit;
}
?>