|
-
Jan 31st, 2003, 11:48 PM
#1
Thread Starter
Lively Member
problem with new version
My server guy updated to php 4.3.0.
It has done some bad things...
This is my problem...
I am using this to request url variable data:
$myLink = $_REQUEST[myLink];
$myFriendly = $_REQUEST[friendly];
Error:
Notice: Use of undefined constant myLink - assumed 'myLink' in d:\wwwroot\brandito\website\Site.php on line 8
Notice: Use of undefined constant friendly - assumed 'friendly' in d:\wwwroot\brandito\website\Site.php on line 9
Notice: Undefined index: friendly in d:\wwwroot\brandito\website\Site.php on line 9
If it 'assumes' that.. why the heck does it have to say so. The php code works.. it just adds these comments at the top! Bad design if you ask me. How does one go about fixing this?
Thanks alot for your support,
Brandito
Master of Cyber Fu - A Temple of Digital Chi
-
Feb 1st, 2003, 09:34 AM
#2
Conquistador
print $array[foo];
PHP looks for a constant named foo first, if it does not exist then
it'll shout an error of level E_NOTICE and then look for the key foo
(which is what you wanted) ...
error_reporting can be set about anywhere, including php.ini, .htaccess
and the error_reporting() function. And some code:
define('a', 'b');
$arr = array('a' => 'apple', 'b' => 'banana');
print $arr[a]; // banana
print $arr['a']; // apple
Moral of the story is you should always surround your array keys with
quotes!
A little searching goes a long way
-
Feb 1st, 2003, 01:48 PM
#3
Stuck in the 80s
Originally posted by da_silvy
Moral of the story is you should always surround your array keys with quotes!
I thought this was a common coding practice?
-
Feb 1st, 2003, 09:08 PM
#4
Conquistador
That's the way i do it
-
Feb 2nd, 2003, 06:54 AM
#5
Frenzied Member
Notice: Undefined index: friendly in d:\wwwroot\brandito\website\Site.php on line 9
That one is because "friendly" hasn't been passed into the $_REQUEST variable either. You can either get round it like $myFriendly = (isset($_REQUEST['friendly'])) $_REQUEST['friendly'] : ''; or you can turn the notice warnings off can't you with error_reporting()
-
Feb 2nd, 2003, 12:54 PM
#6
Frenzied Member
The FIX and it also started in 4.1 is to uncomment the error lines that read as follows,
error_reporting = E_ALL & ~E_NOTICE
if you don't have access to the ini file you can do it in code as well
you can insert this into your script at the very top
error_reporting (E_ALL ^ E_NOTICE);
Last edited by phpman; Feb 2nd, 2003 at 12:58 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|