Tuesday, February 15, 2011

how to rebuild PHP on CentOS or other RedHat derivatives

I was faced with the prospect of rebuilding the PHP interpreter on a server, to add support for GD.

Googling for info yielded this article with some good overview of the process.

After I downloaded the sources and started the configure process I was hit with a slew of errors related to the fact that there were missing some dependencies. Stuff like "xml2-config not found. Please check your libxml2 installation."

One cure for that seems to install the development version of those components, like so:

yum install component-devel 


For me googling the error messages pointed me, in order, to the following resources that helped me solve the issues, here, here, here and finally here.

Wednesday, February 09, 2011

how to work around the "Upload Aborted or Timed Out." errors in iTunes Connect

Lately I've been getting this error when trying to upload screen shots of some apps running on iPad.

It seems to happen for large files, over 1MB. One of my apps does magazine publishing, as such if we take shots of the app showing the cover of the magazine, those usually exceeds that limit and the upload fails.

One way to get around that is to save the large PNG files as smaller JPEG files, of lower quality. You can do that using a tool like Gimp. If you go below 1MB the issue disappears.

Wednesday, February 02, 2011

beware of mysqli_stmt_execute clogging your database connection

There are multiple advantages in using prepared statements with MySQL. Improved performance and escaping of parameters passed to queries, to prevent SQL injection attacks come first to mind.

However, you need to be careful with mysqli_stmt_execute, especially if you run queries that produce result sets. If for some reason (e.g. alternate code path taken due to some error) you don't fetch the content of the result set, and if you don't explicitly close the prepared statement, any new queries sent over the database connection associated with the prepared statement that has results pending will fail.

That is, until you fetch the results with mysqli_stmt_fetch, or close the statement with mysqli_stmt_close, you won't be able to reuse the database connection to issue new queries.

This is intuitive enough, albeit a bit surprising, as it behaves very different from the regular mysqli_query that uses non-prepared statements, which is not subject to such constrains.