473,583 Members | 3,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with mysqli stmt and multi queris.

I've some function:
function show($id) {
$title = $text = $date = $nick = NULL;
$stmt = $this->base->stmt_init();
$stmt->prepare("SELEC T title,text,date time,nick FROM posts LEFT JOIN authors ON authors.id=post s.id WHERE posts.id=?");
$stmt->bind_param('i' , $id);
$stmt->bind_result($t itle, $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("SELEC T 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($t ag);
$stmt->execute();
$names = array();
while($stmt->fetch()) {
array_push($nam es, $tag);
}
return $id;
}
It's shows:

Warning: mysqli_stmt::bi nd_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::bi nd_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
1 3004
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("SELEC T title,text,date time,nick FROM posts LEFT JOIN authors ON authors.id=post s.id WHERE posts.id=?");
$stmt->bind_param('i' , $id);
$stmt->bind_result($t itle, $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("SELEC T 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($t ag);
$stmt->execute();
$names = array();
while($stmt->fetch()) {
array_push($nam es, $tag);
}
return $id;
}
It's shows:

Warning: mysqli_stmt::bi nd_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::bi nd_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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1869
by: Nedelcho Stanev | last post by:
Hello All, I have strange problem with libodbc++ ( 0.2.3 or 0.2.2 ). i'm using mysql-4.0.14 , MyODBC-3.51.06 and unixODBC-2.2.6 configured with following options 1.MySQL ../configure --prefix=/usr/local/test --with-openssl --with-mysqld-user=root --enable-thread-safe-client --with-pthread --enable-shared
26
4675
by: Dodger | last post by:
Okay, background... yes, I am another of those evil, spurned, damnable Perl mongers, but I'm not trying to start a flamewar, I'm juust tryung to understand something... I can write a script in Perl like so, and it's pretty to me (and the using of the heredocs I think does defend perl against many arguments withthe HTML being all escaped and...
0
1364
by: ojorus | last post by:
Hi; I am using the mysqli-extension on all my database queries. Everything worked just fine when I used MySQL 4, but when the database was upgraded to MySQL 5 (5.0.22), I got a strange error. Here is an example: function example(){ global $table, $mysqli; $min = 2; $stmt = mysqli_prepare($mysqli, "SELECT SUM(Id) FROM $table WHERE
2
2751
by: Curtis | last post by:
Hello everyone: Recently, I decided to upgrade to PHP 5.2.0. I have C:\php5 in the Windows XP PATH, so upgrading is quite painless; just unzip new release, and restart Apache! Usually it goes off without a hitch, but I noticed that phpMyAdmin was not able to utilize the MySQLi library (which was working with my last 5.1.x release). As I was...
13
3703
by: Schmidty | last post by:
If you do a page reload with $_SERVER will your program lose a mysqli connection upon the reload of the page? Would this code work? I need to know how to carry over a connection between methods as I am new to OOP? Thanks... Example; ======================================== <?php // webpage $newsignon = new newuser(); logon();
1
3810
by: eholz1 | last post by:
Hello PHP Group, Is there any advantages (or disadvantages) in using mysqli instead of mysql (querys, connections to database, etc). I am currently using mysql_connect, and things like this: $result = @mysql_query("SELECT * FROM images3 WHERE id=" . $img . " AND p=" .$p. ""); to access my database. I see that some people are using the
1
1444
by: jesmi | last post by:
hi i got problem in inserting the date into the database. my requirement is that when i choose a date ie from :2007-01-01 & to :2007-12-01 then all the dates starting from 2007-02-01 upto 2007-12-01 should be inserted. while inserting year,month and day should be incremented.i tried a lot and my code only increments the month. Following is my...
4
1845
by: sugapablo | last post by:
I have a website that I was moving from another server to mine for somebody. This website uses mysqli functions. mysqli extensions are installed on my Linux server, PHP is 5.1.6 and and MySQL is 4.1.22 (both higher than his server). All seems to work fine, but any statement that uses the bind (i.e. placing a ? in the sql statement, and...
10
3382
by: sugapablo | last post by:
Here's my code: <?php $mysqli = new mysqli("localhost", "****", "********", "***********"); $idNum = "1030"; $sql = "select id,email from users where id ?;"; $stmt = $mysqli->prepare($sql); $stmt->bind_param('s', $idNum);
0
7895
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8193
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5374
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3818
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3843
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.