Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 1
Name: tUNJI
Trades: 0
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
 
 
Register now for full access!
Old 03-21-2008, 11:51 PM Re: Help
NullPointer's Avatar
Will Code for Food

Posts: 2,783
Name: Matt
Location: Irvine, CA
Trades: 0
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); 
?>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





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



Page generated in 0.10190 seconds with 12 queries