I'm having the error again this time on my webserver. I have it set as a
global variable but it's not working. It can be found at
http://mom.melchior.us. Type in test for the username and password.
Why???

Thanks,
Stephen
http://www.melchior.us
http://php.melchior.us

:: -----Original Message-----
:: From: debbie_dyer [mailto:[EMAIL PROTECTED]] 
:: Sent: Saturday, September 28, 2002 6:03 PM
:: To: [EMAIL PROTECTED]
:: Subject: Re: [PHP] Member's Area Script
:: 
:: 
:: 
::   $conn = $main; <- that line is the problem - you cant use 
:: global vars inside functions without declaring them as global
:: 
:: ----- Original Message -----
:: From: "Stephen Craton" <[EMAIL PROTECTED]>
:: To: <[EMAIL PROTECTED]>
:: Sent: Saturday, September 28, 2002 11:49 PM
:: Subject: [PHP] Member's Area Script
:: 
:: 
:: > Hello again,
:: >
:: > I'm trying to write a script that has a member's area in 
:: it. So far 
:: > I've been able to successfully validate only one username 
:: and only one 
:: > password but now I'm going big and trying to compare it 
:: with a table 
:: > in my MySQL database. Everything goes nice and smooth 
:: until I actually 
:: > try and enter in my username and password. I type it in, copy and 
:: > paste, whaetever and it tells me the error I wanted it to say "The 
:: > username and password is not a good combo." I've copied 
:: and pasted the 
:: > username and password from the database directly yet it 
:: still gives me 
:: > this error. Here's my code for the login() function that 
:: logs the user 
:: > in:
:: >
:: > function login($username, $password)
:: > {
:: >   $conn = $main;
:: >   if (!$conn)
:: >     return 0;
:: >
:: >   $result = mysql_query("select * from user
:: >                          where username='$username'
:: >                          and passwd = '$password'");
:: >   if (!$result)
:: >      return 0;
:: >
:: >   if (mysql_num_rows($result)>0)
:: >      return 1;
:: >   else
:: >      return 0;
:: > }
:: >
:: > Here's the code for the part that calls the login() function:
:: >
:: > if(login($user, $pass))
:: > {
:: > $valid_user = $user;
:: > session_register("valid_user");
:: > }
:: > else
:: > {
:: > echo "<font face='Arial, Helvetica, sans-serif' 
:: > size='3'><center><b>You supplied an invalid username and password 
:: > combo. Try again please.</b></center>"; exit;
:: > }
:: >
:: > And here's the part that connects to the database:
:: >
:: > <?php
:: > # FileName="Connection_php_mysql.htm"
:: > # Type="MYSQL"
:: > # HTTP="true"
:: > $hostname_main = "localhost";
:: > $database_main = "mom";
:: > $username_main = "root";
:: > $password_main = "";
:: > $main = mysql_pconnect($hostname_main, $username_main, 
:: $password_main) 
:: > or die(mysql_error()); ?>
:: >
:: > Does anyone see why it's doing this to me? Please help!!
:: >
:: > Thanks,
:: > Stephen
:: > http://www.melchior.us
:: > http://php.melchior.us
:: >
:: >
:: >
:: > --
:: > PHP General Mailing List (http://www.php.net/)
:: > To unsubscribe, visit: http://www.php.net/unsub.php
:: >
:: 
:: 
:: -- 
:: PHP General Mailing List (http://www.php.net/)
:: To unsubscribe, visit: http://www.php.net/unsub.php
:: 
:: 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to