/    Sign up×
Community /Pin to ProfileBookmark

What am I doing wrong with this simple function? The code works above the <hr> tag, but I get a: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given… Error when using the function.

[code=php]
<?php

function database_query($query_name, $database_query){
global $dbc;
$query_name = mysqli_query($dbc, $database_query) or die(“Problem Querying “.mysqli_error($dbc));
return $query_name;
}

$comment_count = “SELECT * FROM comments WHERE photo_id = $image_id”;
$count_comments = mysqli_query($dbc, $comment_count) or die(“Problem”);
echo mysqli_num_rows($count_comments);

echo “<hr />”;

database_query($count_comments, $comment_count);
echo mysqli_num_rows($count_comments);

?>
[/code]

Thanks in advance
?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@Hooded_VillianauthorOct 31.2010 — Time for a cuppa coffee.

I got it sorted. Simple fix, just as I thought it might be.

[code=php]
$test = database_query($count_comments, $comment_count);
echo mysqli_num_rows($test);
[/code]

?
×

Success!

Help @Hooded_Villian 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...