<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Dev Pages &#187; PHP</title>
	<atom:link href="http://www.n8williams.com/devblog/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.n8williams.com/devblog</link>
	<description>A knowledge base for simple (and beyond) web applications development</description>
	<lastBuildDate>Mon, 07 Nov 2011 08:31:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Prepared statement errors with PHP 5.3 and mysqli. call_user_func_array returns null. Type error?</title>
		<link>http://www.n8williams.com/devblog/php/prepared-statement-errors-with-php-5-3-and-mysqli-call_user_func_array-returns-null</link>
		<comments>http://www.n8williams.com/devblog/php/prepared-statement-errors-with-php-5-3-and-mysqli-call_user_func_array-returns-null#comments</comments>
		<pubDate>Thu, 10 Sep 2009 23:04:36 +0000</pubDate>
		<dc:creator>Nate Admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.n8williams.com/devblog/?p=144</guid>
		<description><![CDATA[Prepared statements using mysqli seems to be having issues with PHP 5.3. I kept getting null from a prepared statement command that worked fine in PHP 5.2, namely, the mysqli_stmt_bind_param
Null means that the array you passed didn&#8217;t match the function signature.
The following worked in php 5.2, but when I updated my Mac to Snow Leopard [...]]]></description>
			<content:encoded><![CDATA[<p>Prepared statements using mysqli seems to be having issues with PHP 5.3. I kept getting null from a prepared statement command that worked fine in PHP 5.2, namely, the mysqli_stmt_bind_param</p>
<p>Null means that the array you passed didn&#8217;t match the function signature.</p>
<p>The following worked in php 5.2, but when I updated my Mac to Snow Leopard (PHP 5.3 included) the following function stopped working</p>
<p><strong>call_user_func_array(&#8217;mysqli_stmt_bind_param&#8217;, array($stmt,&#8217;isis&#8217;,$args));</strong></p>
<p>I kept getting a null return value (note &#8211; different than false). See bottom of the following bug:  <a title="http://bugs.php.net/bug.php?id=47554&amp;edit=1" href="http://bugs.php.net/bug.php?id=47554&amp;edit=1" target="_blank">http://bugs.php.net/bug.php?id=47554&amp;edit=1</a></p>
<pre>"Returns the function result, NULL for an invalid callback, and FALSE
for all other errors."</pre>
<p>Toying with the array (translates to method signature of the callback function) passed to call_user_func_array was key. After much head banging (on desk) and much head banging (to music) I found that the following made my one specific test query work:</p>
<p><strong>call_user_func_array(&#8217;mysqli_stmt_bind_param&#8217;, array($stmt,&#8217;isis&#8217;,(int) $args[2],(string) $args[3],(int) $args[4],(string) $args[5]));</strong></p>
<p>I wonder if the library that mysqli uses is in c (so that mysqli_stmt_bind_param is eventually run at a level where typing needs to be determined), and is requiring typed values that the php is screwing up somewhere in the translation. Or on the mysqli level. And I wonder what other explanations there could be for this behavior.</p>
<p>Usually when code is this buggy it is a developer&#8217;s coding errors, but someday I hope to run into a bug that isn&#8217;t my fault. On second thought, finding a bug in your development language probably causes a lot more pain in trying to figure it out, so I&#8217;m not sure that would be much of an accomplishment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.n8williams.com/devblog/php/prepared-statement-errors-with-php-5-3-and-mysqli-call_user_func_array-returns-null/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

