Page 1 of 1

php error on winxp

Posted: Wed Jun 18, 2003 1:02 am
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

Posted: Wed Jun 18, 2003 3:41 am
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;

answer

Posted: Wed Jun 18, 2003 4:01 am
by netter
thanks for your answer

the array came from $date = getdate();

ill also look up in the php.ini

thanks

Posted: Wed Jun 18, 2003 4:03 am
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

all right ..

Posted: Wed Jun 18, 2003 4:23 am
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 ...