473,757 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysqli problem with stmt and binding parameters.

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 then binding variables to it)
does not work in my server, only his.

Two questions, comparing phpinfo() on both servers, I can't find any
differences that would cause this problem. Does anyone have any ideas
on where to look?

And two, does anyone know how I can echo the prepared sql statement so
I can see what the final product looks like that gets sent to MySQL?

Jul 30 '07 #1
4 1849
sugapablo wrote:
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 then binding variables to it)
does not work in my server, only his.
"Does not work" is pretty broad. What do you expect to happen? What
actually happens? What error messages do you get?
Two questions, comparing phpinfo() on both servers, I can't find any
differences that would cause this problem. Does anyone have any ideas
on where to look?

And two, does anyone know how I can echo the prepared sql statement so
I can see what the final product looks like that gets sent to MySQL?
No, prepared statements are resources and can't be echo'd.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 30 '07 #2
On Mon, 30 Jul 2007 09:13:15 -0700, sugapablo <su*******@hotm ail.comwrote:
>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).
How much higher is the MySQL - presumably just the minor version?
>All seems to work fine, but any statement that uses the bind (i.e.
placing a ? in the sql statement, and then binding variables to it)
does not work in my server, only his.
In what way does it not work? Errors? Blank pages? Flame pouring out the back
of the computer?

Usual drill: put error_reporting to maximum, make sure you're not suppressing
errors with "@".
>Two questions, comparing phpinfo() on both servers, I can't find any
differences that would cause this problem. Does anyone have any ideas
on where to look?

And two, does anyone know how I can echo the prepared sql statement so
I can see what the final product looks like that gets sent to MySQL?
If you're using mysqli, and you're expecting to see an SQL statement with the
values embedded and escaped into it, actually the statement with placeholders
/is/ the final product sent to MySQL - MySQL 4.x+ supports placeholders
natively.

If you were just after the SQL, then find the place where prepare() gets
called, and add some debugging there.

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 30 '07 #3
On Jul 30, 1:30 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
"Does not work" is pretty broad. What do you expect to happen? What
actually happens? What error messages do you get?
I wasn't sure at first, but I can now tell, based on what is being
returned that the the parameters being binded are blank.

So if the SQL statement was "SELECT * FROM table WHERE col = ?"

What would be passed to the server after trying to bind a string
variable would be "SELECT * FROM table WHERE col = ''"
Jul 30 '07 #4
sugapablo wrote:
On Jul 30, 1:30 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>"Does not work" is pretty broad. What do you expect to happen? What
actually happens? What error messages do you get?

I wasn't sure at first, but I can now tell, based on what is being
returned that the the parameters being binded are blank.

So if the SQL statement was "SELECT * FROM table WHERE col = ?"

What would be passed to the server after trying to bind a string
variable would be "SELECT * FROM table WHERE col = ''"

It could be a lot of things. But not seeing any code I wouldn't begin
to be able to tell you what the problem is.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 30 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3812
by: Tom D | last post by:
I'm rewriting a database interface that our company currently has. Currently it's using the Pear::DB interface, but we found that that was introducing a bit too much overhead. I'm rewriting the interface to use mysqli. Most of what the interface does is to simplify getting results in the form of arrays (ordered and associative). Most of the code using the interface used sql queries with placeholders and parameters. For that reason I'd...
1
2925
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
1
3009
by: Uzytkownik | last post by:
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' =>...
2
2515
by: James | last post by:
Hey everyone... I'm having an issue with a seemingly simple piece of PHP/MySQL I have a stored procedure in MySQL5 as such: SQL: -------------- DELIMITER $$; DROP PROCEDURE IF EXISTS `test`.`sp_returns_string`$$ CREATE PROCEDURE `test`.`sp_returns_string`(OUT vOutput varchar(32))
0
19287
by: IamtheEvster | last post by:
Hi All, I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am unable to call a MySQL stored procedure that returns output parameters using mysql, mysqli, or PDO. I'm having a hell of a time with it... The following comes from phpinfo(): PHP Version: 5.1.2 mysql Client API version: 5.0.18 mysqli Client API version: 5.0.18
26
4693
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 explicit returns and stuff -- which I can see... 'print "<p class=\"text\">stuff</p>\n";' is...
2
2734
by: ojorus | last post by:
Hi! Some questions regarding the mysqli-extension (php5) 1) Prepared statements: If I understand things right, prepared statements will give better performance if you make several similar querys. (where you only change the parameters) But what if you do only ONE query; will it then be usefull to use prepared statements? Can it actuelly give better performance NOT to use prepared statements in that case? 2) Are there any DISadvantages...
0
1369
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
3213
by: Michael | last post by:
Hi, I try to use mysqli object instead of standard mysql functions. Is it ok to create mysqli object within my class or schould I pass mysqli object to my object. The problem is, with code below I must call mysqli->connect() each time I call class methods. How do I create an connection for hole object, so methods can do queries without connect each time? Best Regards, Michael
0
9904
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9735
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8736
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6556
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5168
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.