Devilboy97
-
Posts
3 -
Joined
-
Last visited
Posts posted by Devilboy97
-
-
Hi,
I have a problem with the example two:Coffee.
I have downloaded the script from Larry's site and installed in my server: http://www.gbilling.com.
When i click the link cart or wishlist,an error appear:
An error occurred in script'/home/gbilling/public_html/gmuar02/wishlist.php' on line 80:mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given......
The Cart .php is like this:
<?php
// This file manages the shopping cart.
// This script is begun in Chapter 9.
// Require the configuration before any PHP code:
require ('./includes/config.inc.php');
// Check for, or create, a user session:
if (isset($_COOKIE['SESSION'])) {
$uid = $_COOKIE['SESSION'];
} else {
$uid = md5(uniqid('biped',true));
}
// Send the cookie:
setcookie('SESSION', $uid, time()+(60*60*24*30));
// Include the header file:
$page_title = 'Coffee - Your Shopping Cart';
include ('./includes/header.html');
// Require the database connection:
require (MYSQL);
// Need the utility functions:
include ('./includes/product_functions.inc.php');
// If there's a SKU value in the URL, break it down into its parts:
if (isset($_GET['sku'])) {
list($sp_type, $pid) = parse_sku($_GET['sku']);
}
if (isset ($pid, $sp_type, $_GET['action']) && ($_GET['action'] == 'add') ) { // Add a new product to the cart:
$r = mysqli_query($dbc, "CALL add_to_cart('$uid', '$sp_type', $pid, 1)");
// For debugging purposes:
//if (!$r) echo mysqli_error($dbc);
} elseif (isset ($sp_type, $pid, $_GET['action']) && ($_GET['action'] == 'remove') ) { // Remove it from the cart.
$r = mysqli_query($dbc, "CALL remove_from_cart('$uid', '$sp_type', $pid)");
} elseif (isset ($sp_type, $pid, $_GET['action'], $_GET['qty']) && ($_GET['action'] == 'move') ) { // Move it to the cart.
// Determine the quantity:
$qty = (filter_var($_GET['qty'], FILTER_VALIDATE_INT, array('min_range' => 1))) ? $_GET['qty'] : 1;
// Add it to the cart:
$r = mysqli_query($dbc, "CALL add_to_cart('$uid', '$sp_type', $pid, $qty)");
// Remove it from the wish list:
$r = mysqli_query($dbc, "CALL remove_from_wish_list('$uid', '$sp_type', $pid)");
} elseif (isset($_POST['quantity'])) { // Update quantities in the cart.
// Loop through each item:
foreach ($_POST['quantity'] as $sku => $qty) {
// Parse the SKU:
list($sp_type, $pid) = parse_sku($sku);
if (isset($sp_type, $pid)) {
// Determine the quantity:
$qty = (filter_var($qty, FILTER_VALIDATE_INT, array('min_range' => 0)) !== false) ? $qty : 1;
// Update the quantity in the cart:
$r = mysqli_query($dbc, "CALL update_cart('$uid', '$sp_type', $pid, $qty)");
}
} // End of FOREACH loop.
}// End of main IF.
// Get the cart contents:
$r = mysqli_query($dbc, "CALL get_shopping_cart_contents('$uid')");
if (mysqli_num_rows($r) >= 1) { // Products to show!
include ('./views/cart.html');
} else { // Empty cart!
include ('./views/emptycart.html');
}
// Finish the page:
include ('./includes/footer.html');
?>
Wishlist.php
<?php
// This file manages the wish list.
// This script is begun in Chapter 9.
// Require the configuration before any PHP code:
require ('./includes/config.inc.php');
// Check for, or create, a user session:
if (isset($_COOKIE['SESSION'])) {
$uid = $_COOKIE['SESSION'];
} else {
$uid = md5(uniqid('biped',true));
}
// Send the cookie:
setcookie('SESSION', $uid, time()+(60*60*24*30));
// Include the header file:
$page_title = 'Coffee - Your Wish List';
include ('./includes/header.html');
// Require the database connection:
require (MYSQL);
// Need the utility functions:
include ('./includes/product_functions.inc.php');
// If there's a SKU value in the URL, break it down into its parts:
if (isset($_GET['sku'])) {
list($sp_type, $pid) = parse_sku($_GET['sku']);
}
if (isset ($sp_type, $pid, $_GET['action']) && ($_GET['action'] == 'remove') ) { // Remove it from the wish list.
$r = mysqli_query($dbc, "CALL remove_from_wish_list('$uid', '$sp_type', $pid)");
} elseif (isset ($sp_type, $pid, $_GET['action'], $_GET['qty']) && ($_GET['action'] == 'move') ) { // Move it to the wish list.
// Determine the quantity:
$qty = (filter_var($_GET['qty'], FILTER_VALIDATE_INT, array('min_range' => 1))) ? $_GET['qty'] : 1;
// Add it to the wish list:
$r = mysqli_query($dbc, "CALL add_to_wish_list('$uid', '$sp_type', $pid, $qty)");
// For debugging purposes:
//if (!$r) echo mysqli_error($dbc);
// Remove it from the cart:
$r = mysqli_query($dbc, "CALL remove_from_cart('$uid', '$sp_type', $pid)");
// For debugging purposes:
//if (!$r) echo mysqli_error($dbc);
} elseif (isset($_POST['quantity'])) { // Update quantities in the wish list.
// Loop through each item:
foreach ($_POST['quantity'] as $sku => $qty) {
// Parse the SKU:
list($sp_type, $pid) = parse_sku($sku);
if (isset($sp_type, $pid)) {
// Determine the quantity:
$qty = (filter_var($qty, FILTER_VALIDATE_INT, array('min_range' => 0)) !== false) ? $qty : 1;
// Update the quantity in the wish list:
$r = mysqli_query($dbc, "CALL update_wish_list('$uid', '$sp_type', $pid, $qty)");
}
} // End of FOREACH loop.
}// End of main IF.
// Get the wish list contents:
$r = mysqli_query($dbc, "CALL get_wish_list_contents('$uid')");
if (mysqli_num_rows($r) > 0) { // Products to show!
include ('./views/wishlist.html');
} else { // Empty cart!
include ('./views/emptylist.html');
}
// Finish the page:
include ('./includes/footer.html');
?>
Or Is the procedure problem? I cannot store the Procedure in my database.
#1304 - PROCEDURE select_categories already exists ...
Can anyone help me??Thank you very much!!!!
-
Hi can anyone help with the error messag below
An error occurred in script '/home/gbilling/public_html/cart.php' on line 81:
mysqli_affected_rows() expects parameter 1 to be mysqli
File:Cart.php
<?php
// This file manages the shopping cart.
// This script is begun in Chapter 9.
// Require the configuration before any PHP code:
require ('./includes/config.inc.php');
// Check for, or create, a user session:
if (isset($_COOKIE['SESSION'])) {
$uid = $_COOKIE['SESSION'];
} else {
$uid = md5(uniqid('biped',true));
}
// Send the cookie:
setcookie('SESSION', $uid, time()+(60*60*24*30));
// Include the header file:
$page_title = 'Coffee - Your Shopping Cart';
include ('./includes/header.html');
// Require the database connection:
require (MYSQL);
// Need the utility functions:
include ('./includes/product_functions.inc.php');
// If there's a SKU value in the URL, break it down into its parts:
if (isset($_GET['sku'])) {
list($sp_type, $pid) = parse_sku($_GET['sku']);
}
if (isset ($pid, $sp_type, $_GET['action']) && ($_GET['action'] == 'add') ) { // Add a new product to the cart:
$r = mysqli_query($dbc, "CALL add_to_cart('$uid', '$sp_type', $pid, 1)");
// For debugging purposes:
//if (!$r) echo mysqli_error($dbc);
} elseif (isset ($sp_type, $pid, $_GET['action']) && ($_GET['action'] == 'remove') ) { // Remove it from the cart.
$r = mysqli_query($dbc, "CALL remove_from_cart('$uid', '$sp_type', $pid)");
} elseif (isset ($sp_type, $pid, $_GET['action'], $_GET['qty']) && ($_GET['action'] == 'move') ) { // Move it to the cart.
// Determine the quantity:
$qty = (filter_var($_GET['qty'], FILTER_VALIDATE_INT, array('min_range' => 1))) ? $_GET['qty'] : 1;
// Add it to the cart:
$r = mysqli_query($dbc, "CALL add_to_cart('$uid', '$sp_type', $pid, $qty)");
// Remove it from the wish list:
$r = mysqli_query($dbc, "CALL remove_from_wish_list('$uid', '$sp_type', $pid)");
} elseif (isset($_POST['quantity'])) { // Update quantities in the cart.
// Loop through each item:
foreach ($_POST['quantity'] as $sku => $qty) {
// Parse the SKU:
list($sp_type, $pid) = parse_sku($sku);
if (isset($sp_type, $pid)) {
// Determine the quantity:
$qty = (filter_var($qty, FILTER_VALIDATE_INT, array('min_range' => 0)) !== false) ? $qty : 1;
// Update the quantity in the cart:
$r = mysqli_query($dbc, "CALL update_cart('$uid', '$sp_type', $pid, $qty)");
}
} // End of FOREACH loop.
}// End of main IF.
// Get the cart contents:
$r = mysqli_query($dbc, "CALL get_shopping_cart_contents('$uid')");
if (mysqli_affected_rows($r) > 1) { // Products to show!
include ('./views/cart.html');
} else { // Empty cart!
include ('./views/emptycart.html');
}
// Finish the page:
include ('./includes/footer.html');
?>
thanks
Problem Cart.Php & Wishlist.Php
in Effortless E-Commerce with PHP and MySQL
Posted
Thank you very much,Larry & Andrew,it work correctly.But i meet another problem.When i go to my admin panel:http://www.gbilling.com/admin,it will appear a SSL error.How to disable the SSL?