Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    apache configuration question. PHP error.

    I've a website running a php script that displays a random photo.
    On my live site everything works fine, but locally I get an error message. These are shown in the attached JPGs. A similar issue happens to the social icons on the left.
    Since the sites are identical, I assume this is a problem with my local server configuration.
    Can anyone help me fix this?
    Any help will be appreciated.

    Thank you.
    leifbaker@nj.rr.com




  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    That's a PHP error.
    Looks to me that you may be using the wrong datatype. max/min work with arrays or with two separate arguments, but these have been provided with a single scalar argument. If you have 2x arguments, one low and one high, you provide both for your rand:
    PHP Code:
    $lowValue 112;
    $highValue 1;
    $rand mt_rand(min($lowValue$highValue), max($lowValue$highValue)); 

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, Fou-Lu,
    but that's not the problem.
    The page runs fine on the live site (and the social icons suffer also).

    The problem is in my local php configuration, but I don't know how to fix it.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    No, the problem is your PHP versions.
    The document doesn't state a change, but its clearly there. 5.2x for sure accepts the arguments in either order. By 5.3.10 it tosses the above error if you have the maximum value before the minimum value. So your arguments are backwards.

  • #5
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok.
    I'm no php whiz, I'm a designer.
    But here's my script:

    <?php
    $total = "1";
    $file_type = ".jpg";
    $image_folder = "images/rotate2";
    $start = "112";
    $random = mt_rand($start, $total);
    $image_name = $random . $file_type;
    $url = "pics/pic_" . $random . '.php';
    echo "<a href=\"$url\" target=\"_blank\"><img src=\"$image_folder/$image_name\" /></a>"
    ?>

    Do you know how I can fix it to make it 5.3 compliant?

    Thanks for the help.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Yeah, swap the $start, $total arguments in mt_rand. $start = 112 and $total = 1. So they are backwards.
    Alternatively to keep it more dynamic, use this:
    PHP Code:
    $random mt_rand(min($start$total), max($start$total)); 
    Then either can be larger or smaller

  • #7
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Thanks

    That did it. Thanks a lot.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •