CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Apache configuration (http://www.codingforums.com/forumdisplay.php?f=69)
-   -   apache configuration question. PHP error. (http://www.codingforums.com/showthread.php?t=268981)

leifbaker 07-28-2012 01:56 PM

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

http://leifbaker.net/error/lbd.jpg

http://leifbaker.net/error/lbd_errors.jpg

Fou-Lu 07-28-2012 05:09 PM

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)); 


leifbaker 07-29-2012 01:08 AM

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.

Fou-Lu 07-29-2012 08:47 PM

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.

leifbaker 07-30-2012 02:48 AM

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.

Fou-Lu 07-30-2012 11:48 PM

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

leifbaker 07-31-2012 12:44 AM

Thanks
 
That did it. Thanks a lot.


All times are GMT +1. The time now is 12:27 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.