caytre Posted December 23, 2011 Share Posted December 23, 2011 Hi all, I have a question, I droped all procedures and re_uploaded all, next I re_uploaded all again and I have such a result : -PROCEDURE select_categories already exists, -PROCEDURE select_products already exists, - ................... select_sale_items already exists -.................... update_cart already exists -.................... add_customer already exists, -................. get_order_contents already exists, -..................... get_shopping_cart_contents The SQL query has been executed successfully, -..................... clear_cart ...................as above........................................., - .....................add_transactions ....................as above........................................., -......................add_to_cart ....................as above..........................................' -......................remove_from_cart ....................as above.........................................., -..................... add_to_wish_list ....................as above..........................................., -......................remove_from_wish_list ....................as above..........................................., -......................update_wish_list ....................as above..........................................., -......................get_shopping_wish_list_contents.....................as above............................................, -......................add_order ......................as above............................................ Is it ok or not ? If it was ok, why cart.php, wishlist.php don't work? Thanks for the advices. Link to comment Share on other sites More sharing options...
Larry Posted December 23, 2011 Share Posted December 23, 2011 If it already exists, then it's okay. Have you tested them? Have you implemented the standard debugging methods for your cart.php and wishlist.php scripts? And per the forum guidelines, how about including basic information such as the versions in use? Link to comment Share on other sites More sharing options...
caytre Posted December 23, 2011 Author Share Posted December 23, 2011 Hi, Server has MySQL 5, PHP 5.2, phpMyAdmin 3.3.9.2 I don't know how to test procedures, but when I called procedures I got such a result : -get_shopping_cart_contents no exists -clear_cart no exists -add_transactions no exists -add_to_cart no exists -remove_from_cart no exists -add_to_wish_list no exists -remove_from_wish_list no exists -update_wish_list no exists -get_shopping_wish_list_contents no exists -add_order no exists And when I called those procedures : select_sale_items and get_order_contents I got field of SQL ( no error and no info ) What is it ? I don't know. Link to comment Share on other sites More sharing options...
Larry Posted December 24, 2011 Share Posted December 24, 2011 Where/how are you calling them? If you get a list of messages that say they exist and then get a list of messages saying they don't exist, you're probably accidentally using two different databases. Link to comment Share on other sites More sharing options...
caytre Posted December 24, 2011 Author Share Posted December 24, 2011 I called like that : CALL add_to_cart ( ) and I got an answer : #1305 - PROCEDURE db229174.add_to_cart does not exist My datebase is db229174. I re_uploaded PROCEDURE add_to_cart ( ) again to db229174 and I got answer : The SQL query has been executed successfully, I called this PROCEDURE again : CALL add_to_cart ( ) and I got : #1305 - PROCEDURE db229174.add_to_cart does not exist again, Why ? If you read carefully my post in top you know that not ok because all procedures were re_uploaded again and for some procedures the answer was : "The SQL query has been executed successfully." and for other the answer was :".. .already exists,". Link to comment Share on other sites More sharing options...
caytre Posted December 27, 2011 Author Share Posted December 27, 2011 Hi all, It seems that nobody knows why scripts cart.php and wishlist.php don't work for me. Effortless is not effortless. Link to comment Share on other sites More sharing options...
Jonathon Posted December 27, 2011 Share Posted December 27, 2011 How much PHP an MySQL experience do you have? This book isn't for beginners. I am having some difficulty following what is happening, have you Googled this to see if anyone else has had these problems. Link to comment Share on other sites More sharing options...
Larry Posted December 27, 2011 Share Posted December 27, 2011 And I, for one, would be much more willing to help if your attitude were better and if you followed the forum guidelines. In short, you'd do better if you spent less time being insulting and more time trying to provide the information that people need in order to actually help. Never forget that you are asking for free help from strangers here. Clearly the code in the book does work, as it's been tested by thousands of people by now. You just haven't done something right with that code. Link to comment Share on other sites More sharing options...
caytre Posted December 27, 2011 Author Share Posted December 27, 2011 Hi Larry, Jonathon and all, I am very sorry, if my words offended someone, I am just angry with myself. I bought this book at the end of September, I thing all in the book is understood, all is clearly for me as a beginner in PHP and SQL. So I started building shop based on this book. I'm learning from this book i making a shop. Some scripts work, but scripts cart.php and wishlist.php don't. The worst thing that I don't know where is the error. My website is: http://www.caytre.ugu.pl/ cart.php : <?php require ('./includes/config.inc.php'); if (isset($_COOKIE['SESSION'] )) { $uid = $_COOKIE['SESSION']; } else { $uid = md5(uniqid('biped',true)); } setcookie('SESSION', $uid, time()+(60*60*24*30)); $page_title = 'Caytre - koszyk na zakupy'; include ('./includes/header.html'); require (MYSQL); include ('./includes/product_functions.inc.php'); if (isset($_GET['sku'] )) { list($sp_type, $pid) = parse_sku($_GET['sku'] ); } if (isset ($sp_type, $pid, $_GET['action'] ) && ($_GET['action'] == 'add') ) { $r = mysqli_query($dbc, "CALL add_to_cart('$uid', '$sp_type', $pid, 1)"); } elseif (isset ($sp_type, $pid, $_GET['action'] ) && ($_GET['action'] == 'remove') ) { $r = mysqli_query($dbc, "CALL remove_from_cart('$uid', '$sp_type', $pid)"); } elseif (isset ($sp_type, $pid, $_GET['action'], $_GET['qty'] ) && ($_GET['action'] == 'move') ) { $qty = (filter_var($_GET['qty'], FILTER_VALIDATE_INT, array('min_range' => 1))) ? $_GET['qty'] : 1; $r = mysqli_query($dbc, "CALL add_to_cart('$uid', '$sp_type', $pid, $qty)"); $r = mysqli_query($dbc, "CALL remove_from_wish_list('$uid', '$sp_type', $pid)"); if (!$r) echo mysqli_error($dbc); } elseif (isset($_POST['quantity'] )) { foreach ($_POST['quantity'] as $sku => $qty) { list($sp_type, $pid) = parse_sku($sku); if (isset($sp_type, $pid)) { $qty = (filter_var($qty, FILTER_VALIDATE_INT, array('min_range'=> 0))) ? $qty : 1; $r = mysqli_query($dbc, "CALL update_cart('$uid', '$sp_type', $pid, $qty)"); } } } //Koniec głównej instrukcji warunkowej IF. $r = mysqli_query($dbc, "CALL get_shopping_cart_contents('$uid')"); if (mysqli_num_rows($r) > 0) { include ('./views/cart.html'); } else { //Pusty koszyk include ('./views/emptycart.html'); } include ('./includes/footer.html'); Again sorry for all. Link to comment Share on other sites More sharing options...
Larry Posted December 28, 2011 Share Posted December 28, 2011 Okay, well if you had standard PHP-MySQL skills, you'd know that the standard debugging approach here is simple and always the same: Print out the exact query being run by the script. Execute that query using another interface, such as phpMyAdmin. This confirms the results of the query, so you can determine if the problem is within the PHP code or the MySQL result. As I suggested previously, "If you get a list of messages that say they exist and then get a list of messages saying they don't exist, you're probably accidentally using two different databases." I know you already gave a rather snarky response to that suggestion, but the suggestion remains the same. Link to comment Share on other sites More sharing options...
caytre Posted December 28, 2011 Author Share Posted December 28, 2011 Thanks for advices, I think I have problems with probably hosting, where I have my web page. I did this, I logget into my database db229174, in the phpMyAdmin ( for db229174) I pressed a button SQL and uploaded a query : add_to_cart : 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 > o 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 ; and I got the a reply : The SQL query has been executed successfully. Next in the SQL for database db229174, I ran CALL add_to_cart and I got a reply : #1305 - PROCEDURE db229174.add_to_cart does not exist I sent a query to owner of the hosting, but I haven't the answer. Link to comment Share on other sites More sharing options...
Larry Posted December 28, 2011 Share Posted December 28, 2011 Good. Then it's probably a hosting issue and you'll need to wait for their response. On my main site I provide instructions for implementing this site without stored procedures, FYI. Link to comment Share on other sites More sharing options...
Recommended Posts