Jump to content
Larry Ullman's Book Forums

JBruner

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by JBruner

  1. I am also getting an Internal 500 Error, and just cant seem to figure out why. I am copying the code straight from the printed book. When i don't have the .htaccess uploaded then the page shows up fine, but no links work. I would greatly appreciate any help. thank you!

     

    Here is the error:

     

    Internal Server Error


    The server encountered an internal error or
    misconfiguration and was unable to complete
    your request.


    Please contact the server administrator,
    webmaster@allthatteases.johnnybrunerdesigns.com and inform them of the time the error occurred,
    and anything you might have done that may have
    caused the error.


    More information about this error may be available
    in the server error log.


    Additionally, a 500 Internal Server Error
    error was encountered while trying to use an ErrorDocument to handle the request.



    Apache Server at www.allthatteases.com Port 80

    Here is my code:

     

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^allthatteases\.com
    RewriteRule ^(.*)$ http://www.allthatteases.com/$1 [R=permanent,L]
    # For sales:
    RewriteRule ^shop/sales/?$ sales.php
    # For the primary categories:
    RewriteRule ^shop/([A-Za-z\+]+)/?$ shop.php?type=$1
    # For specific products:
    RewriteRule ^browse/([A-Za-z\+\-]+)/(A-Za-z\+\-]+)/([0-9]+)$ browse.php?type=$1&category=$2&id=$3
    # For HTTPS pages:
    RewriteCond %{HTTPS}off
    RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1[R=301,L]
    </IfModule>

  2. I am having another error issue with a certain procedure. Here is the original code provided

     

     

    $r = mysqli_query($dbc, "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'");

     

    I changed the double quotes in the beginning and end to single quotes, pasted below is the code how I changed it. In red is the line where I am receiving the error, If someone can explain I would really appreciate it! Thank you so much!

     

    $r = mysqli_query($dbc, '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'');

  3. I had to rewrite the stored procedures since my hosting doesn't allow EXECUTE capabilities. I do all of my coding in Dreamweaver because I find the color coding is easier to find errors. I am not an expert in PHP by any means, but I can usually get my way around. So in copying the scripts Larry provided in his Rewriting Stored Procedures blog I get a couple errors (highlighted in red):

     

     

    if ($type == 'coffee') {

    $r = mysqli_query($dbc, 'SELECT gc.description, gc.image, CONCAT("C", sc.id) AS sku,

    CONCAT_WS(" - ", s.size, sc.caf_decaf, sc.ground_whole, sc.price) AS name,

    sc.stock, sc.price, sales.price AS sale_price

    FROM specific_coffees AS sc 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 general_coffee_id=' . $sp_cat . ' AND stock>0

    ORDER by name');

    } elseif ($type == 'goodies') {

    $r = mysqli_query($dbc, 'SELECT ncc.description AS g_description, ncc.image AS g_image,

    CONCAT("O", ncp.id) AS sku, ncp.name, ncp.description, ncp.image,

    ncp.price, ncp.stock, sales.price AS sale_price

    FROM non_coffee_products AS ncp 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 non_coffee_category_id=' . $sp_cat . ' ORDER by date_created DESC');

    }

     

    Am I correct in saying that coffee and goodies should be double quotation marks: "coffee" "goodies"?

  4. So I am pretty comfy with PHP and MySQL, but am still learning so I seem to be stuck. I am working on the "Coffee" site and my hosting service doesn't allow EXECUTE for procedures, so I need to convert the procedures into PHP code but just can't seem to get it right. If there is someone who can help I would be ever so greatful. Just for example if I need to convert this code:

     

    DELIMITER $$

    CREATE PROCEDURE get_order_contents (oid INT)

    BEGIN

    SELECT oc.quantity, oc.price_per, (oc.quantity*oc.price_per) AS subtotal, ncc.category, ncp.name, o.total, o.shipping

    FROM order_contents AS oc INNER JOIN non_coffee_products AS ncp ON oc.product_id=ncp.id

    INNER JOIN non_coffee_categories AS ncc ON ncc.id=ncp.non_coffee_category_id

    INNER JOIN orders AS o ON oc.order_id=o.id WHERE oc.product_type="other" AND oc.order_id=oid

    UNION SELECT oc.quantity, oc.price_per, (oc.quantity*oc.price_per), gc.category, CONCAT_WS(" - ", s.size, sc.caf_decaf, sc.ground_whole), o.total, o.shipping

    FROM order_contents AS oc

    INNER JOIN specific_coffees AS sc ON oc.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

    INNER JOIN orders AS o ON oc.order_id=o.id

    WHERE oc.product_type="coffee" AND oc.order_id=oid;

    END$$

    DELIMITER ;

     

    into PHP script, what would be the easiest way of doing so? I would appreciate any feedback I could get. Thank you in advance!

    Johnny

×
×
  • Create New...