Jump to content
Larry Ullman's Book Forums

lewy009

Members
  • Posts

    14
  • Joined

  • Last visited

Everything posted by lewy009

  1. Thanks it was a simple fix just needed the mysql.inc.php in the correct folder.
  2. Hello, I have the administration pages up and running the css, super fish menus all working but i seem to be having a problem with connecting the the database. All procedures have been entered into the database. when i click on any admin pages such as add product etc i get the following error An error occurred in script '/home3/fournirb/public_html/trad/admin/add_other_products.php' on line 15: require(includes/mysql.inc.php) [function.require]: failed to open stream: No such file or directory Mysql connection in admin config.php if ($_SERVER['HTTP_HOST']=='localhost') { $debug = TRUE; define ('BASE_URI', 'includes/'); define ('BASE_URL', 'www.fournirbeauty.co.uk/trad/admin/'); define ('MYSQL', BASE_URI . 'mysql.inc.php'); } else { define ('BASE_URI', '/path/to/htdocs/folder/'); define ('BASE_URL', 'http://www.address.com/'); define ('MYSQL', '/path/to/mysql_connect.inc.php'); }
  3. Upadte - I tried accessing the billing page using Google Chrome and found that the browser is having a problem with the SSL Google Chrome states this: The site uses SSL, but Google Chrome has detected either high-risk insecure content on the page or problems with the site’s certificate. Don’t enter sensitive information on this page. Invalid certificate or other serious https issues could indicate that someone is attempting to tamper with your connection to the site. Can someone tell me what i maybe doing wrong?
  4. its working now something to do with the hostgator server i was using. I tried starting again and the stored procedures got corrupted and I couldn't store and new procedures. I done exactly the same on my blue host server and it all worked fine.
  5. Hello, It seems i have the same problem - getting redirected to cart.php after clicking 'continue to billing'. Cart.php // Check for the user's session ID, to retrieve the cart contents: if ($_SERVER['REQUEST_METHOD'] == 'GET') { if (isset($_GET['session'])) { $uid = $_GET['session']; // Use the existing user ID: session_id($uid); // Start the session: session_start(); } else { // Redirect the user. $location = 'http://' . BASE_URL . '/cart.php'; header("Location: $location"); exit(); } } else { // POST request. session_start(); $uid = session_id(); } This is where its getting redirected to cart.php so I'm asumming I have the same problem as above but as im not the greatest programmer about I am still here with the problem. Can someone point me in the right direction on how i go about fixing this problem? I can see its something to do with the session but dont know how to fix it.
  6. The steps i took was I opened the sql data in word pad and copied and pasted the sql to create the tables every table was run seperatley. Then i copied and pasted the sample data and run them seperatly. Then for the procedures i copied and pasted them when asked in the book seperatley. so after the tables were made and the sample data was entered i run the following all seperatly Select_categories Select_products select_sale_items Then i updated select_products Then i ran the stored procedures the in the following order; add_to_cart remove_from_cart update_cart get_shopping_cart_contents I run all this through phpmyadmin my host is hostgator. I still cannot find a problem with the stored procedure would it be the stored procedure though if it is a copy and paste from coffee sample?
  7. Thanks for the reply I am guessing the problem is one of the procedures for each the wishlist and cart Below are the four procedures i stored in the database for cart. My guess is that get_shopping_cart_contents proecdure is the problem but i cannot seem to figure it out what's wrong. can anyone see any syntax errors with my get_shopping_cart_contents procedure? I copied and pasted the procedures from wordpad when needed. DELIMITER $$ CREATE PROCEDURE update_cart (uid CHAR(32), type VARCHAR(6), pid MEDIUMINT, qty TINYINT) BEGIN IF qty > 0 THEN UPDATE carts SET quantity=qty, date_modified=NOW() WHERE user_session_id=uid AND product_type=type AND product_id=pid; ELSEIF qty = 0 THEN CALL remove_from_cart (uid, type, pid); END IF; END$$ DELIMITER ; DELIMITER $$ CREATE PROCEDURE add_to_cart (uid CHAR(32), type VARCHAR(6), pid MEDIUMINT, qty TINYINT) BEGIN DECLARE cid INT; SELECT id INTO cid FROM carts WHERE user_session_id=uid AND product_type=type AND product_id=pid; IF cid > 0 THEN UPDATE carts SET quantity=quantity+qty, date_modified=NOW() WHERE id=cid; ELSE INSERT INTO carts (user_session_id, product_type, product_id, quantity) VALUES (uid, type, pid, qty); END IF; END$$ DELIMITER ; DELIMITER $$ CREATE PROCEDURE remove_from_cart (uid CHAR(32), type VARCHAR(6), pid MEDIUMINT) BEGIN DELETE FROM carts WHERE user_session_id=uid AND product_type=type AND product_id=pid; END$$ DELIMITER ; DELIMITER $$ CREATE PROCEDURE get_shopping_cart_contents (uid CHAR(32)) BEGIN SELECT CONCAT("O", ncp.id) AS sku, c.quantity, ncc.category, ncp.name, ncp.price, ncp.stock, sales.price AS sale_price FROM carts AS c INNER JOIN non_coffee_products AS ncp ON c.product_id=ncp.id INNER JOIN non_coffee_categories AS ncc ON ncc.id=ncp.non_coffee_category_id LEFT OUTER JOIN sales ON (sales.product_id=ncp.id AND sales.product_type='other' AND ((NOW() BETWEEN sales.start_date AND sales.end_date) OR (NOW() > sales.start_date AND sales.end_date IS NULL)) ) WHERE c.product_type="other" AND c.user_session_id=uid UNION SELECT CONCAT("C", sc.id), c.quantity, gc.category, CONCAT_WS(" - ", s.size, sc.caf_decaf, sc.ground_whole), sc.price, sc.stock, sales.price FROM carts AS c INNER JOIN specific_coffees AS sc ON c.product_id=sc.id INNER JOIN sizes AS s ON s.id=sc.size_id INNER JOIN general_coffees AS gc ON gc.id=sc.general_coffee_id LEFT OUTER JOIN sales ON (sales.product_id=sc.id AND sales.product_type='coffee' AND ((NOW() BETWEEN sales.start_date AND sales.end_date) OR (NOW() > sales.start_date AND sales.end_date IS NULL)) ) WHERE c.product_type="coffee" AND c.user_session_id=uid; END$$ DELIMITER ;
  8. I have a problem with the example two:Coffee. I get the following errors with accessing wishlist and cart; wishlist.php An error occurred in script '/home/lewyh/public_html/cart.php' on line 81: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given cart.php An error occurred in script '/home/lewyh/public_html/cart.php' on line 81: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given I have run the 4 procedures in phpmyadmin for each cart and wishlist with no problems but still get the errors. I have checked the database user and allowed all privilages with no luck. I have droped the procedures and run them again with no luck. I have done a search and came accross the same problem but still couldnt seem to fix it. The temp URL is www.spafusion.co.uk Below is the php for cart.php and wishlist.php 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_num_rows($r) > 0) { // 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'); ?> Any help will be greatly appreciated. Lewis
  9. i am now getting: An error occurred in script '/home/lewyh/public_html/site2/html/views/home.html' on line 14: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given does this mean the conenction to database is right now but theres somethnig else wrong? Can anyone help please?
  10. Thanks for the reply Rob, In my config.inc i have: define ('BASE_URI', '/site2/'); define ('BASE_URL', 'www.spafusion.co.uk'); define ('MYSQL', BASE_URI . 'mysql.inc.php'); and mysql.inc.php is stored in home/lewyh/public_html/site2/ or www.spafusion.co.uk/site2 i have uploaded the site so it will be www.spafusion.co.uk/site2/html. all the shop.php, index.php etc is in the folder html and the mysql.inc.php is up 1 directory in /site2 sorry if it is confusing i am not very good at explaining in plain english.
  11. for reference, i am trying to copy the coffee shop example exactly then when i have done that i will start my own or edit the coffee shop.
  12. i have made the database, uploaded the sample coffe shop edited the config.php and mysql.inc.php so they connect to database etc. but i am getting the following. Can anyone help me please?
×
×
  • Create New...