joinx Posted May 19, 2008 Share Posted May 19, 2008 here is my code but not working...always displaying 0 items in your cart. //Function to display num of items in cart function writeCart() { require_once('../Connections/JaceyConn.php'); $sid = session_id(); mysql_select_db($database_JaceyConn, $JaceyConn); $sqlnum = "SELECT * from cart where session_id = '$sid'"; $num = mysql_query($sqlnum, $JaceyConn) or die(mysql_error()); $totalRows_num = mysql_num_rows($num); if ($totalRows_num = 0) { return '<p>You have no items in your shopping cart</p>'; } else { // Parse the cart session variable return '<p align ="center">You have '.$totalRows_num.' item(s) in your shopping cart</p>'; } Link to comment https://forums.phpfreaks.com/topic/106332-display-items-in-cart/ Share on other sites More sharing options...
BlueSkyIS Posted May 19, 2008 Share Posted May 19, 2008 1. echo $sqlnum to see what it says 2. run the SQL in your database to make sure there is a record matching that SQL Link to comment https://forums.phpfreaks.com/topic/106332-display-items-in-cart/#findComment-544937 Share on other sites More sharing options...
joinx Posted May 20, 2008 Author Share Posted May 20, 2008 In some pages it is being displayed but some i get this error: Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\Apache2.2\htdocs\Jacey\order.php on line 75 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\Apache2.2\htdocs\Jacey\order.php on line 77 Link to comment https://forums.phpfreaks.com/topic/106332-display-items-in-cart/#findComment-545509 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.