Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2005-02-01, 10:26 AM
Junior Member
 
Join Date: Jan 2005
Location: London
Posts: 8
Dimerx
Default

I am getting very aggravated try to validate an authorised user, however I am not getting any errors but its not giving the correct response when either you have entered the correct user details or not. The varible of $nrows stays at "0"

Orginally the first part of the sql statement request worked (varible $nrows = "1") when I tried a verified a user before adding the user to the table now with this php statement it doesn't! What am I doing wrong?


// Check Username
include ("serverdtls.php");// Server Details
mysql_connect($host,$user,$spassword) or die(mysql_error());
mysql_select_db($database);
$sql = "SELECT userName FROM Auth_members WHERE userName = '$userName'";
$result = mysql_query($sql) or die(mysql_error());
$nrows = mysql_num_rows($result);
//echo "

$nrows</p>";
if (($nrows == "1" )|| ($nrows > "1")) {//Username Correct
mysql_connect($host,$user,$spassword) or die(mysql_error());
mysql_select_db($database);
$sql = "SELECT userName FROM Auth_members WHERE userName = '$userName' AND password = '$pwd'";
$result2 = mysql_query($sql) or die(mysql_error());
$nrows2 = mysql_num_rows($result2);
if (($nrows2 == "1" ) || ($nrows2 > "1")) {//Password Correct
//include (Memberlog.inc)
include( "http://www.mysite.com/xxx/....." );
exit();
}

else {
$msgno = "1";
include ("MemLogin.php" );
exit();
}
}
else if($nrows == "0") {
header ("Location: http://www.mysite/xxx2." );
exit;
}
?>
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2005-02-01, 05:40 PM
Junior Member
 
Join Date: Jan 2005
Posts: 21
gvwiberg
Default

Hi there!

if (($nrows2 == "1" ) || ($nrows2 > "1")) {//Password Correct
//code...

means THAT if $nrows ARE 1 OR LARGER THAN 1, then run code...

Is that what you want?

If this is the case you could type it like this:
Observe that I took away the " because you want to check numeric values...

if (($nrows2 >= 1 )) {
//code...
}


Another thing:

You have TWO controls of username and password, that doesn't seem neccesary...
You could only use the control where both username and password is checked like this:


mysql_connect($host,$user,$spassword) or die(mysql_error());
mysql_select_db($database);
$sql = "SELECT userName FROM Auth_members WHERE userName = '$userName' AND password = '$pwd'";

and your other code...

Hope this helps a bit...

/G
@varupiraten.se
Reply With Quote
  #3 (permalink)  
Old 2005-02-02, 07:21 AM
Junior Member
 
Join Date: Jan 2005
Location: London
Posts: 8
Dimerx
Default

Thank you for your assistance. I will amend my script , however, for some reason this may not resolve the problem I think I am having.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:34 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.