Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-28-2012, 01:56 PM   PM User | #1
leifbaker
New to the CF scene

 
Join Date: Jul 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
leifbaker is an unknown quantity at this point
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



leifbaker is offline   Reply With Quote
Old 07-28-2012, 05:09 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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)); 
Fou-Lu is offline   Reply With Quote
Old 07-29-2012, 01:08 AM   PM User | #3
leifbaker
New to the CF scene

 
Join Date: Jul 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
leifbaker is an unknown quantity at this point
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.
leifbaker is offline   Reply With Quote
Old 07-29-2012, 08:47 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Old 07-30-2012, 02:48 AM   PM User | #5
leifbaker
New to the CF scene

 
Join Date: Jul 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
leifbaker is an unknown quantity at this point
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.
leifbaker is offline   Reply With Quote
Old 07-30-2012, 11:48 PM   PM User | #6
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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
Fou-Lu is offline   Reply With Quote
Old 07-31-2012, 12:44 AM   PM User | #7
leifbaker
New to the CF scene

 
Join Date: Jul 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
leifbaker is an unknown quantity at this point
Thumbs up Thanks

That did it. Thanks a lot.
leifbaker is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:12 AM.


Advertisement
Log in to turn off these ads.