Jump to content
Larry Ullman's Book Forums

caytre

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by caytre

  1. 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.

  2. 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.

  3. 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,".

  4. 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.

  5. 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.

  6. Hi all,

    I try create shop by Effortless E-Commerce with PHP and MySQL since October, but I don't know why it was'nt done. I always have an answer like that :

    mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given ( for cart.php , wishlist.php and home.html), where must I find errors.

    The wishlist.php needs a procedure get_wish_list_contents but I can't find it in the book, I have a book in Polish version, maybe someone can give me that procedure.

    Thanks a lot

×
×
  • Create New...