By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,915 Members | 1,327 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,915 IT Pros & Developers. It's quick & easy.

Problem with mysqli stmt and multi queris.

P: n/a
I've some function:
function show($id) {
$title = $text = $date = $nick = NULL;
$stmt = $this->base->stmt_init();
$stmt->prepare("SELECT title,text,datetime,nick FROM posts LEFT JOIN authors ON authors.id=posts.id WHERE posts.id=?");
$stmt->bind_param('i', $id);
$stmt->bind_result($title, $text, $date, $nick);
$stmt->execute();
$stmt->fetch();
return array('title'=>$title, 'text'=>$text, 'date'=>$date, 'author'=>$nick, 'tags' => $this->tags->get($id));
}
Function use in last line:
function get($id) {
$tag = '';
$stmt = $this->base->stmt_init();
$stmt->prepare("SELECT tags.name FROM tags LEFT JOIN tags_names ON tags_names.id = tags.tag_id WHERE tags.post_id=?");
$stmt->bind_param('i', $id);
$stmt->bind_result($tag);
$stmt->execute();
$names = array();
while($stmt->fetch()) {
array_push($names, $tag);
}
return $id;
}
It's shows:

Warning: mysqli_stmt::bind_param() [function.bind-param]: Number of variables doesn't match number of parameters in prepared statement in /home/uzytkownik/workspace/blog/classes/tags.php on line 64

Warning: mysqli_stmt::bind_result() [function.bind-result]: Number of bind variables doesn't match number of fields in prepared statement. in /home/uzytkownik/workspace/blog/classes/tags.php on line 65
array(5) { ["title"]=> string(4) "Test" ["text"]=> string(4) "Test"
["date"]=> string(19) "2005-11-22 08:09:33" ["author"]=> string(10)
"uzytkownik" ["tags"]=> int(1) }

I've experimented with $stmt->: close, free/store_result, reset ect.

What's wrong?

Regards
Nov 25 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, 25 Nov 2005 20:36:49 +0100, Uzytkownik wrote:
I've some function:
function show($id) {
$title = $text = $date = $nick = NULL;
$stmt = $this->base->stmt_init();
$stmt->prepare("SELECT title,text,datetime,nick FROM posts LEFT JOIN authors ON authors.id=posts.id WHERE posts.id=?");
$stmt->bind_param('i', $id);
$stmt->bind_result($title, $text, $date, $nick);
$stmt->execute();
$stmt->fetch();
return array('title'=>$title, 'text'=>$text, 'date'=>$date, 'author'=>$nick, 'tags' => $this->tags->get($id));
}
Function use in last line:
function get($id) {
$tag = '';
$stmt = $this->base->stmt_init();
$stmt->prepare("SELECT tags.name FROM tags LEFT JOIN tags_names ON tags_names.id = tags.tag_id WHERE tags.post_id=?");
$stmt->bind_param('i', $id);
$stmt->bind_result($tag);
$stmt->execute();
$names = array();
while($stmt->fetch()) {
array_push($names, $tag);
}
return $id;
}
It's shows:

Warning: mysqli_stmt::bind_param() [function.bind-param]: Number of variables doesn't match number of parameters in prepared statement in /home/uzytkownik/workspace/blog/classes/tags.php on line 64

Warning: mysqli_stmt::bind_result() [function.bind-result]: Number of bind variables doesn't match number of fields in prepared statement. in /home/uzytkownik/workspace/blog/classes/tags.php on line 65
array(5) { ["title"]=> string(4) "Test" ["text"]=> string(4) "Test"
["date"]=> string(19) "2005-11-22 08:09:33" ["author"]=> string(10)
"uzytkownik" ["tags"]=> int(1) }

I've experimented with $stmt->: close, free/store_result, reset ect.

What's wrong?

Regards


Resolved after rewrite the code.

Regards
Nov 26 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.