Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 8th, 2005, 07:33 PM
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Warning: mysql_num_rows()...

Code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
I get that when trying to use the /textbook/ code for "auth_user.php". I don't get what the problem is there. It can connect to the database perfectly fine in the other scripts, but not this mission critical login page.
Any help would be appreciated.

 
Old July 11th, 2005, 05:29 AM
Authorized User
 
Join Date: Jul 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajuru Send a message via Yahoo to rajuru
Default

Hi mgway,

for using this function you need a successful query resource to mysql like
$sql=mysql_query("SELECT * from table");
$rows=mysql_num_rows($sql);
echo $rows

you can check if your query syntax is correct while quering to mysql like
if(!$sql=mysql_query("SELECT * from table")) die(mysql_error());

this will notify you what error occurs when you quering to mysql. for more help give your codes sample?



Best Regard:
Md. Zakir Hossain (Raju)
www.rubd.net
www.xenexbd.com
Cheap Hosting, Domain, Reseller
www.forum.rubd.net
 
Old July 11th, 2005, 07:04 PM
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
<? 
}
function auth_user($userid, $userpassword){
    global $default_dbname, $user_tablename;

    $link_id = db_connect($default_dbname);

    $query = "SELECT user FROM $user_tablename
        WHERE userid = '$userid' 
        AND userpassword = password('userpassword')";
    $result = mysql_query($query);

    if(!mysql_num_rows($result)){
        return NULL;
    }else{
        $query_data = mysql_fetch_row($result);
        return $query_data[1];
    }
}
?>

 
Old July 11th, 2005, 07:17 PM
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oi. Nevermind then.
I figured out my problem. I didn't define "$user_tablename" and didn't include a $ before "userpassword"
Thanks for your time. =)






Similar Threads
Thread Thread Starter Forum Replies Last Post
mailling list:mysql_num_rows(): supplied argument jamesz20 Beginning PHP 2 December 6th, 2006 11:45 AM
mysql_num_rows() => Giving Error? Cybot MySQL 4 September 12th, 2006 12:07 PM
Security Warning ggiibboo Access 0 January 3rd, 2006 03:11 AM
Warning error, please help! kscritch BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 December 12th, 2005 04:33 PM
Warning message NutzyNobs Beginning PHP 1 July 28th, 2005 02:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.