|
Posted by Uzytkownik on 11/26/05 10:30
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
Navigation:
[Reply to this message]
|