Reply
Old 03-21-2008, 06:42 PM Help
Junior Talker

Posts: 1
Name: tUNJI
I am trying to display the number of acticve users in my table using the code below. but i geet this error

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/globalpe/public_html/tunji2.php on line 13.
<?php
$dbhost
= "";
$dbuser = "";
$dbpass = "";
$dbname = "";

$link = mysql_connect($dbhost, $dbuser, $dbpass)
or die(
mysql_error());
mysql_select_db($dbname)
or die(
mysql_error());

$sql = 'SELECT COUNT(`ID`) FROM `Profiles` WHERE `Status` = \'Active\'';
$results = mysql_result($sql, "0")
or die(
mysql_error());
print(
$results);
?>
tunjiaodu is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-21-2008, 11:51 PM Re: Help
NullPointer's Avatar
Will Code for Food

Posts: 544
Name: Matt
Location: Irvine, CA
mysql_result does not take a string as input, it takes the result of a mysql query. Your code is fine more or less but you simply forgot a step. Try this:

PHP Code:
<?php 
$dbhost 
""
$dbuser ""
$dbpass ""
$dbname ""

$link mysql_connect($dbhost$dbuser$dbpass
or die(
mysql_error()); 
mysql_select_db($dbname
or die(
mysql_error()); 

$sql 'SELECT COUNT(`ID`) FROM `Profiles` WHERE `Status` = \'Active\'';
$result mysql_query($sql); 
$results mysql_result($result"0"
or die(
mysql_error()); 
print(
$results); 
?>
__________________
http://tinsology.com/ - Under construction
NullPointer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help
 

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11807 seconds with 12 queries