Page 1 of 2

Problems with my phpsite

Posted: Thu Jun 06, 2002 5:30 am
by XepheX
Hi!

First of all im a newbie at php and mysql, an all that includes :)
A got a slight problem with my phpsite, and i dont know whats wrong.
I´ve copyed the code from a magazin that had a artikel how to make a community in php.
The code is exactly as they wrote it, but it won´t work, so i wonder if you could help me :?:

The addres to the site is http://XepheX.mine.nu/XZone/index.php
And the code can you see here http://w1.141.telia.com/~u14116407/

Im using
MySQL: 3.23.49
PHP: 4.2.1
Apache: 1.3.23
On Windows XP

Thanks / XepheX

Posted: Thu Jun 06, 2002 5:33 am
by twigletmac

Posted: Thu Jun 06, 2002 5:55 am
by Wayne
what error message are you getting?

Posted: Thu Jun 06, 2002 6:08 am
by XepheX
I get a lot of errormessegs if you would like to see check out the link above.

twigletmac! what about the other thread! I cant get anything out of it.

Posted: Thu Jun 06, 2002 6:24 am
by twigletmac
The code you have assumes that register_globals is on. Find the php.ini file, search within that file for register_globals then change where it says

Code: Select all

register_globals = off
to

Code: Select all

register_globals = on
and then see if the code runs.

This is a very common problem, the other post explains why those errors occur when register_globals is set to off and how to adjust your code so that you don't need register_globals on.

Mac

Posted: Thu Jun 06, 2002 6:54 am
by XepheX
I checked the php.ini and

Code: Select all

register_globals = on
is on by default.

Posted: Thu Jun 06, 2002 7:02 am
by twigletmac
Try changing line 33 in login.php from

Code: Select all

if ($msg!="") &#123; print "<p><b>$msg</b>\n"; &#125;
to

Code: Select all

if (isset($msg) && $msg != '') &#123; print "<p><b>$msg</b>\n"; &#125;
and similarily line 3 from

Code: Select all

if ((int)$msgcode>0)
to

Code: Select all

if (isset($msgcode) && (int)$msgcode>0)
Mac

Posted: Thu Jun 06, 2002 7:43 am
by XepheX
Now it happends som nice things! Thanks twigletmac!
Now it only reamins, what ican see 2 problems.
1. at the topframe : Internal Server Error
2.

Code: Select all

if ($action=="nymedlem")
at nymedlem.php line 2

3. When i try to register me i get this error:
Warning: Cannot add header information - headers already sent by (output started at c:\program\apache group\apache\htdocs\xzone\dblib.php:66) in c:\program\apache group\apache\htdocs\xzone\nymedlem.php on line 22

Posted: Thu Jun 06, 2002 7:58 am
by twigletmac
1. Do you have a top.php file?

2. As before:

Code: Select all

if (isset($action) && $action=='nymedlem')
3. You can't use header() if any output has been sent to the browser, so no HTML or whitespace can be sent before you try to redirect the page.

Mac

Posted: Thu Jun 06, 2002 8:20 am
by XepheX
1. No i dont have a top.php :)
2. ok thanks. So every time there is if, i´ll use

Code: Select all

(isset($bla) && $bla=='bla')
?

Posted: Thu Jun 06, 2002 8:29 am
by twigletmac
Use isset to make sure that you don't get undefined variable notices. If you know that the variable has already been set then it won't be necessary. So you could have,

Code: Select all

if (isset($page) && $page != '') &#123;
    //Do something
    if ($page == index) &#123; // Don't need isset statement here
         //Do something extra
    &#125;
    //Finish off
&#125;
It's not the best example but it shows the basic principal - if you've already tested to make sure a variable exists you probably won't need to test again within the same loop.

Mac

Posted: Thu Jun 06, 2002 4:13 pm
by XepheX
Hi again! and thanks!

I got a slight problem how to figur out how to put this in a isset string

Code: Select all

(mysql_num_rows($result)==0)
It´s () who make me confused :?

Posted: Thu Jun 06, 2002 4:45 pm
by twigletmac
mysql_num_rows() just checks to see how many rows are returned from a query (in this case $result). It's not a variable it's a function so you don't need to check to see if it is set.

It would probably be a good idea if you had a look at some of the PHP tutorials at places like:
http://www.phpbuilder.com
http://www.devshed.com
http://www.zend.com
as well as the sites within the Developer Network.

Mac

Posted: Fri Jun 07, 2002 3:24 pm
by XepheX
Thanks twigletmac for the links!

Posted: Sun Jun 09, 2002 11:45 am
by XepheX
And it happends again! :evil:
The idea with my site is that your suppost to register, and then get some friends, send emails to other persons that are registred at my site.

Problem nr.1
But now it seems like ive got problem again. First of all, if your new at my site and whant to register you clik the link that says här,
then youll been taken to the "register part". But when i fill out my username and password i´ve been taken to the inloggpart, but it says Du är nu utloggad, välkommen tillbaka! (You have been outlogged, welcome back!)

Problem nr.2
If i fill out wrong username or password, there shall come an errormsg that say Wrong username or password!. But instead i got an php errormsg, that says:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\program\apache group\apache\htdocs\xzone\dologin.php on line 6

Warning: Cannot add header information - headers already sent by (output started at c:\program\apache group\apache\htdocs\xzone\dologin.php:6) in c:\program\apache group\apache\htdocs\xzone\dologin.php on line 8

ive cheched the code, but i cant figgur it out, so im turning to you guys, one more time :D