Jump to content
Larry Ullman's Book Forums

Craig-UK

Members
  • Posts

    35
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by Craig-UK

  1. if (mysqli_affected_rows($r) >= 1) { // Products to show!

    include ('./views/cart.html');

    } else { // Empty cart!

    include ('./views/emptycart.html');

    }

    I may be wrong here, but I think you need to put "more than or equal to", cause surely if there is only 1 item in the shopping cart you would still want it to show.

    A alternate is to change the 1 to a 0 and leave it as just "more than".

     

    Also shouldn't it be "mysqli_num_rows" rather than "mysqli_affected_rows"?!

  2. I know this probably doesn't really matter much, but I am wondering whats the best hash algorithm to use? Also what is the difference between them if any?

    My host supports md2, md4, md5, sha1, sha256, sha384, sha512, ripemd128, ripemd160, ripemd256, ripemd320, whirlpool, tiger128,3, tiger160,3, tiger192,3, tiger128,4, tiger160,4, tiger192,4, snefru, gost, adler32, crc32, crc32b, haval128,3, haval160,3, haval192,3, haval224,3, haval256,3, haval128,4, haval160,4, haval192,4, haval224,4, haval256,4, haval128,5, haval160,5, haval192,5, haval224,5, haval256,5.

     

    Also is it bad saying what the server supports (obviously wont on the site itself)?! (abit late I know)

     

    Thanks

  3. My php script:

    <?php //Script 5.2 - handle_post.php

    // Display Errors

    ini_set ('display_errors', 1);

    error_reporting (E__ALL | E_STRICT);

     

    // Assigning Local Varibles

    $first_name = $_POST['first_name'];

    $last_name = $_POST['last_name'];

    $posting = $_POST['posting'];

     

    // Concantanating Varible

    $name = $first_name . ' ' . $last_name;

     

    print "<div>Thank you, $name, for your posting:

    <p>$posting</p></div>";

     

    ?>

     

    Any input would be appreciated.

    There is your problem, you have forgotten to include the $

  4. Thanks for noticing the problem Paul and thanks for your try at the script, but unfortunately didn't work

    ... at the time I used a sub-select/query to achieve the desired effect.

    Could you go a little into more detail as to how to achieve this if possible? I am just looking to do this so then only items within a certain mileage will show.

     

    P.S. Also as I forgot to mention before....

    MySQL: 5.1.52

    PHP: 5.2.17

  5. Sorry I should of been a lil more thorough about my query.

    Here is the scripts with and without the "WHERE" clause...

    http://www.flyinduck.com/distance1.php - Without

    		$q = "SELECT postcode, ROUND(DEGREES(ACOS(SIN(RADIANS($lat)) 
    * SIN(RADIANS(latitude)) 
    + COS(RADIANS($lat))  
    * COS(RADIANS(latitude))
    * COS(RADIANS($long - longitude)))) * 69.09, 2) AS distance FROM uk_postcodes ORDER BY distance ASC LIMIT 100";
    	$r = mysqli_query($dbc, $q);
    
    	if (mysqli_num_rows($r) > 0) {

    http://www.flyinduck.com/distance.php - With

    		$q = "SELECT postcode, ROUND(DEGREES(ACOS(SIN(RADIANS($lat)) 
    * SIN(RADIANS(latitude)) 
    + COS(RADIANS($lat))  
    * COS(RADIANS(latitude))
    * COS(RADIANS($long - longitude)))) * 69.09, 2) AS distance FROM uk_postcodes WHERE distance<=1 ORDER BY distance ASC LIMIT 100";
    	$r = mysqli_query($dbc, $q);
    
    	if (mysqli_num_rows($r) > 0) {

    Like I say I have tried it with "WHERE (distance<=1)" "WHERE distance<='1'" "WHERE (distance<='1')"

    Does it have anything to do with the fact that I put it to 2 decimal points?

    I did try the "WHERE" clause with "WHERE postcode != '$postcode'" which seemed to bring back results too.

    If there is any additional information you need please let me know and I'd gladly provide it.

     

    Thanks alot for any help

  6. Hi Larry, as like every says... fantastic books. I have 4.

    I can't seem to get my head around this 1 part. I have altered the Zip Code script to just do Postcodes for now without any stores/items.

     

    		$q = "SELECT postcode, ROUND(DEGREES(ACOS(SIN(RADIANS($lat)) 
    * SIN(RADIANS(latitude)) 
    + COS(RADIANS($lat))  
    * COS(RADIANS(latitude))
    * COS(RADIANS($long - longitude)))) * 69.09, 2) AS distance FROM uk_postcodes WHERE distance<=1 ORDER BY distance ASC LIMIT 100";
    	$r = mysqli_query($dbc, $q);

     

    The "WHERE" clause seems to not work. I have tried putting it in brackets, single quotations etc but still wont work. It does work without the "WHERE" clause though. Ideally I'd like it to limit the radius of searches.

    Can you see anything that I have done wrong? or what is the problem?

    I have had a look at other topics to see whether this has already been covered, but couldn't see anything.

     

    Thanks alot

×
×
  • Create New...