| | |
Supplied argument is not a valid MySQL result resource
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jun 2005
Posts: 1
Reputation:
Solved Threads: 0
hi,
i write a code like this
$user_id = $hd_cookie['user_id'];
$user_password = $hd_cookie['auth'];
$sql = "SELECT * FROM hd_users WHERE user_id='$user_id' AND user_password='$user_password'";
$r_user = mysql_query($sql);
$num=mysql_num_rows($r_user); //line 24
it shows Warning
Warning: Supplied argument is not a valid MySQL result resource in c:\apache\htdocs\helpdeskfinal\includes\auth.php on line 24
when i print the sql statement and run the statement in MySql Window it gives the result.but from here it didn't give the result why?
i am using PHPTRIAD 2.1.1 version is this version supports mysql_num_rows????
please solve my problem
Thanks
Srinivas
i write a code like this
$user_id = $hd_cookie['user_id'];
$user_password = $hd_cookie['auth'];
$sql = "SELECT * FROM hd_users WHERE user_id='$user_id' AND user_password='$user_password'";
$r_user = mysql_query($sql);
$num=mysql_num_rows($r_user); //line 24
it shows Warning
Warning: Supplied argument is not a valid MySQL result resource in c:\apache\htdocs\helpdeskfinal\includes\auth.php on line 24
when i print the sql statement and run the statement in MySql Window it gives the result.but from here it didn't give the result why?
i am using PHPTRIAD 2.1.1 version is this version supports mysql_num_rows????
please solve my problem
Thanks
Srinivas
Debugging tip: You mention that you run the statement in MySql window, and it works, but did you actually copy & paste the statement as generated by your code? Right after you build the $sql variable, output it like so:
[php]
echo $sql;
exit();
[/php]
Then copy & paste that output in your MySql query windows and see if it works. You may find your problem.
[php]
echo $sql;
exit();
[/php]
Then copy & paste that output in your MySql query windows and see if it works. You may find your problem.
•
•
Join Date: Aug 2005
Posts: 1
Reputation:
Solved Threads: 1
I had exactly the same problem and I knew for certain I did spell the cellnames and tablename right.
I've found the solution. Simply put all the cellnames and tablename between ``. That's all!
[php]
$sql = "SELECT * FROM `hd_users` WHERE `user_id`='$user_id' AND `user_password`='$user_password'";
[/php]
If this doesn't work, first get the user_id and user_password out of the ``, only hd_users. If that doesn't work either, I don't it, for me it worked
grtz, Jero
I've found the solution. Simply put all the cellnames and tablename between ``. That's all!
[php]
$sql = "SELECT * FROM `hd_users` WHERE `user_id`='$user_id' AND `user_password`='$user_password'";
[/php]
If this doesn't work, first get the user_id and user_password out of the ``, only hd_users. If that doesn't work either, I don't it, for me it worked

grtz, Jero
•
•
Join Date: Aug 2007
Posts: 1
Reputation:
Solved Threads: 1
Thanks, this thread helped me figure out a problem I was having too.
In my case, the problem was a missing semicolon at the end of the SQL statement. Was this also the problem for the original poster, I wonder?
In other words, this:
should have been this:
In my case, the problem was a missing semicolon at the end of the SQL statement. Was this also the problem for the original poster, I wonder?
In other words, this:
MySQL Syntax (Toggle Plain Text)
...snip... AND user_password='$user_password'";
should have been this:
MySQL Syntax (Toggle Plain Text)
...snip... AND user_password='$user_password';";
Last edited by gregarious; Aug 18th, 2007 at 5:20 am. Reason: clarify with code example
•
•
Join Date: Feb 2009
Posts: 1
Reputation:
Solved Threads: 1
The gotcha for me was remembering to use the mysql_select_db() function. I use mysql_connect() and then mysql_select_db() before I do the mysql_query. Like this...
That did the trick for me.
<URL SNIPPED>
MySQL Syntax (Toggle Plain Text)
$sql_conn = mysql_connect($hostName, $dbuser, $dbpass); mysql_select_db($databaseName, $sql_conn); $sql = "select * from tablename;"; $rs = mysql_query($sql, $sql_conn);
That did the trick for me.
<URL SNIPPED>
Last edited by peter_budo; Feb 3rd, 2009 at 2:01 pm. Reason: Keep It On The Site - Do not manually post "fake" signatures in your posts. Instead, you may create a sitewide signature within the user control panel.
•
•
Join Date: Feb 2009
Posts: 1
Reputation:
Solved Threads: 0
The error caused by mysql_select_db not connected to the database.
Most of the time because you don't have the privilege to the database or your database in MySQL has no user set for it yet.
Here is how to check:
From your cpanel, go to MySQL Databases.
Check your User for the database that you use if it empty.
If its empty, you need to add from Add User To Database below.
If its not empty, match them with the one you set in your mysql_connect()
Most of the time because you don't have the privilege to the database or your database in MySQL has no user set for it yet.
Here is how to check:
From your cpanel, go to MySQL Databases.
Check your User for the database that you use if it empty.
If its empty, you need to add from Add User To Database below.
If its not empty, match them with the one you set in your mysql_connect()
![]() |
Similar Threads
- mysql_numrows(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- mysql_num_rows(): supplied argument is not a valid MySQL result resource in /user/690 (PHP)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
Other Threads in the MySQL Forum
- Previous Thread: Update Stmt - Update same record multiple times
- Next Thread: how to check table existince in a stored procedure using mysql
| Thread Tools | Search this Thread |
agplv3 alfresco api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





