script not parsing correctly and outputing an error

I don’t think this is a database queston I think my script is faulty when I press the submit button on the page nothing happens no info is being sent to the DB however it does say that there are no inventory items in the DB like it should also there is an error on the top of the page(Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/content/85/9338985/html/store_admin/inventory_list.php on line 58) I have no idea what this means well anyway heres the rest of the script if you guys need anymore info let me know <?php
[php]session_start();
if (!isset($_SESSION[“manager”])){
header(“location:admin_login.php”);
exit();
}
//Be sure to check that this manager SESSION value is in fact in the database
$managerID = preg_replace(’#[^0-9]#i’,’’,$_SESSION[“id”]);//filter everything but numbers and letters
$manager = preg_replace(’#[^A-Za-z0-9]#i’,’’,$_SESSION[“manager”]);//filter everything but numbers and letters
$password = preg_replace(’#[^A-Za-z0-9]#i’,’’,$_SESSION[“password”]);//filter everything but numbers and letters
//run mySQL query to be sure that this person is an admin and that their password session var equals the database information
//connect to mySQL database
include"…/storescripts/connect_to_mysql.php";
$sql = mysql_query(“SELECT* FROM admin WHERE id=’$managerID’ AND username=’$manager’ AND password=’$password’LIMIT 1”);//query the person
//------Make sure person exist in database-------
$existCount = mysql_num_rows($sql); //count the row nums
if($existCount == 0)//evaluate the count
{ header(“location:index.php”);
exit();
}
?>

<?php //error_reporting error_reporting(E_ALL); ini_set('display_errors','1'); ?> <?php //parse the form and add inventory item to the system if (isset($_POST['item_name'])){ $item_number = mysql_real_escape_string($_POST['item_number']); $item_name = mysql_real_escape_string($_POST['item_name']); $auction_type = mysql_real_escape_string($_POST['auction_type']); $retail_price = mysql_real_escape_string($_POST['retail_price']); $initial_bid = mysql_real_escape_string($_POST['initial_bid']); $category = mysql_real_escape_string($_POST['category']); $subcategory = mysql_real_escape_string($_POST['subcategory']); $description = mysql_real_escape_string($_POST['description']); //see if that item name has an identical match to another item in the system $sql = mysql_query("SELECT id FROM Auctioned Items WHERE item_name='$item_name' LIMIT 1"); $itemMatch = mysql_num_rows($sql);//count the output amount if ($itemMatch >0){ echo'Sorry you tried to place a duplicate "Item Name" into the system, click here'; exit(); } //add this item into the database now $sql = mysql_query("INSERT INTO Auctioned Items(item_number, item_name, auction_type, retail_price, initial_bid, categoery, subcategory, description, date_added) VALUES('$item_number','$item_name','$auction_type','$retail_price','$initial_bid','$category','$subcategory','$description',now())")or die (mysql_error()); $pid = mysql_insert_id(); //place image in the folder $newname = "$pid.jpg"; move_uploaded_file ($_FILES['fileField']['tmp_name'],"../images/inventory_images/$newname"); } ?> <?php //this block grabs the whole list for viewing $product_list = ""; $sql = mysql_query("SELECT* FROM Auctioned Items ORDER BY date_added DESC"); $productCount = mysql_num_rows($sql); //count the output amount if ($productCount >0){ while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $item_name = $row["item_name"]; $date_added = strftime("%b %d %Y",strtotime($row["date_added"])); $product_list .= "$date_added-$id-$item_name       editdelete
"; } }else{ $product_list ="You have no products listed in your inventory yet"; } ?> Inventory List
<?php include_once"../header_template.php";?>


Inventory list

<?php echo $product_list;?>

↓Add New Auction Item Form↓

Item Number
Item Name
Auction Type Standard Premium Quick Multi Win
Retail Price $
Initial Bid $
Category Electronics Gift Cards Health & Beauty Home & Garden Jewelry & Fashion Sports & Recreation Video Games - Dvds and Blu ray
Subcategory Airline Department Store Gas Hotel-Lodging Restaurant
Item Description
Item Image
 


<?php include_once"../footer_template.php";?>
[/php] its been a week and ive looked at this script from every angle so maybe I need a second pair of eyes thanks so much for any help in advance

What’s line 58? It’s basically saying that using mysql_num_rows on something that isn’t a mysql result.

Also you should technically be putting the error reporting stuff at the very top.

Since PHP runs line by line, it won’t check anything above what you have for errors.

You can alter your code to be more error-checking format. Change your query like this:

$result = mysql_query($query) or die ("Error - Query failed: ".mysql_error());

Or, something similar. Then, if you have a bad query, the error message will show.
This will tell you if you are actually counting valid records or not…

the line that is failing is actually line 59, 58 was a typo on my part sorry this is what the line reads

$productCount = mysql_num_rows($sql); //count the output amount

your error is in your query:

[php]
$sql = mysql_query(“SELECT* FROM Auctioned Items ORDER BY date_added DESC”);
[/php]

Firstly, you need a space between SELECT and *
Secondly, table names cannot have a space.

Good catch! Yep, the space… But, if line 58 where the query is executed had some error checking in it as I mentioned, then the error would have been spelled out. Nothing beats good error checking!

Sponsor our Newsletter | Privacy Policy | Terms of Service