Hi guys, I've searched these forums and everywhere else... and I can't understand why this won't work when it works for other people... Here are my two error messages:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Assignment\inc\ManageStock.php on line 24
Notice: Undefined index: fileField in C:\xampp\htdocs\Assignment\inc\ManageStock.php on line 39
<?php
//parse form and add inventory to system
if(isset($_POST['productName'])){
$productName = mysql_real_escape_string($_POST['productName']);
$price = mysql_real_escape_string($_POST['price']);
$category = mysql_real_escape_string($_POST['category']);
$description = mysql_real_escape_string($_POST['description']);
//check if product name ios already in use
$sql = mysql_query("SELECT id FROM products WHERE productName = '$productName' LIMIT 1");
$productMatch = (mysql_num_rows($sql));//count the output amount <<-----LINE 24
if( $productMatch > 0) // if there is a match
{
echo "Sorry there is already a product with this name in our system!";
exit();
}
else
{
//if no match add into database
$sql = mysql_query("INSERT INTO products (productid, title, description, keywords, link, price, section)
VALUES ('', '$productName', '$description', '', '', '$price' '')");
$pid = mysql_insert_id();//sets the AI product ID to this variable
//placing image in folder
$newname = "$pid.jpg";
//should save image as the <products id>.jpg
move_uploaded_file($_FILES['fileField']['tmp_name'],'../Images/newproducts/$newname'); <<-----LINE 39
}
}
?>
any ideas? Cheers in advance