Mysqli and BLOB binary database fields

This post exists to save you hours of research on the web. The following things may be true about you:

  • You recently transitioned from mysql PHP functions to mysqli functions (staying current)
  • You prefer procedural PHP over object-oriented PHP (functions and arrays are cooler than classes)
  • You are storing some data in a MySQL BLOB, MEDIUMBLOB, or LONGBLOB field, which is Binary

Continue reading

mysqli_result() function to match mysql_result()

As of PHP 5.5, the MySQL functions are deprecated and will be removed by PHP6. The recommendation is to switch to MySQLi functions, which conveniently offer both a procedural (my preference) and object-oriented structure. Luckily, it’s a rather easy transition to MySQLi as functions names and functions are nearly identical (just change mysql_ to mysqli_). The only exception to this is the mysql_result() function, which has no analog.

Quick review: mysql_result() is used to write less code when your database query is returning only a single row (LIMIT 1) and/or a single column.

$output = mysql_result($result,0);

Pretty simple and straightforward. To replicate this in MySQLi, the following function can be used:

function mysqli_result($res,$row=0,$col=0){ 
    $numrows = mysqli_num_rows($res); 
    if ($numrows && $row <= ($numrows-1) && $row >=0){
        $resrow = (is_numeric($col)) ? mysqli_fetch_row($res) : mysqli_fetch_assoc($res);
        if (isset($resrow[$col])){
            return $resrow[$col];
    return false;

It has one improvement over mysql_result(), which is you can choose to only include the resource and no row and/or column. It will just assume mysqli_result($resource,0,0).

EDITED Dec 19, 2014
Function updated to allow for the column to be referenced by field name as well as numerical offset.

Regular Expression Crossword – Fun Practice with RegEx

RegEx CrosswordAfter seeing the post on Slashdot about the Regular Expressions crossword, I was inspired. I also wanted a puzzle that was easier and more approachable for the beginners or intermittent RegEx users.

So, I found a great base puzzle generator (javascript) and after a few hours, some graph paper, and some tweaks to the code, I created a RegEx crossword puzzle for others to check out. If people enjoy it, let me know in the comments. I’m thinking of putting out a physical workbook of these for fun.

jQuery Mobile 1.3 Swipe to Reveal Panel with Demo

I wanted to make use of the new jQuery Mobile 1.3.0-beta1 feature called Panels, allowing you to overlay, push, or reveal a hidden panel of content on the left or right of the main window. This is most commonly used to provide extra navigation options. In my case, I wanted to show static content that is hyper relevant, but without crowding up the main window.

However, the docs recommend and demonstrate how to use a hyperlink to activate the panel, which is great in a header, footer, or in a button, but it seemed more natural to allow the user to swipe the screen either left or right to show the panel. Thus, I need to add the following code to the bottom of the page:

<script type='text/javascript'>
		$("#leftpanel").panel( "open");
		$("#rightpanel").panel( "open");

Continue reading

HTML5 and jQuery Mobile Shortcut and Tip Sheet

jQuery MobileI’ve been exploring jQuery Mobile lately and consequently, HTML5 and mobile HTML design. What I’ve come to realize is that the framework is incredibly powerful and looks fantastic! I first looked at it almost 2 years ago and was overwhelmed, so either it has gotten that much better, or I have. Either way, I’m incredibly satisfied.
Continue reading

Quick RSS Feed Access with Browser Bar Icon

Back in early versions of Firefox, a small icon was visible on the browser bar if the webpage you visited listed available RSS feeds in the source HTML:

Some time in the last few years, this has disappeared. Luckily, with the assistance of extension and add-on developers, this option is available for both Firefox and Chrome!

After installing either browser plugin, an icon will appear if the webpage includes HTML like the following:

<link rel="alternate" type="application/rss+xml" title="Mario Lurig RSS" href=""/>

You can test it out by visiting this website after installing the extension/add-on.

Slowpreneur: The Patient Startup Idea

Slowpreneur <noun>:

  1. A person who organizes and operates a new business or businesses with a patient approach to profits and growth while taking a measured financial risk.
  2. A person who begins a new business or businesses as a side project until it becomes established, thus before operating the business in a full time capacity.

I stumbled upon this word by accident. I was sitting on the plane from Charlotte, NC to Orlando, FL and found myself sitting next to a psychologist, Tracy, reading some startup book on her tablet. We had been talking for the first third of the flight, but were currently on a break to do some reading. She nudges me and points to a word in the book: solopreneur. She says, “Ha, slowpreneur, that’s kind of like you!” I smile, read the word on the digital page, and reply kindly, “That says solopreneur.” Her embarrassment was palpable, so I quickly interjected, “But I do like the idea of a slowpreneur! I’m writing it down.”

I checked Google when we landed and, as of writing this article, when you search for slowpreneur Google suggests (and displays) the results for solopreneur. If you force it to use slowpreneur, there are a total of 3 results!
slowpreneur google search results 2012-08-30

Mind. Blown.

Is this really a phrase I could coin? Alright, I’m doing it (I’ve already bought the domain)! In this startup world of big money, explosive growth, the quick buck, and the desire to make a million dollars in a year (165,000,000 results), I want to do something different.

Slowpreneur Creed

I want to be patient. I want to grow within my means. I don’t want to incur debt. I will hold back the charging bull. I will continue to live my life. I will learn every day. I will let go of the reins when it’s ready. I will not be greedy. I will succeed.

So here’s to the slowpreneurs [raises glass in the air], who adventure into business with a slower pace, a balanced life, and the patience to see it through. Cheers.