/    Sign up×
Community /Pin to ProfileBookmark

count in mysql – error

Following on from a previous thread, can anyone tell me what’s wrong with the code below:

[CODE]
$count_page = mysql_query(“SELECT page, COUNT (*) FROM user_record GROUP BY page”) or die (“SQL failed: ” . mysql_error());

$num_rowsCount = mysql_num_rows( $count_page );

for($i = 0; $i < $num_rowsCount; $i++)
{
$row = mysql_fetch_array($count_page);
$page = $row[‘page’];

print “<p><b>Page:</b> $page – <b>Hits:</b> $hits</p><br />”;
}
[/CODE]

‘page’ is a field that is counted, and user_record is the table. I get the following error: “SQL failed: You have an error in your SQL syntax near ‘(*) FROM user_record GROUP BY page’ at line 1”

Can anyone tell me what’s wrong with the syntax in the code here?

Thanks loads!! ?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@chazzyJan 23.2006 — take out the space, it's sensitive. Needs to be count(*)
Copy linkTweet thisAlerts:
@nickismeauthorJan 23.2006 — ARRR! Thanks so much! Can't believe that! Well, I'm unlikely to make that mistake again... You are fantastic Chazzy!!
×

Success!

Help @nickisme 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.19,
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,
)...