I am using this script to add a record. I keep running into the 'can't add record' error.. what should I change?
<?
if ((!$userid) || (!$password)) {
header("location: http://www.retroarts.com/placeshare2/mylogin.php");
exit;
}
mysql_connect("loalhost", "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("blah")
or die ("Unable to select database.");
session_start();
$date = "current_date";
$sql = "insert into mynewads values (\"$userid\",\"$email\", \"$city\", \"$housing\", \"$phone\", \"$parking\",
\"$smoking\", \"$pets\", \"$description\", \"$date\")";
$sql_result = mysql_query($sql);
if (!$sql_result) {
echo "Couldn't Add Record"; exit;
} else {
echo "Record Added! "; exit;
}
}
else if ($num == 0) {
echo "You are not authorized!";
exit;
}
?>