Page 1 of 1
PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 1:24 pm
by php_ghost
Guys,
I have this captcha script and it behaves differently on my test server and production server.
the code looks like this:
Code: Select all
<?php
session_start();
if ($_SESSION['captchacode']=='' && !isset($_POST['captchasubmit'])) {
echo "Condition 1";
}elseif($_SESSION['captchacode'] == $_POST['captchasubmit']){
echo "Condition 2";
}elseif($_SESSION['captchacode'] != $_POST['captchasubmit']){
echo "Condition 3";
}
?>
In the test server, it works perfectly. Howerver, in the production server, it doesn't display anything on the browser. Have you guys encountered this? What could be the common cause for this? The two servers have different configurations etc. but this is the first time I have encountered a script that works this way.
Re: PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 1:44 pm
by jaoudestudios
Put an else on the end and see if it is falling through your script.
i.e.
Re: PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 2:25 pm
by php_ghost
tried it. it still displays nothing.
also i've got another part of the script which contains a loop.
the code looks like this:
Code: Select all
for ($i = 0; $i < $flakes; $i++) {
$x1 = mt_rand(0, 200);
$y1 = mt_rand(0, 50);
$x2 = $x1 + mt_rand(-2, 2);
$y2 = $y1 + mt_rand(-2, 2);
imageline($im, $x1, $y1, $x2, $y2, $fore);
}
In Production, when I place an echo statement inside this loop, it displays the text just once unlike in my test server, it loops correctly.
Re: PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 2:28 pm
by pickle
set the error reporting level to E_ALL at the top of your script.
Re: PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 2:32 pm
by php_ghost
pickle wrote:set the error reporting level to E_ALL at the top of your script.
Yeah tried it already. The script when in production, still doesn't display anything.
Re: PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 2:43 pm
by php_ghost
php_ghost wrote:tried it. it still displays nothing.
also i've got another part of the script which contains a loop.
the code looks like this:
Code: Select all
for ($i = 0; $i < $flakes; $i++) {
$x1 = mt_rand(0, 200);
$y1 = mt_rand(0, 50);
$x2 = $x1 + mt_rand(-2, 2);
$y2 = $y1 + mt_rand(-2, 2);
imageline($im, $x1, $y1, $x2, $y2, $fore);
}
In Production, when I place an echo statement inside this loop, it displays the text just once unlike in my test server, it loops correctly.
Alright it looks like this part of the script is what screws everything up. When I removed this entire For loop block, everything worked fine on production. But with this on, test is ok, production is jacked up. So what could be the problem with this block then? Any ideas?
Re: PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 3:29 pm
by pickle
The errors might also be going to a file rather than the screen. Do this:
or something similar - not 100% sure what the syntax is.
You can make a phpinfo() file to check what the ini settings are as well.
Re: PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 3:49 pm
by jaoudestudios
Check your server errors log
Re: PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 3:50 pm
by jaoudestudios
Oh what about different versions of php?
Re: PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 5:06 pm
by Mark Baker
jaoudestudios wrote:Oh what about different versions of php?
You'd be more likely to see an error (e.g. undefined function) with different versions of PHP.
Different php.ini might cause discrepancies though.
Re: PHP Script behaves differently on different servers
Posted: Mon Dec 22, 2008 10:55 pm
by jaoudestudios
production server wont show errors, just blank screen. Errors logs would record it though