Adding Data

wxdqz

New Member
Hi,

I'm hoping someone can help! I'm trying to add data to a MySQL dattabase from the PHP script below, but it does NOT go through. Two strange things are:
1. I get NO error message, so I have no idea what's wrong, and,
2. I am fully able to add a record via the MySQL monitor using the commands.

I am SUPPOSED to get a page that says "New Customer Entry Results. 1 customer inserted into database", but the page ONLY says "New Customer Entry Results".

Can anyone tell me if there is an error in the script below? Any help would be greatly appreciated!

Thank You!



<head>
<title>Entry Results</title>
</head>
<body>
<h1>New Customer Entry Results</h1>
<?
if (!$name || !$address || !$city || !$state)
{
echo "You have not entered all the required details.<br>"
."Please go back and try again.";
exit;
}

$name = addslashes($name);
$address = addslashes($address);
$city = addslashes($city);
$state = addslashes($state);

@ $db = MYSQL_CONNECT('localhost','xxxx','xxxx');

if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}

@mysql_select_db("clientsdb");
$query = "insert into customers values
('.$name.', '.$address.', '.$city.', '.$state.')";
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows()." customer inserted into database.";
?>

</body>
 
Back
Top