hello..
i was learning through julie c. melony's php essentials how to add a record to the database.. actually it is a chapter teaching us how to design a complete book store.
i am having problems adding a record to the table..
here is some info:
db name: shin_omair
table name: MASTER_PRODUCTS
and here is the code:
can you tell me what is the problem ??PHP Code:<?php
if (!isset($PHP_AUTH_USER)) {
header('WWW-Authenticate: Basic realm="XYZ COMPANY Admin Area"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
} else if (isset($PHP_AUTH_USER)) {
if (($PHP_AUTH_USER != "admin") || ($PHP_AUTH_PW != "xxxxxx")) {
header('WWW-Authenticate: Basic Realm="XYZ Company Admin Area"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Reuired.';
exit;
} else {
if ((!$isbn) || (!$title) || (!$price)) {
header("Location: [url]http://www.dayzero.org/omair/admin_addrecord1.php[/url]");
exit;
}
//prepare SQL Statement
$sql = "INSERT INTO MASTER_PRODUCTS VALUES (\"$isbn\", \"$title\", \"author\", \"$publisher\", \"$category\", \"$type\", \"$info_blurb\", \"$page_num\", \"$price\")";
// create connection
$connection = mysql_connect("localhost","login","password") or die("Could'n connect to the database.");
//select database
$db = mysql_select_db("shin_omair",$connection) or die ("Could'nt select the database.);
// execute SQL QUERY AND GET RESULTS
$sql_result = mysql_query($sql,$connection) or die
("Could'nt execute query");
if (!$sql_result) {
echo "<p>Could'nt add record!</p>";
} else {
echo "
<html>
<head>
<title>Add New Product</title>
</head>
<body bgcolor=\"#FFFFFF\" text=\"#000000\">
<p> </p>
<p><h1>Product added to the XYZ Company Catalog:</h1></p>
<p> </p>
<p>ISBN: $isbn </p>
<p>Title of the book: $title</p>
<p>Author's Name: $author</p>
<p>Publisher: $publisher</p>
<p>Category: $category</p>
<p>Type: $type</p>
<p>Paragraph about the book: $info_blurb</p>
<p>Number of Pages: $page_num</p>
<p>Retail Price: $price</p>
<p align=\"center\">< a href=\"admin_menu.php\">Return to Menu</a></p>
<p> </p>
</body>
</html>
";
}
}
}
?>



/h1></p>

Bookmarks