php error on winxp

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
netter
Forum Newbie
Posts: 3
Joined: Wed Jun 18, 2003 1:02 am

php error on winxp

Post by netter »

hope this is the right place to post...

since i moved my webserver to winxp pro i get the following error

warning: use of undefined constant mon assumed 'mon' in i:\http\index.inc online x

the soure is like this

if ($date[mon]==1) { $date[mon]=01;}

so what ... it worked in win98 and i just copied it over!
here is what i use to serve:

php: 4.1.1
apache: 1.3.27

php is loaded in apache via cgi binary (install.txt)

if iam using the newest php this error goes away and a new one comes up:

if i write a link like <a href='index.php?ref=link'>link</a>
and the sourece is like this:

switch ($ref) {
case 'link': include ("data/link.inc");
break;
}

it simply dont work

this one is also just copyed from win98

so if anyone knows what php / apache versions i should use with winxp pro and how to include php in apache
please write back! ... you may also write if you know a solution for the problems.

greetings from germany

netter
bjg
Forum Newbie
Posts: 15
Joined: Tue Jun 10, 2003 9:42 am
Location: .au

Post by bjg »

Read the error reporting config comments in your php.ini or alternatively http://au.php.net/error_reporting

As for the warning, to avoid it you need to check if the array index exists first before comparing it with a value.

Code: Select all

if(isset($date&#1111;mon]))
&#123;
    if ($date&#1111;mon]==1) &#123; $date&#1111;mon]=01;&#125; 
&#125;
netter
Forum Newbie
Posts: 3
Joined: Wed Jun 18, 2003 1:02 am

answer

Post by netter »

thanks for your answer

the array came from $date = getdate();

ill also look up in the php.ini

thanks
User avatar
releasedj
Forum Contributor
Posts: 105
Joined: Tue Jun 17, 2003 6:35 am

Post by releasedj »

For the first problem, in php when you access elements in an array you should use quotes.

Code: Select all

<?php
if ($date[mon]==1) { $date[mon]=01;}
?>
What PHP does with this is it first looks for a constant named 'mon'. When it doesn't find it, it assumes that you meant the string 'mon'. What you should write is this:

Code: Select all

<?php
if ($date['mon']==1) { $date['mon']=01;}
?>
That should get rid of your error.


For the second problem, new versions of php by default do not register request variables as global variables.
If you really need this behaviour, then change make register_globals = On in your php.ini file. However, what you should do is this:

Code: Select all

<?php
switch ($_GET['ref']) {
case 'link': include ("data/link.inc");
break;
}
?>
Take a look at the manual for pre-defined variables: http://uk.php.net/manual/en/language.va ... efined.php


Regards,

Kelvin
netter
Forum Newbie
Posts: 3
Joined: Wed Jun 18, 2003 1:02 am

all right ..

Post by netter »

ok boys, thank you very much...

i think i can work with that stuff as long as my provider dosnt switches register variables off (will be a lot of work)

thanks again ...
Post Reply