Last night I ran into the crazy problem that a mysql result set contained rows (confirmed with mysql_num_rows) but I wasn’t able to fetch the rows in mysql_fetch_array while loop construction. I managed to create a workaround but I posted a note on the mysql_fetch_array page asking for an explanation. The note got rejected so I figured I could use my own blog in the search for an answer.

Here is the note;

I hope someone can help me with this question.

I have 2 code snippets. The first works, the second doesn’t. I would prefer using the second code snippet because it seems cleaner. What’s wrong with the second code snippet?

This works;

$results = mysql_query("SELECT DISTINCT(col) FROM table WHERE col!='' ORDER BY RAND()");
for( $i = 0; $i < mysql_num_rows( $results ); $i++ )
// do something with mysql_result($results,$i,0);

This doesn’t work;

$results = mysql_query("SELECT DISTINCT(col) FROM table WHERE col!='' ORDER BY RAND()");

 while($result = mysql_fetch_array($results))
 //do something with $result

I’m writing a web application that allows it’s users (among other things) to upload their company logos. PHP script is used to take the user provided jpgs/pngs and present them uniformly in a webpage. I ran into the problem that rescaled png images had their transparent regions turned black.

Here’s the solution I found;


Although the last step effectively overwrites all the pixels in your image, step 2 and 3 seem to be absolutely necessary to allow transparency inside your png image.

One more word of advice; use imagecopyresampled instead of imagecopyresized.


Resampled "Dutch Design Award"

Resampled "Dutch Design Award"


Resized "Dutch Design Award"

Resized "Dutch Design Award"

Make Up Your Mind!

Originally uploaded by Theo Lagendijk

This commercial is about ….
A) a laptop with “Windows 7 Home Premium”
B) a laptop with “Windows Vista Home Premium”

I just had a weird unexpected exception thrown by the Flex 3.4 compiler on an existing ActionScript 3.0 project that always compiled without a problem.

exception during transcoding:
Unexpected exception encountered while reading font file 'F.ttf'
unable to build font 'F'
Unable to transcode assets/F.ttf

Luckily I found solution via Google. ¬†Thanks Crazy Flexer “pixelfreak” adding -managers flash.fonts.AFEFontManager as an additional compiler argument fixed the build process.

Hope this blog post helps people that encounter the same issue.