You are here: Problem with mysqli stmt and multi queris. « PHP Programming Language « IT news, forums, messages
Problem with mysqli stmt and multi queris.

Posted by Uzytkownik on 11/25/05 21:36

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация