MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 22nd, 2004, 07:12 AM
Robbo Robbo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 14 Robbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
mysql_num_rows(): supplied argument is not a valid MySQL result resource

Im trying to get several pieces of data from several different tables and print it out into one nice table to be displayed for the user and i get getting the above message.
The code is

import_request_variables("gp","tt_");

$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");

$query = "SELECT ana_name, ana_familyname, shortsize_size, shirtsize_size, kit_year
FROM ana_tbl, shortsize_tbl, shirtsize_tbl, kit_tbl
WHERE ana_name = '$tt_ana_name'";
$result = mysql_query($query)
or die ("Could Not execute Query");

/* Display results in a table */
echo "<h1>Kit Details</h1>";
echo "<table cellspacing='15'>";
echo "<tr><td colspan='10'><hr></td></tr>";

$row = mysql_fetch_array($result);
$num = mysql_num_rows($row);


{
$i = "0";
while ($i < $num);
extract($row);
echo "<tr>\n
<td>$tt_ana_name</td>\n
<td>$tt_ana_familyname</td>\n
<td shortsize_size</td>\n
<td shirtsize_size</td>\n
<td kit_year</td>\n
</tr>\n";
echo "<tr><td colspan='5'><hr></td></tr>\n";
++$i;
}

echo "</table>\n";

?>
</body>
</html>

If anyone could help it would be much appreciated

Reply With Quote
  #2  
Old January 22nd, 2004, 07:29 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Try this:

$row = mysql_fetch_array($result);
$num = mysql_num_rows($result);


mysql_num_rows() expects the result set, not an array...

Refer to the PHP Manual: http://www.php.net/manual/en/functi...ql-num-rows.php

Reply With Quote
  #3  
Old January 22nd, 2004, 07:39 AM
Robbo Robbo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 14 Robbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Have tried that and its not throwing an error message any more but it is now timing out.
Am i going from with the while loop?

Reply With Quote
  #4  
Old January 22nd, 2004, 07:46 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
wait, what while loop?

you seem to have missed an important line... I see curly braces, but no loop... Oh wait, there's the while line...
this style of loop won't work in PHP

try this:

PHP Code:
 $num mysql_num_rows($row);

while (
$row mysql_fetch_array($result)) {
    
extract($row);
    echo 
"<tr>\n
    <td>$tt_ana_name</td>\n
    <td>$tt_ana_familyname</td>\n
    <td shortsize_size</td>\n
    <td shirtsize_size</td>\n
    <td kit_year</td>\n
    </tr>\n"
;
    echo 
"<tr><td colspan='5'><hr></td></tr>\n";


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > mysql_num_rows(): supplied argument is not a valid MySQL result resource


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway