/    Sign up×
Community /Pin to ProfileBookmark

correct sql argument

Hello!!

I am using the sql argument:

$total_results = mysql_result(mysql_query(“SELECT COUNT(*) as Num FROM reply”),0);

but I need the following :

$total_results = mysql_result(mysql_query(“SELECT COUNT(*) as Num FROM reply WHERE MEMBER_ID=’$MEMBER_ID'”),0);

It says is not a valid argument. How can I get a spefic number of results for this?

thanks for any help

to post a comment
PHP

12 Comments(s)

Copy linkTweet thisAlerts:
@JonaOct 20.2004 — [font=trebuchet ms]Specific [i]number of results[/i] or do you just want the second query to [i]work[/i]?[/font]
Copy linkTweet thisAlerts:
@sandro27authorOct 20.2004 — Hi

I want the second query to work.

You see, I am getting the total number of results in the first argument but I need to get only the results for a specific member.

Cheers
Copy linkTweet thisAlerts:
@JonaOct 20.2004 — [font=trebuchet ms]Are you sure you have all the field names correct and $MEMBER_ID is defined? What is the exact error you get from MySQL? Try...[/font]

[code=php]
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM reply WHERE MEMBER_ID = '$MEMBER_ID'"),0);
[/code]
Copy linkTweet thisAlerts:
@sandro27authorOct 20.2004 — The error says:

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in c:sitesmembersmember_account.php on line 36

That´s strange, because When I do $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM reply"),0); it works

Sandro27
Copy linkTweet thisAlerts:
@JonaOct 20.2004 — [font=trebuchet ms]Are you sure $MEMBER_ID is defined? Tell me if this works, even if it isn't what you want.[/font]

[code=php]
$total_results = mysql_result(mysql_query("SELECT * FROM reply WHERE MEMBER_ID = '$MEMBER_ID'"),0);
[/code]
Copy linkTweet thisAlerts:
@sandro27authorOct 20.2004 — It doesn´t work. The whole script as follows:

<?

include ("intro.php");

$id_member=$_GET['member_id'];

$sql2="select * from members where member_id='$id_member'";

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM reply"),0);

$busca=mysql_query($sql2,$conexao) or die(mysql_error());

while($lista=mysql_fetch_array($busca)){

?>

}

This script is working but not when I try:

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM reply WHERE member_id='$id_member'"),0);
Copy linkTweet thisAlerts:
@JonaOct 20.2004 — [font=trebuchet ms]Maybe PHP is being fussy about the quotes.[/font]

[code=php]
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM reply WHERE MEMBER_ID='".$MEMBER_ID."'"),0);
[/code]
Copy linkTweet thisAlerts:
@sandro27authorOct 20.2004 — Dear Jona,

Thanks for you help. I have tested the argument on mysql front and it showed me where I was wrong. The columm member_id has another name!! That´s why I coudn´t get the results I wanted.

I am new with this stuff so sometimes I oversee silly mistakes.

Cheers
Copy linkTweet thisAlerts:
@JonaOct 20.2004 — [font=trebuchet ms]lol. Well, thanks for wasting my time. ? Anyway, I'm glad you got it fixed. ? [/font]
Copy linkTweet thisAlerts:
@sandro27authorOct 20.2004 — I am sorry for your wasted time. I can send you a post card if you want.
Copy linkTweet thisAlerts:
@JonaOct 20.2004 — [i]Originally posted by sandro27 [/i]

[B]I am sorry for your wasted time. I can send you a post card if you want. [/B][/QUOTE]


[font=trebuchet ms]Haha, it's no problem, really.[/font]
Copy linkTweet thisAlerts:
@sandro27authorOct 20.2004 — uffff.(sigh of relief)
×

Success!

Help @sandro27 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...