coopster

msg:3561118 | 5:42 pm on Jan 29, 2008 (gmt 0) |
In regards to ... what? Error reporting? The function you mentioned is where you can set the level of "strictness" for error handling.
|
jatar_k

msg:3561139 | 6:13 pm on Jan 29, 2008 (gmt 0) |
plus a non initialized variable will only throw a warning are these warnings showing in the page? as coop confirmed, just use [php.net...] unless there is something we are not understanding
|
ryan_b83

msg:3561197 | 7:09 pm on Jan 29, 2008 (gmt 0) |
Hi, yea well i know about the error_reporting() function which does hide the warning message. However the following code does not work: <? $error[] = "Some error here"; foreach($error as $k=>$v){ echo $v."<br>"; } ?>
This just echo's the letter "S" (the first letter in the error message), I think it is because although I am attempting to set it into an array, its setting it as a scalar variable because i didn't initiate the array. If it add <? $error = array();continue code...
Then it works, because it sets the variable type as an array. Now I know that the correct thing to do would be to code stricter and actually instantiate my variables with the correct data types, but I have the whole thing working on 1 server (which allows this), and now that I am trying it on another server it wont set the variables the same. Any ideas? Thanks, Ryan
|
coopster

msg:3561215 | 7:28 pm on Jan 29, 2008 (gmt 0) |
| I think it is because although I am attempting to set it into an array, its setting it as a scalar variable because i didn't initiate the array. |
| No, that is not the case as PHP allows you to Create/modify with square-bracket syntax [php.net]. If the array does not yet exist it will be created. Which version of PHP is running on the server that is not working correctly?
|
ryan_b83

msg:3561294 | 8:26 pm on Jan 29, 2008 (gmt 0) |
Hum, ok could the fact that register_globals is turned on? I know that the server that it works on, the register_globals is off... im not sure if thats the only difference. Thanks, Ryan
|
coopster

msg:3561316 | 8:40 pm on Jan 29, 2008 (gmt 0) |
Which version of PHP? PHP 4.7? PHP 5.2.5? I don't believe register_globals would have anything to do with it. To find out, you could always dump the variable prior to using it here to see if it exists in memory already. You'll get an error if it doesn't exist.
<?php print '<pre>'; [b]var_dump [php.net]($error); print '</pre>'; $error[] = "Some error here"; foreach($error as $k=>$v){ echo $v."<br>"; } ?> Have you viewed the source in the browser too and make sure that not just the "S" is being written? Perhaps the text is indeed there, just not rendering in the browser.
|
cameraman

msg:3561327 | 8:53 pm on Jan 29, 2008 (gmt 0) |
I know that you can get into trouble with this: $error = "hello"; $error[] = "Some error"; The fix is to either unset($error); or $error = array(); before reusing it as an array. I ran across this a couple of months ago, and verified that it caused problems on both my shared hosting 4.7 LAMP and my 5.2.something WAMP home game.
|
|