My php guestbook

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
teo
Forum Newbie
Posts: 5
Joined: Wed Jul 16, 2003 3:49 pm

My php guestbook

Post 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?

:?: :?: :?: :?: :?:
Monk
Forum Newbie
Posts: 8
Joined: Wed Jul 16, 2003 3:19 am
Location: Germany - Temporarily

Post 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.
teo
Forum Newbie
Posts: 5
Joined: Wed Jul 16, 2003 3:49 pm

Thx

Post by teo »

I followed your advice on the error handling, just turned of the showing of notices. Worked like a charm! Thx! :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Monk
Forum Newbie
Posts: 8
Joined: Wed Jul 16, 2003 3:19 am
Location: Germany - Temporarily

Post 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.
Post Reply