473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

supplied argument is not a valid MySQL result resource

Before I get in trouble, I have searched extensively for this one, in the
PHP Docs, online etc.

I have a simple page:

<?php

$un="jim";
$pw="jim";
$db="localhost";

$link = mysql_connect($db,$un,$pw) or die("Could not connect: " .
mysql_error());

$sql2 = "SELECT * FROM eib.book ORDER BY bookid";
$op = mysql_query($sql2) ;
$num= mysql_numrows($op);

?>

When I run the page I keep getting this error:

Warning: mysql_numrows(): supplied argument is not a valid MySQL result
resource in C:\Program Files\Apache
Group\Apache2\htdocs\eib\php\itemadd2.php on line 34

I can't work out why?

The code looks fine to me.

Thanks

Jim
http://jimpix.co.uk


Jul 17 '05 #1
12 28445
I noticed that Message-ID: <br*********@titan.btinternet.com> from
Burton Figg contained the following:
$sql2 = "SELECT * FROM eib.book ORDER BY bookid";

What have you tried?
Does this query work in phpMyadmin?
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
Burton Figg wrote:
$sql2 = "SELECT * FROM eib.book ORDER BY bookid";
$op = mysql_query($sql2) ;
Try
$op = mysql_query($sql2) or die(mysql_error() . ' in ' . $sql2);

$num= mysql_numrows($op);
Shouldn't this be
$num = mysql_num_rows($op);
## _____________^__________

<quote src="http://pt2.php.net/manual/en/function.mysql-num-rows.php">
.. For downward compatibility mysql_numrows() can also be used.
This is deprecated however.
</quote>

When I run the page I keep getting this error:

Warning: mysql_numrows(): supplied argument is not a valid MySQL result
resource in C:\Program Files\Apache
Group\Apache2\htdocs\eib\php\itemadd2.php on line 34

I can't work out why?

The code looks fine to me.


It looks fine to me too :)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3
On Sat, 13 Dec 2003 21:42:29 +0000, Burton Figg wrote:
Before I get in trouble, I have searched extensively for this one, in the
PHP Docs, online etc.

I have a simple page:

<?php

$un="jim";
$pw="jim";
$db="localhost";

$link = mysql_connect($db,$un,$pw) or die("Could not connect: " .
mysql_error());

$sql2 = "SELECT * FROM eib.book ORDER BY bookid";
$op = mysql_query($sql2) ;
$num= mysql_numrows($op);

?>

When I run the page I keep getting this error:

Warning: mysql_numrows(): supplied argument is not a valid MySQL result
resource in C:\Program Files\Apache
Group\Apache2\htdocs\eib\php\itemadd2.php on line 34

I can't work out why?


mysql_select_db ;)

Jul 17 '05 #4
CJ Llewellyn wrote:
On Sat, 13 Dec 2003 21:42:29 +0000, Burton Figg wrote:
$sql2 = "SELECT * FROM eib.book ORDER BY bookid";
$op = mysql_query($sql2) ;
mysql_select_db ;)


No need for that.

select <fields> from database.table ...

You can specify the database in the query string; you can even (luckily)
mix different databases in the same query:

select u.name, x.quantity from db1.tb1 u, db2.tb2 x where u.id=x.id
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #5
On Sat, 13 Dec 2003 21:42:29 +0000 (UTC), "Burton Figg" <so*****@somewhere.com>
wrote:
Before I get in trouble, I have searched extensively for this one, in the
PHP Docs, online etc.
Really? The first few pages on Google web and groups searches come up with the
answer.
$link = mysql_connect($db,$un,$pw) or die("Could not connect: " .
mysql_error());
Here you correctly check for a possible error and stop the script going any
further.
$sql2 = "SELECT * FROM eib.book ORDER BY bookid";
$op = mysql_query($sql2) ;
Here you haven't bothered...
$num= mysql_numrows($op);
... resulting in you passing 'false' to mysql_numrows.
When I run the page I keep getting this error:
Warning, actually, you skipped passed the point at which you got an error
(mysql_query) because you didn't check for it
Warning: mysql_numrows(): supplied argument is not a valid MySQL result
resource in C:\Program Files\Apache
Group\Apache2\htdocs\eib\php\itemadd2.php on line 34


--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #6
On Sat, 13 Dec 2003 22:18:56 +0000, Pedro Graca wrote:
CJ Llewellyn wrote:
On Sat, 13 Dec 2003 21:42:29 +0000, Burton Figg wrote:
$sql2 = "SELECT * FROM eib.book ORDER BY bookid";
$op = mysql_query($sql2) ;

mysql_select_db ;)


No need for that.


Call me fussy, but I like to know I've got access to the database before I
try to use it :)

Jul 17 '05 #7
CJ Llewellyn wrote:
On Sat, 13 Dec 2003 22:18:56 +0000, Pedro Graca wrote:
CJ Llewellyn wrote:
mysql_select_db ;)
No need for that.
Call me fussy, but I like to know I've got access to the database before I
try to use it :)


fussy!

call me fussy too :)

mysql_select_db() or die();
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #8
"Burton Figg" a écrit le 13/12/2003 :
$sql2 = "SELECT * FROM eib.book ORDER BY bookid";
$op = mysql_query($sql2) ;
$num= mysql_numrows($op);


Are you sure a table name containing a dot is OK? I won't risk it
myself. Cause 'eib.book' can be translated by MySQL as field book form
table eib...

What does this select returns directly in phpmyadmin or equivalent ?

--
Have you read the manual?
http://www.php.net/manual/en/

Jul 17 '05 #9
Jedi121 <je*********@free.fr.Removethis> brightened my day with his
incisive wit when in news:mesnews.701d7d3c.cb834ecb.367.2689
@free.fr.Removethis he conjectured that:
"Burton Figg" a écrit le 13/12/2003 :
$sql2 = "SELECT * FROM eib.book ORDER BY bookid";
$op = mysql_query($sql2) ;
$num= mysql_numrows($op);


Are you sure a table name containing a dot is OK? I won't risk it
myself. Cause 'eib.book' can be translated by MySQL as field book form
table eib...


eh? The table name doesn't have a dot in it. He's merely using fully
qualified column names in form "tablename<dot>columnName" isn't he?
Jul 17 '05 #10
With total disregard for any kind of safety measures Walter Mitty
<mi******@yahoo.co.uk> leapt forth and uttered:
Jedi121 <je*********@free.fr.Removethis> brightened my day with
his incisive wit when in news:mesnews.701d7d3c.cb834ecb.367.2689
@free.fr.Removethis he conjectured that:
"Burton Figg" a écrit le 13/12/2003 :
$sql2 = "SELECT * FROM eib.book ORDER BY bookid";
$op = mysql_query($sql2) ;
$num= mysql_numrows($op);


Are you sure a table name containing a dot is OK? I won't risk
it myself. Cause 'eib.book' can be translated by MySQL as field
book form table eib...


eh? The table name doesn't have a dot in it. He's merely using
fully qualified column names in form "tablename<dot>columnName"
isn't he?


databasename<dot>tablename

--
There is no signature.....
Jul 17 '05 #11
Phil Roberts <ph*****@HOLYflatnetSHIT.net> brightened my day with his
incisive wit when in news:Xn*************************@206.127.4.22 he
conjectured that:
With total disregard for any kind of safety measures Walter Mitty
<mi******@yahoo.co.uk> leapt forth and uttered:
Jedi121 <je*********@free.fr.Removethis> brightened my day with
his incisive wit when in news:mesnews.701d7d3c.cb834ecb.367.2689
@free.fr.Removethis he conjectured that:
"Burton Figg" a écrit le 13/12/2003 :

$sql2 = "SELECT * FROM eib.book ORDER BY bookid";
$op = mysql_query($sql2) ;
$num= mysql_numrows($op);

Are you sure a table name containing a dot is OK? I won't risk
it myself. Cause 'eib.book' can be translated by MySQL as field
book form table eib...


eh? The table name doesn't have a dot in it. He's merely using
fully qualified column names in form "tablename<dot>columnName"
isn't he?


databasename<dot>tablename


woops. I meant this. sorry.
Jul 17 '05 #12
>> databasename<dot>tablename

Then he should check for MySQL version 'cause MySQL manual state :
"db_name.tbl_name.col_name = Column col_name from table tbl_name of the
database db_name. This form is available in MySQL Version 3.22 or
later."

--
Have you read the manual?
http://www.php.net/manual/en/

Jul 17 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: petemaxi | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\tockholes\includes\menu.inc.php on line 9 <div class="left"> <div class="menu">...
4
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the...
2
by: techjohnny | last post by:
Error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jplane/certcent/phpweb/quiz/index.php on line 20 Warning: mysql_num_rows(): supplied argument is...
1
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on...
11
by: Breana | last post by:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/breana/public_html/category.php on line 88 ------------------------------------------- It does this...
5
by: Mubs | last post by:
Hi, I 'am trying to connect my sql database with my webpage for users log in. i have got this script so far but i keep getting the following error message which i cannot figure out.. could any1...
4
by: fisherd | last post by:
When i run this code, i keep getting this message; Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\checklogin.php on line 26 i use this code to...
4
by: kalyanip14 | last post by:
Hi I am new to Php.I am trying to read My sql database data from table to php. I am getting this warning Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource ...
2
by: perhapscwk | last post by:
When I run my site from localhost, no error, but when I move it to webhosting, it show below error, why? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in...
2
by: macdalor | last post by:
Hi! I'm completely new to all dev and trying to put a website together using MySQLI and PHP; was running fine until I try to gather the DB content with the following script: <?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.