Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-14-2006, 11:51 AM   PM User | #1
i4VisualMedia
New to the CF scene

 
Join Date: Dec 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
i4VisualMedia is an unknown quantity at this point
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

Hi guys,
I am fairly new to PHP and mySQL and am still learning the ropes.

I am getting the following error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/i4visua/public_html/cmsadmin/editmembers.php on line 84

the purpose of the script is to show the just the names of all the companies in the database using a loop.

My code is as follows:
PHP Code:
82    $query "SELECT * FROM 'members'";
83    $result mysql_query($query);
84    $num_results mysql_num_rows($result);
85    
86    
for ($i=0$i <$num_results$i++)
87    {
88    $row mysql_fetch_array($result);
89    echo '<br /> ';
90    echo stripslashed($row['company']);
91    
Any help would be much appriciated

Regards
Pete
i4VisualMedia is offline   Reply With Quote
Old 12-14-2006, 12:20 PM   PM User | #2
MRMAN
Regular Coder

 
Join Date: Jan 2006
Location: Preston, Lancashire, England
Posts: 285
Thanks: 0
Thanked 0 Times in 0 Posts
MRMAN is an unknown quantity at this point
instead of using the mysql_num_rows you can do it like this


PHP Code:
$result mysql_query($query);

while(
$data mysql_fetch_array($result))
{
print 
$data["company"];

but i think the problem is the quotes round the table name,

to see if there is a error do this

PHP Code:
$result mysql_query($query) or die(mysql_error()); 
MRMAN is offline   Reply With Quote
Old 12-14-2006, 01:13 PM   PM User | #3
i4VisualMedia
New to the CF scene

 
Join Date: Dec 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
i4VisualMedia is an unknown quantity at this point
thankyou very much.
I have one more question, I am trying to pass a varible (namely the ID of the database entry) between two pages using the following:

PHP Code:
$output "<a href='memberedit?id=".$row['id']."'>Edit</a>";
echo 
$output
When the link is clicked, I am being taken to the address:
www.mydomain.com/memberedit?id=
note the missing ID.
Can anybody help?
incase you need it, my query is as follows:
PHP Code:
$query "SELECT ID,company FROM `members`"
Cheers guys
Pete
i4VisualMedia is offline   Reply With Quote
Old 12-14-2006, 03:25 PM   PM User | #4
MRMAN
Regular Coder

 
Join Date: Jan 2006
Location: Preston, Lancashire, England
Posts: 285
Thanks: 0
Thanked 0 Times in 0 Posts
MRMAN is an unknown quantity at this point
SELECT ID

$row['id']

id is not the same as ID

it should be $row['ID']
MRMAN is offline   Reply With Quote
Old 12-14-2006, 03:37 PM   PM User | #5
Tyree
Regular Coder

 
Tyree's Avatar
 
Join Date: Sep 2003
Posts: 254
Thanks: 0
Thanked 0 Times in 0 Posts
Tyree is on a distinguished road
Man, that seems familiar! Oh yeah, it's because the same exact thing is in your other thread.

Hope you got it straight, bro!
__________________
Matt Tyree
TyreeOnline
If I didn't just "make it worse," show me some love! Hit me with the rep points! :) (The white scales icon on the left)
Tyree is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:13 AM.


Advertisement
Log in to turn off these ads.