Page 1 of 1

My php guestbook

Posted: Wed Jul 16, 2003 3:49 pm
by teo
I have a webserver running on a Win95 machine (ye you read right). I am no php wiz, but i have installed php on the machine. My guestbook is a php script, but it doesnt seem to function like it should. The problem is that i get error messages when viewing the guestbook on my server. I now run my guestbook on a friends server for the time beeing. Below is the guestbook on my server, when i click the admin link i get errors.

http://www.tow.no/gjestebok/index2.htm

Below is the same guestbook running on my friends server, with no errors.

http://www.plymb.com/tow/guestbook/index.htm

I am clueless, one work and the other doesnt. Anybody got an idea what could be wrong?

:?: :?: :?: :?: :?:

Posted: Wed Jul 16, 2003 4:31 pm
by Monk
Well, it's not really an error that halts execution of the script, basically what it's saying is that the $username variable has no value yet.

Did you write the script? I'm guessing that the admin page has something like...

if ( $username == )
{}

Somewhere in it to check the submitted username and password to see if they are in fact an admin. To fix this either turn down your error reporting or ( preferably ) add something like this...

if ( isset( $_POST[ 'username' ] ) && $_POST[ 'username' ] == ... )
{}

So anyways... that's making a few assumptions and the code probably doesn't look exactly like that, but the errors tell you what line to look on and you should be able to figure it out from there.

Thx

Posted: Wed Jul 16, 2003 5:24 pm
by teo
I followed your advice on the error handling, just turned of the showing of notices. Worked like a charm! Thx! :)

Posted: Thu Jul 17, 2003 3:45 am
by twigletmac
As I clearly state in the post linked to in my signature turning down error reporting is not a solution. All it does is hide the problem so the error is still occuring - you just don't get a notice. Stop using the

Code: Select all

if ($username) {
method of testing if variables are set because it is the incorrect way of doing it and start using isset() or empty() to test the existance of variables.

Mac

Posted: Thu Jul 17, 2003 5:37 am
by Monk
My real advice is to fix the if statement, turning down the error reporting is just a temp fix to hide bad coding practices.