Jump to content
Larry Ullman's Book Forums

sanng

Members
  • Posts

    1
  • Joined

  • Last visited

sanng's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi I am new to PHP MySQL and recently bought the book for my friend's website. I think the book is great for building e-commerce website by using PHP. I changed the database as my friend is selling photos. However, it gave me the following error on cart.php An error occurred in script 'C:\Program Files\Abyss Web Server\htdocs\cart.php' on line 82: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array ( [0] => Array ( [function] => my_error_handler [args] => Array ( [0] => 2 [1] => mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given [2] => C:\Program Files\Abyss Web Server\htdocs\cart.php [3] => 82 [4] => Array ( [_GET] => Array ( [sku] => 2 ) [_POST] => Array ( ) [_COOKIE] => Array ( [phpSESSID] => e5d0kmc317b2qr560hmp2je820 [sESSION] => 0d36fdb1dea48580a333e4066147c5b9 ) [_FILES] => Array ( ) [live] => [contact_email] => [uid] => 0d36fdb1dea48580a333e4066147c5b9 [page_title] => Your Shopping Cart [dbc] => mysqli Object ( [affected_rows] => -1 [client_info] => mysqlnd 5.0.11-dev - 20120503 - $Id: 40933630edef551dfaca71298a83fad8d03d62d4 $ [client_version] => 50011 [connect_errno] => 0 [connect_error] => [errno] => 1054 [error] => Unknown column 'tblImage.ImageID' in 'field list' [error_list] => Array ( [0] => Array ( [errno] => 1054 [sqlstate] => 42S22 [error] => Unknown column 'tblImage.ImageID' in 'field list' ) ) [field_count] => 0 [host_info] => localhost via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.5.35 [server_version] => 50535 [stat] => Uptime: 90218 Threads: 2 Questions: 425 Slow queries: 0 Opens: 136 Flush tables: 1 Open tables: 4 Queries per second avg: 0.004 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 120 [warning_count] => 0 ) [pid] => [sp_type] => [r] => ) ) ) [1] => Array ( [file] => C:\Program Files\Abyss Web Server\htdocs\cart.php [line] => 82 [function] => mysqli_num_rows [args] => Array ( [0] => ) ) ) here is the script where the error occurred and based on cart.php // Get the cart contents: $r = mysqli_query($dbc, "CALL get_shopping_cart_contents('$uid')"); if (mysqli_num_rows($r) > 0) { // Products to show! include ('./views/cart.html'); } else { // Empty cart! include ('./views/emptycart.html'); } and here is the database table and procedure CREATE TABLE tblImage ( ImageID INT UNSIGNED NOT NULL AUTO_INCREMENT, CatID INT NOT NULL, ImageName VARCHAR (50) NOT NULL, ImageDes TEXT NOT NULL, ImagePic LONGBLOB NOT NULL, Price DECIMAL(5,2) NOT NULL, DateCreated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (ImageID), KEY (CatID) ); DELIMITER $$ CREATE PROCEDURE get_shopping_cart_contents (uid CHAR(32)) BEGIN SELECT CONCAT("O", tblImage.ImageID) AS sku, tblCart.Quantity, tblImageCategory.Category, tblImage.ImageName, tblImage.Price FROM tblCart AS c INNER JOIN tblImage AS I ON c.ImageID=I.ImageID INNER JOIN tblImageCategory AS icat ON icat.CatID= Image.CatID WHERE c.UserSessionID=uid; END$$ DELIMITER ; I did notice that it gave me the error [error] => Unknown column 'tblImage.ImageID' in 'field list' When created a procedure in MySQL 5.5, it didn't have any error. I have no idea why I was given the error when I run the php page. Please advice. Many thanks
×
×
  • Create New...