WebmasterForums.NET - Webmaster Forums & Directory
 

Go Back   WebmasterForums.NET - Webmaster Forums & Directory > Design and Development > Database - Mysql, SQL and Others
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Database - Mysql, SQL and Others MySQL, MSSQL, PGSQL, ms access and other database discussions.

Reply
 
Thread Tools Display Modes
Old 08-05-2006, 03:50 PM   #1
barney
Senior Member
 
barney's Avatar
 
Join Date: Jul 2006
Location: USA
Posts: 203
barney is on a distinguished road
Send a message via ICQ to barney Send a message via AIM to barney Send a message via Yahoo to barney
Default php constant in msql query

The below query throws an error: Warning: mysql_num_rows(): supplied
argument is not a valid MySQL result resource
I think it is unhappy about the constant in the LIMIT

What am I doing wrong?

SELECT
dms_user_logs.user_log_id,
dms_user_logs.user_log_date,
dms_users.dms_user_id,
dms_users.dms_user_first_name,
dms_users.dms_user_middle_name,
dms_users.dms_user_last_name
FROM
dms_user_logs,
dms_users
WHERE
dms_users.dms_user_id = dms_user_logs.dms_user_id
LIMIT
$start, PAGINATION_COUNT
ORDER BY
user_log_id DESC
barney is offline   Reply With Quote
Old 08-05-2006, 03:50 PM   #2
barney
Senior Member
 
barney's Avatar
 
Join Date: Jul 2006
Location: USA
Posts: 203
barney is on a distinguished road
Send a message via ICQ to barney Send a message via AIM to barney Send a message via Yahoo to barney
Default

So is the value a zero? Why not set its initial value to 1, so you get
a result set with some rows in it?
SELECT ... FROM ... LIMIT 0 returns no rows, hence mysql_num_rows() is
tossing an error.

That said, if there is any chance there will/could be an empty
recordset, you should always test for that before doing anything else
with the result.
barney is offline   Reply With Quote
Old 08-05-2006, 03:50 PM   #3
barney
Senior Member
 
barney's Avatar
 
Join Date: Jul 2006
Location: USA
Posts: 203
barney is on a distinguished road
Send a message via ICQ to barney Send a message via AIM to barney Send a message via Yahoo to barney
Default

The error Karl was getting was "not a valid MySQL result resource". A
record-set with zero rows is still a valid resource. The error message
means there was an error in the MySQL query itself.
Karl, since you are spanning databases, it may be that your ORDER BY
expression does not reference a database name, like all your other
values. Just a first guess...
barney is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 02:35 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
WebmasterForums.NET - Webmaster Forums & Directory