cant find how to fix the error
Posted: Thu Jun 25, 2009 6:49 am
when i open the page it works fine but when i try and get into a cat?=1 or2,3,4,5 it gives me this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\CHOPSHOP\customer.php on line 90 really been stuck on this for a couple of days nows ............will be reallly grateful if u can help me out.....thanking u in advance ...
Code: Select all
<?php
//this is connection from php
$connection = @mysql_connect("localhost", "ashtnfer", "ashtnfer");
// this is to capture any errors from the database
if (!$connection)
{
mysql_error();
}
if (!mysql_select_db('shopping'))
{
mysql_error();
}
$product_query = "select id,title,body,price,image from products";
if(isset($_GET['cat']))
{
$product_query .= sprintf("where category_id = '%s'", mysql_real_escape_string($_GET['cat']));
}
$product_result = mysql_query($product_query);
$category_query = "select id,name from category";
$category_result = mysql_query($category_query);
if(!$category_result)
{
echo mysql_error();
}
?>
<!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>Ultra FAshion</title>
<link href="application.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<!-- start wrapper -->
<div id="wrapper">
<!-- start header -->
<div id="header">
<a href="http://localhost/CHOPSHOP/customer.php/"><img src="images/ultra_logo.jpg" alt="Ultra Fashion" width="395" height="89" /></div>
<!-- end header -->
<!-- start sidebar -->
<div class="clear-fix" id="side-bar">
<h2> </h2>
<h2> </h2>
<h2>Categories</h2>
<ul>
<?php while ($category_row = mysql_fetch_array($category_result))
{
?>
<li><a href="customer.php?cat=<?php echo $category_row['id']; ?>"><?php echo $category_row['name']; ?></a></li>
<?php
}
?>
<hr />
</ul>
</div>
<div align="left">
<!-- end sidebar -->
<!-- main -->
</div>
<div id="main">
<p> </p>
<p> </p>
<p>
<?php
while ($row = mysql_fetch_array($product_result))
{
?>
</p>
<div class="clear-fix" id="intro">
<p><img src="images/<?php
echo ($row['image'] );
?>" alt="<?php
print ($row['title'] . '<br/>');
?>" width="173" height="146" class="pic" /></p>
<p><span class="title">Name: <?php
print ($row['title'] . '<br/>');
?>
</span>
<span class="email">Price: <b>
<?php
print ($row['price'] . '<br/>');
?>
</a></b></span>
<span class="txt">
Description:
<?php
print ($row['body'] . '<br/>');
?>
</span> </p>
<div class="clear-fix"></div>
</div>
<?php
}
?>
</div>
<!-- end main -->
<!-- start footer -->
<div id="footer">
Copyright 2009 Ultra Fashion all rights reserved.
</div>
<!-- end footer -->
</div>
<!-- end wrapper -->
</body>
</html>