<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Mellertime's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 06 Oct 2008 05:44:14 GMT</pubDate>
    <description>DZone Snippets: Mellertime's Code Snippets</description>
    <item>
      <title>Maybe UnSerialize</title>
      <link>http://snippets.dzone.com/posts/show/1534</link>
      <description>Checks to see if a string is actually the serialized version of an array. If it is, we return an unserialized version. If not, return the original string. This way, we can just call our function on stored DB values and not worry about checking the results.&lt;br /&gt;&lt;br /&gt;This was snagged from the &lt;a href="http://wordpress.org"&gt;Wordpress&lt;/a&gt; 2.0 source. Yayyy for Open Source!&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;	function maybe_unserialize ( $original ) {&lt;br /&gt;		if ( false !== $gm = @ unserialize($original) )&lt;br /&gt;			return $gm;&lt;br /&gt;		else&lt;br /&gt;			return $original;&lt;br /&gt;	}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 20 Feb 2006 08:09:13 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1534</guid>
      <author>MellerTime (Chris Meller)</author>
    </item>
    <item>
      <title>Smart MySQL Escape Function</title>
      <link>http://snippets.dzone.com/posts/show/1533</link>
      <description>This function first checks to see if PHP is set to automagically quote stuff. If it is, we first strip pre-quoted stuff, then (assuming our text isn't numeric), we properly quote everything.&lt;br /&gt;&lt;br /&gt;A good bit of room for improvement here, but at the very least, you should hit this before inserting anything into your database.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;	// check to see if a string needs to be escaped for database input&lt;br /&gt;	function escapeit ( $text ) {&lt;br /&gt;		&lt;br /&gt;		if ( get_magic_quotes_gpc() ) {&lt;br /&gt;			$text = stripslashes($text);&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;		if ( !is_numeric($text) ) {&lt;br /&gt;			&lt;br /&gt;			$text = mysql_real_escape_string($text);&lt;br /&gt;			&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;		return $text;&lt;br /&gt;		&lt;br /&gt;	}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 20 Feb 2006 08:04:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1533</guid>
      <author>MellerTime (Chris Meller)</author>
    </item>
  </channel>
</rss>
