<?php
// This page contains the connection routine for the
// database as well as getting the ID of the cart, etc
$dbServer = "localhost";
$dbUser = "furnitur_herman";
$dbPass = "usmcusmc";
$dbName = "furnitur_furnitur";
function ConnectToDb($dbServer, $dbUser, $dbPass, $dbName)
{
// Connect to the database and return
// true/false depending on whether or
// not a connection could be made.
$s = @mysql_connect($dbServer, $dbUser, $dbPass);
$d = @mysql_select_db($s,$dbName);
if(!$s || !$d)
return false;
else
return true;
}
function GetCartId()
{
// This function will generate an encrypted string and
// will set it as a cookie using set_cookie. This will
// also be used as the cookieId field in the cart table
if(isset($COOKIE["cartId"]))
{
return $COOKIE["cartId"];
}
else
{
// There is no cookie set. We will set the cookie
// and return the value of the users session ID
session_start();
setcookie("cartId", session_id(), time() + ((3600 24) 30));
return session_id();
}
}
?>
this is the db.php
and this is the products.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
include("db.php");
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$result = mysql_query("select * FROM products ORDER BY itemName")or die ('Error: '.mysql_error ());
?>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td width="30%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["itemName"]; ?>
</font>
</td>
<td width="10%" height="25">
<font face="verdana" size="1" color="black">
R
<?php echo $row["itemPrice"]; ?>
</font>
</td>
<td width="50%" height="25">
<font face="verdana" size="1" color="black">
<a href="cart.php?action=add_item&id=
<?php echo $row["itemId"]; ?>
&qty=1">Add Item</a>
</font>
</td>
</tr>
<?php } ?>
<tr>
<td width="100%" colspan="4">
<hr size="1"color="red" NOSHADE>
</td>
</tr>
<tr>
<td width="100%" colspan="4">
<font face="verdana" size="1" color="black">
<a href="cart.php">Your Shopping Cart</a>
</font>
</td>
</tr>
</table>
</body>
</html>
Is the problem with the db or products page?