<?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>Thomas Hambach - Web engineer &#187; php</title>
	<atom:link href="http://www.rdlt.com/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.rdlt.com</link>
	<description>Web development, Web design &#38; Usability</description>
	<lastBuildDate>Wed, 16 Jun 2010 09:10:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Facebook Error Message: Requires valid next URL.</title>
		<link>http://www.rdlt.com/facebook-error-message-requires-valid-next-url.html</link>
		<comments>http://www.rdlt.com/facebook-error-message-requires-valid-next-url.html#comments</comments>
		<pubDate>Wed, 16 Jun 2010 09:10:48 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[facebook]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[api error]]></category>
		<category><![CDATA[invalid parameter]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=285</guid>
		<description><![CDATA[Let me start with asking you a few questions! Are you having issues with the Facebook API? Are you constantly getting the error message &#8220;API Error Code: 100 API Error Description: Invalid parameter Error Message: Requires valid next URL.&#8220;? Are you using the latest official Facebook PHP class? Are you redirecting using the PHP header() [...]]]></description>
			<content:encoded><![CDATA[<p>Let me start with asking you a few questions!</p>
<ol>
<li>Are you having issues with the Facebook API?</li>
<li>Are you constantly getting the error message &#8220;<em>API Error Code: 100 API Error Description: Invalid parameter Error Message: Requires valid next URL.</em>&#8220;?</li>
<li>Are you using the latest official Facebook PHP class?</li>
<li>Are you redirecting using the PHP <em>header()</em> function?</li>
</ol>
<p><a rel="lightbox" href="http://www.rdlt.com/wp-content/uploads/2010/06/facebookerror.png"><img class="alignnone size-medium wp-image-286" title="Facebook error" src="http://www.rdlt.com/wp-content/uploads/2010/06/facebookerror-300x119.png" alt="Facebook error" width="300" height="119" /></a></p>
<p>Well,  I might have a solution for you. When calling the function <em>getLoginUrl</em> in the Facebook PHP class, the function will return a HTML encoded string. When outputing this string to your browser, it is rendered/decoded by a browser and this will convert all &#8220;safe&#8221; charachters to their textual equivalent.  This makes that <em>&#8220;&amp;amp;&#8221;</em> becomes &#8220;<em>&amp;</em>&#8221; and <em>&#8220;%20&#8243;</em> becomes &#8221; &#8220;.</p>
<p>However, when using the <em>header()</em> function in PHP, this url will not be rendered/decoded and you are basically sending out a garbled request.</p>
<p><strong>Original</strong></p>
<pre><code class="php">getLoginUrl($params);
header('Location:' . $url);
</code></pre>
<p><strong>Solution:</strong></p>
<pre><code class="php">getLoginUrl($params);
$url = str_replace('&amp;','&amp;',urldecode($url));
header('Location:' . $url);
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/facebook-error-message-requires-valid-next-url.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress mysqli 2.9 Database Class Patch</title>
		<link>http://www.rdlt.com/wordpress-mysqli-2-9-database-class-patch.html</link>
		<comments>http://www.rdlt.com/wordpress-mysqli-2-9-database-class-patch.html#comments</comments>
		<pubDate>Wed, 30 Dec 2009 10:30:51 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[freebies]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=253</guid>
		<description><![CDATA[WordPress does not officialy support the mysqli drivers.  I needed my WordPress installation to use the mysqli class instead of the mysql ones. I&#8217;m sure there will be someone else out there with the same needs I decided to place the modified database class and the patch file online. Use whichever you prefer. Full: Download [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-thumbnail wp-image-256" title="wordpress-logo" src="http://www.rdlt.com/wp-content/uploads/2009/12/wordpress-logo-150x150.png" alt="wordpress-logo" width="150" height="150" />WordPress does not officialy support the <a href="http://be2.php.net/manual/en/class.mysqli.php" target="_blank">mysqli</a> drivers.  I needed my WordPress installation to use the mysqli class instead of the mysql ones. I&#8217;m sure there will be someone else out there with the same needs I decided to place the modified database class and the patch file online. Use whichever you prefer.</p>
<ul>
<li><strong>Full:</strong> <a href="http://www.rdlt.com/wp-content/uploads/2009/12/wp-db-2.9-class.zip" target="_blank">Download WordPress 2.9 mysqli database class</a></li>
<li><strong>Patch: </strong><a href="http://www.rdlt.com/wp-content/uploads/2009/12/wp-db-2.9-patch.zip" target="_blank">Download WordPress 2.9 mysqli database class</a></li>
</ul>
<p><span id="more-253"></span></p>
<h3>Patch contents</h3>
<pre><code>Index: wp-includes/wp-db.php
===================================================================
--- wp-includes/wp-db.php	(revision 19)
+++ wp-includes/wp-db.php	(working copy)
@@ -367,9 +367,12 @@
 			$this-&gt;collate = DB_COLLATE;

 		$this-&gt;dbuser = $dbuser;
+
+		// $this-&gt;dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true);
+		$this-&gt;dbh = new mysqli($dbhost, $dbuser, $dbpassword, $dbname); 

-		$this-&gt;dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true);
-		if (!$this-&gt;dbh) {
+		// if (!$this-&gt;dbh) {
+		if ($this-&gt;dbh-&gt;connect_error || mysqli_connect_error()) { // remember $mysqli-&gt;connect_error is broken in PHP &lt; 5.2.9
 			$this-&gt;bail(sprintf(/*WP_I18N_DB_CONN_ERROR*/"
 &lt;h1&gt;Error establishing a database connection&lt;/h1&gt;
 &lt;p&gt;This either means that the username and password information in your &lt;code&gt;wp-config.php&lt;/code&gt; file is incorrect or we can't contact the database server at &lt;code&gt;%s&lt;/code&gt;. This could mean your host's database server is down.&lt;/p&gt;
@@ -386,18 +389,21 @@
 		$this-&gt;ready = true;

 		if ( !empty($this-&gt;charset) ) {
+			$this-&gt;dbh-&gt;set_charset($this-&gt;charset);
+			$this-&gt;real_escape = true;
+			/*
 			if ( function_exists('mysql_set_charset') ) {
 				mysql_set_charset($this-&gt;charset, $this-&gt;dbh);
-				$this-&gt;real_escape = true;
 			} else {
 				$collation_query = "SET NAMES '{$this-&gt;charset}'";
 				if ( !empty($this-&gt;collate) )
 					$collation_query .= " COLLATE '{$this-&gt;collate}'";
 				$this-&gt;query($collation_query);
-			}
+			}*/
 		}

-		$this-&gt;select($dbname);
+		// selection of database with mysql happens when connecting
+		// $this-&gt;select($dbname);
 	}

 	/**
@@ -454,6 +460,9 @@
 	 * @return null Always null.
 	 */
 	function select($db) {
+
+		return true; // database selection happens in constructor when usng mysqli
+
 		if (!@mysql_select_db($db, $this-&gt;dbh)) {
 			$this-&gt;ready = false;
 			$this-&gt;bail(sprintf(/*WP_I18N_DB_SELECT_DB*/'
@@ -475,7 +484,7 @@

 	function _real_escape($string) {
 		if ( $this-&gt;dbh &#038;&#038; $this-&gt;real_escape )
-			return mysql_real_escape_string( $string, $this-&gt;dbh );
+			return $this-&gt;dbh-&gt;real_escape_string( $string );
 		else
 			return addslashes( $string );
 	}
@@ -579,7 +588,7 @@
 	function print_error($str = '') {
 		global $EZSQL_ERROR;

-		if (!$str) $str = mysql_error($this-&gt;dbh);
+		if (!$str) $str = $this-&gt;dbh-&gt;error;
 		$EZSQL_ERROR[] = array ('query' =&gt; $this-&gt;last_query, 'error_str' =&gt; $str);

 		if ( $this-&gt;suppress_errors )
@@ -703,39 +712,40 @@
 		if ( defined('SAVEQUERIES') &#038;&#038; SAVEQUERIES )
 			$this-&gt;timer_start();

-		$this-&gt;result = @mysql_query($query, $this-&gt;dbh);
+		$this-&gt;result = $this-&gt;dbh-&gt;query($query);
 		++$this-&gt;num_queries;

 		if ( defined('SAVEQUERIES') &#038;&#038; SAVEQUERIES )
 			$this-&gt;queries[] = array( $query, $this-&gt;timer_stop(), $this-&gt;get_caller() );

 		// If there is an error then take note of it..
-		if ( $this-&gt;last_error = mysql_error($this-&gt;dbh) ) {
+		if ( $this-&gt;last_error = $this-&gt;dbh-&gt;error) {
 			$this-&gt;print_error();
 			return false;
 		}

 		if ( preg_match("/^\\s*(insert|delete|update|replace|alter) /i",$query) ) {
-			$this-&gt;rows_affected = mysql_affected_rows($this-&gt;dbh);
+			$this-&gt;rows_affected = $this-&gt;db-&gt;affected_rows;
 			// Take note of the insert_id
 			if ( preg_match("/^\\s*(insert|replace) /i",$query) ) {
-				$this-&gt;insert_id = mysql_insert_id($this-&gt;dbh);
+				$this-&gt;insert_id = $this-&gt;db-&gt;insert_id;
 			}
 			// Return number of rows affected
 			$return_val = $this-&gt;rows_affected;
 		} else {
 			$i = 0;
-			while ($i &lt; @mysql_num_fields($this-&gt;result)) {
-				$this-&gt;col_info[$i] = @mysql_fetch_field($this-&gt;result);
+			while ($i &lt; $this-&gt;result-&gt;field_count) {
+				$this-&gt;col_info[$i] = @$this-&gt;result-&gt;fetch_field();
 				$i++;
 			}
 			$num_rows = 0;
-			while ( $row = @mysql_fetch_object($this-&gt;result) ) {
+			while ( $row = @$this-&gt;result-&gt;fetch_object() ) {
 				$this-&gt;last_result[$num_rows] = $row;
 				$num_rows++;
 			}

-			@mysql_free_result($this-&gt;result);
+			// no more need for freeing results, they ARE free! <img src='http://www.rdlt.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />
+			// @mysql_free_result($this-&gt;result);

 			// Log number of rows the query returned
 			$this-&gt;num_rows = $num_rows;
@@ -1138,4 +1148,5 @@
 	 */
 	$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
 }
+
 ?&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/wordpress-mysqli-2-9-database-class-patch.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>xdebug trace file parser</title>
		<link>http://www.rdlt.com/xdebug-trace-file-parser.html</link>
		<comments>http://www.rdlt.com/xdebug-trace-file-parser.html#comments</comments>
		<pubDate>Wed, 18 Nov 2009 18:02:10 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[freebies]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[xdebug]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=241</guid>
		<description><![CDATA[When I am trying to optimize my PHP code, one of my prefered tools is xdebug. It provides me with excellent error messages, outputs code tracing files &#38; insight into memory usage. By using kcachegrind or webgrind &#8211; wincachegrind crashes *all* the time &#8211; to parse the cachegrind files created by xdebug, you get a [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-243" title="xdebug_trace_preview" src="http://www.rdlt.com/wp-content/uploads/2009/11/xdebug_trace_preview-300x199.png" alt="xdebug_trace_preview" width="300" height="199" /></p>
<p>When I am trying to optimize my PHP code, one of my prefered tools is <a href="http://www.xdebug.org" target="_blank">xdebug</a>. It provides me with excellent error messages, outputs code tracing files &amp; insight into memory usage.</p>
<p>By using kcachegrind or <a href="http://code.google.com/p/webgrind/" target="_blank">webgrind</a> &#8211; wincachegrind crashes *all* the time &#8211; to parse the cachegrind files created by xdebug, you get a good idea of what your code is doing most of the time. It&#8217;ll show you which functions are called, by who, which arguments are passed and tons more. <a href="http://www.xdebug.org" target="_blank">Check it out. </a></p>
<p>Now, there was one small thing I couldn&#8217;t find anywhere. A program to parse the trace files that xdebug generates. True, xdebug already provides the option to output this information into HTML, but it&#8217;s not really what I was looking for. <strong>I want to get quick information in the blink of an eye! </strong>That&#8217;s why I have created my own trace file parser, based on PHP of course.</p>
<h3><span id="more-241"></span>What is it?</h3>
<p>This <strong>xdebug trace parser</strong> will show you, for each function:</p>
<ul>
<li>How much memory was used on entry &amp; exit</li>
<li>How much time it costed to execute the function</li>
<li>The exact line the function was called from plus insight into the code by clicking a link</li>
<li>Whether the function is native PHP or not</li>
</ul>
<p><a rel="lightbox" href="http://www.rdlt.com/wp-content/uploads/2009/11/xdebug_trace_warning.png"><img class="alignnone size-medium wp-image-245" title="xdebug_trace_warning" src="http://www.rdlt.com/wp-content/uploads/2009/11/xdebug_trace_warning-300x54.png" alt="xdebug_trace_warning" width="300" height="54" /></a></p>
<p>It also has a basic &#8220;alerting&#8221; feature, which will allow you to set triggers on memory usage &amp; execution time. You can specifiy that if the memory or time jump is greater than a certain value, to show this in the output.</p>
<h3>Requirements</h3>
<p>It should be obvious that you&#8217;ll need to install and configure xdebug for your PHP installation. See <a href="http://www.xdebug.org" target="_blank">http://www.xdebug.org</a> for more information on this.</p>
<p>Your xdebug config should look a bit like this, don&#8217;t forget to update your paths <img src='http://www.rdlt.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<pre><code>[XDebug]
;; Only Zend OR (!) XDebug
zend_extension_ts="\php\ext\php_xdebug-2.0.4-5.2.8.dll"
xdebug.auto_trace=1
xdebug.trace_format=1
xdebug.profiler_append=1
xdebug.profiler_enable=1
xdebug.profiler_enable_trigger=0
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.trace_output_dir="D:\webserver\xdebug"
xdebug.trace_output_name= %t.trace
xdebug.profiler_output_name = %s.%t.profile
xdebug.profiler_output_dir="D:\webserver\xdebug"
</code></pre>
<h3>Download</h3>
<p>Now, give it a try and <a href="../wp-content/uploads/2009/11/trace.zip" target="_blank">downlod the xdebug trace file parser here!</a></p>
<h3>Usage</h3>
<p>Once you&#8217;ve downloaded the trace file parser, extract it to a directory inside your website root and surf to the URL. If everything works out you should be able to select trace files onceyou have ran an other PHP script on your server. This trace file parser will *not* show it&#8217;s own traces because that would make things even more complicated!</p>
<p>Comments &amp; suggestions! <img src='http://www.rdlt.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/xdebug-trace-file-parser.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>xampp mysqli crashes apache</title>
		<link>http://www.rdlt.com/xampp-mysqli-crashes-apache.html</link>
		<comments>http://www.rdlt.com/xampp-mysqli-crashes-apache.html#comments</comments>
		<pubDate>Wed, 18 Nov 2009 14:46:09 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=238</guid>
		<description><![CDATA[Is your XAMPP installation crashing apache when using the mysqli PHP functions on windows? The apache logs are not telling anything even when you have debug mode enabled? Are you getting something like &#8220;Faulting application apache.exe, version 2.2.11.0, faulting module ntdll.dll&#8221; or &#8220;Faulting application apache.exe, version 2.2.11.0, faulting module MSVCR71.dll.&#8221; ? Really? Sure? Well here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Is your <strong>XAMPP </strong>installation crashing apache when using the mysqli PHP functions on windows? The apache logs are not telling anything even when you have debug mode enabled? Are you getting something like &#8220;<strong>Faulting application apache.exe, version 2.2.11.0, faulting module ntdll.dll</strong>&#8221; or &#8220;<strong>Faulting application apache.exe, version 2.2.11.0, faulting module MSVCR71.dll.</strong>&#8221; ?</p>
<p>Really? Sure? Well here&#8217;s your solution&#8230;</p>
<p>Download the most recent version of <strong>php_mysqli.dll </strong>and place it in <strong>&lt;yourxampdir&gt;\php\ext</strong> directory.You might want to take a backup of the file you&#8217;re replacing in case it doesn&#8217;t work&#8230;</p>
<p>You can <a href="http://www.rdlt.com/wp-content/uploads/2009/11/php_mysqli.zip">download the php_mysqli.dll righ here</a> or you&#8217;ll have to find a recent version for your PHP version yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/xampp-mysqli-crashes-apache.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple memcache instances/servers on windows</title>
		<link>http://www.rdlt.com/multiple-memcache-instancesservers-on-windows.html</link>
		<comments>http://www.rdlt.com/multiple-memcache-instancesservers-on-windows.html#comments</comments>
		<pubDate>Mon, 11 May 2009 10:50:55 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[memcache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=164</guid>
		<description><![CDATA[Setting up memcache on windows is like taking candy from a baby. You can find all the information and the binaries for memcache at http://jehiah.cz/projects/memcached-win32/ . Note that these binaries will also work for x64 based windows. A little trickier is to set up multiple instances of memcached on your windows machine. Basically you have [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up memcache on windows is like taking candy from a baby. You can find all the information and the binaries for memcache at <a href="http://jehiah.cz/projects/memcached-win32/" target="_blank">http://jehiah.cz/projects/memcached-win32/</a> . Note that these binaries will also work for x64 based windows.</p>
<p>A little trickier is to set up multiple instances of memcached on your windows machine. Basically you have to install the same memcache executable as many times as you want servers.</p>
<p>Installing memcache from the command line is simple:</p>
<pre><code>sc create  "Memcached11211" binPath= "E:\webserver\memcached.exe -d runservice -p 11211 -m 128"  DisplayName= "Memcached11211" start= auto</code></pre>
<p>Thus, for multiple instances this will be:</p>
<pre><code>sc create  "Memcached11211" binPath= "E:\webserver\memcached.exe -d runservice -p 11211 -m 15"  DisplayName= "Memcached11211" start= auto
sc create  "Memcached11212" binPath= "E:\webserver\memcached.exe -d runservice -p 11212 -m 15"  DisplayName= "Memcached11212" start= auto
sc create  "Memcached11213" binPath= "E:\webserver\memcached.exe -d runservice -p 11213 -m 15"  DisplayName= "Memcached11213" start= auto
sc create  "Memcached11214" binPath= "E:\webserver\memcached.exe -d runservice -p 11214 -m 15"  DisplayName= "Memcached11214" start= auto
sc create  "Memcached11215" binPath= "E:\webserver\memcached.exe -d runservice -p 11215 -m 15"  DisplayName= "Memcached11215" start= auto
sc create  "Memcached11216" binPath= "E:\webserver\memcached.exe -d runservice -p 11216 -m 15"  DisplayName= "Memcached11216" start= auto
sc create  "Memcached11217" binPath= "E:\webserver\memcached.exe -d runservice -p 11217 -m 15"  DisplayName= "Memcached11217" start= auto
sc create  "Memcached11218" binPath= "E:\webserver\memcached.exe -d runservice -p 11218 -m 15"  DisplayName= "Memcached11218" start= auto
sc create  "Memcached11219" binPath= "E:\webserver\memcached.exe -d runservice -p 11219 -m 15"  DisplayName= "Memcached11219" start= auto
sc create  "Memcached11220" binPath= "E:\webserver\memcached.exe -d runservice -p 11220 -m 15"  DisplayName= "Memcached11220" start= auto
sc create  "Memcached11221" binPath= "E:\webserver\memcached.exe -d runservice -p 11221 -m 15"  DisplayName= "Memcached11221" start= auto
sc create  "Memcached11222" binPath= "E:\webserver\memcached.exe -d runservice -p 11222 -m 15"  DisplayName= "Memcached11222" start= auto</code></pre>
<p>As you can see from the example above, you have to choose a different port for each memcache instance you are running.</p>
<div style="font-size:10px">references: <a href="http://www.nabble.com/Multi-instance-on-Win2K3--td18223078.html" target="_blank">http://www.nabble.com/Multi-instance-on-Win2K3&#8211;td18223078.html</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/multiple-memcache-instancesservers-on-windows.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>memcache_connect() [function.memcache-connect]: Can&#8217;t connect to localhost:11211</title>
		<link>http://www.rdlt.com/memcache_connect-functionmemcache-connect-cant-connect-to-localhost11211.html</link>
		<comments>http://www.rdlt.com/memcache_connect-functionmemcache-connect-cant-connect-to-localhost11211.html#comments</comments>
		<pubDate>Mon, 11 May 2009 10:34:06 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[memcache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=161</guid>
		<description><![CDATA[Encountered this error? It could be as simple as switching the host from localhost to 127.0.0.1 before: &#60;?php $memcache_obj = memcache_connect('localhost', 11211); after: &#60;?php $memcache_obj = memcache_connect('127.0.0.1', 11211);]]></description>
			<content:encoded><![CDATA[<p>Encountered this error? It could be as simple as switching the<strong> </strong>host from <strong>localhost </strong>to <strong>127.0.0.1</strong></p>
<p><strong>before:</strong></p>
<pre><code class="php">&lt;?php
$memcache_obj = memcache_connect('localhost', 11211);</code></pre>
<p><strong>after:</strong></p>
<pre><code class="php">&lt;?php
$memcache_obj = memcache_connect('127.0.0.1', 11211);</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/memcache_connect-functionmemcache-connect-cant-connect-to-localhost11211.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Get monday, sunday, last monday &amp; last sunday</title>
		<link>http://www.rdlt.com/php-get-monday-sunday-last-monday-last-sunday.html</link>
		<comments>http://www.rdlt.com/php-get-monday-sunday-last-monday-last-sunday.html#comments</comments>
		<pubDate>Fri, 22 Aug 2008 11:37:32 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/?p=115</guid>
		<description><![CDATA[A function I&#8217;ve put togheter for a work-related project to get date of monday, sunday, last monday &#38; last sunday.. Might add in next monday and sunday later. /** * Get Mondays and Sundays * * Get monday, sunday, last monday &#38; last sunday * Example usage: * // to retreive the dates using today [...]]]></description>
			<content:encoded><![CDATA[<p>A function I&#8217;ve put togheter for a work-related project to get date of monday, sunday, last monday &amp; last sunday.. Might add in next monday and sunday later.</p>
<pre><code class="php">
/**
* Get Mondays and Sundays
*
* Get monday, sunday, last monday &amp; last sunday
* Example usage:
* // to retreive the dates using today as starting point
* $mondaysAndSundays = getMondaysAndSundays();
* // to retreive the dates using a custom date as starting point
* $mondaysAndSundays = getMondaysAndSundays('1987-04-14');
*
* @param date $offset Provide a date from where to calculate from in strtotime() translatable format. If none is given, today's date will be used.
*
* @return array
*
*/
function getMondaysAndSundays($offset=false)
{

if(!$offset) $offset = strtotime(date('Y-m-d'));
else $offset = strtotime($offset);

// this week
if(date('w',$offset) == 1)
{
$mas['monday'] = date('Y-m-d',$offset);
}
else
{
$mas['monday'] = date('Y-m-d',strtotime("last Monday",$offset));
}

if(date('w',$offset) == 6)
{
$mas['sunday'] = date('Y-m-d',$offset);
}
else
{
$mas['sunday'] = date('Y-m-d',strtotime("next Sunday",$offset));
}

// last week
if(date('w',$offset) == 1)
{
$mas['lastmonday'] =  date('Y-m-d',strtotime('-1 week',$offset));
}
else
{
$mas['lastmonday'] = date('Y-m-d',strtotime('-1 week', strtotime(date('Y-m-d',strtotime("last Monday",$offset)))));
}

if(date('w') == 6)
{
$mas['lastsunday'] = date('Y-m-d',strtotime('-1 week',$offset));
}
else
{
$mas['lastsunday'] = date('Y-m-d',strtotime("last Sunday",$offset));
}

return $mas;
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/php-get-monday-sunday-last-monday-last-sunday.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>vTiger slow account/products popup</title>
		<link>http://www.rdlt.com/vtiger-slow-accountproducts-popup.html</link>
		<comments>http://www.rdlt.com/vtiger-slow-accountproducts-popup.html#comments</comments>
		<pubDate>Thu, 17 Apr 2008 12:38:59 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[vtiger]]></category>
		<category><![CDATA[adodb]]></category>
		<category><![CDATA[vtiger account]]></category>
		<category><![CDATA[vtiger logging]]></category>
		<category><![CDATA[vtiger popup]]></category>
		<category><![CDATA[vtiger slow popup]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/vtiger-slow-accountproducts-popup.html</guid>
		<description><![CDATA[After plowing through tons of code from both vTiger and ADOdb and pushing Google search to the max, I finally found a forum topic on vtiger.com covering the problem we were having with vTiger. The problem was that the popup to select an account or a product had load times averaging 60seconds. That&#8217;s a huge [...]]]></description>
			<content:encoded><![CDATA[<p>After plowing through tons of code from both vTiger and ADOdb and pushing Google search to the max, I finally found a forum topic on vtiger.com covering the problem we were having with vTiger. The problem was that the popup to select an account or a product had load times averaging 60seconds. That&#8217;s a huge usability issue (read: waste of time) when you are creating invoices or filling out your calendar.</p>
<p>Anyway, all the more reason to place it on my blog, with the all right keywords!</p>
<p>And now, for the solution:</p>
<blockquote><p><em>Quoting <span class="name"><strong>onwealdandy</strong></span></em><br />
<span class="gen"> However, I fixed the performance issue with a work around that doesn’t make much sense, but worked. I read this forum post a few days ago, but couldn’t see how commenting out debug print lines would speed things up. But, that did the trick. However, I did narrow it down to the exact variable causing the ruckus ($list_result) , so I only had to comment out just a few lines in ListViewUtils.php. (any debug log lines with $list_result)</span></p>
<p>Even with logging set to FATAL, the slowness would occur. When you did set logging to DEBUG, one instance would show the correct information in the debug log for the debug log lines .. basically what you would expect when printing $list_result (which is a recordset object) .. the object id &#8230; &#8220;Object id #40&#8243; &#8230; however on the slow machine it would actually print the 2000+ records which were returned by the query.</p>
<p>There must be a bug in php or apache or mysql ( no idea) that returns the entire result set to $list_result when its evaluated for printing. My guess is that the libmysql.dll must have a default _tostring method in there in some versions. BE CAREFUL .. since there its not documented which versions do this &#8230; for the record, my troubled instance was running php5.2.5, apache 2.2.6, and mysql 5.0.45</p></blockquote>
<p>You can find the original vTiger topic here: http://forums.vtiger.com/viewtopic.php?p=64335</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/vtiger-slow-accountproducts-popup.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>hostgator upgrades all their servers to PHP &amp; MySQL 5</title>
		<link>http://www.rdlt.com/hostgator-upgrades-all-their-servers-to-php-mysql-5.html</link>
		<comments>http://www.rdlt.com/hostgator-upgrades-all-their-servers-to-php-mysql-5.html#comments</comments>
		<pubDate>Wed, 13 Feb 2008 19:03:05 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[hostgator]]></category>
		<category><![CDATA[mysql5]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[webhosting]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/hostgator-upgrades-all-their-servers-to-php-mysql-5.html</guid>
		<description><![CDATA[I was very pleased to receive an e-mail from hostgator today, in which they stated that they will be upgrading all servers to have MySQL 5 and PHP 5 installed by default! I hope this will send out a message to the other hosting firms, which would finally allow us to start using PHP5 in all our opensource [...]]]></description>
			<content:encoded><![CDATA[<p>I was very pleased to receive an e-mail from <a target="_blank" href="http://secure.hostgator.com/cgi-bin/affiliates/clickthru.cgi?id=oneliner">hostgator </a>today, in which they stated that they will be upgrading all servers to have MySQL 5 and PHP 5 installed by default! I hope this will send out a message to the other hosting firms, which would finally allow us to start using PHP5 in all our opensource projects.</p>
<p style="text-align: center"><a target="_blank" href="http://secure.hostgator.com/cgi-bin/affiliates/clickthru.cgi?id=oneliner"><img border="0" width="247" src="http://www.hostgator.com/banners/gator_banner.gif" height="85" /></a></p>
<p><span id="more-98"></span></p>
<p><a target="_blank" href="http://secure.hostgator.com/cgi-bin/affiliates/clickthru.cgi?id=oneliner">Hostgator </a>e-mail:</p>
<blockquote><p>Dear HostGator clients,</p>
<p>As technology continues to advance and evolve, HostGator has always aimed to stay at the forefront of the technological curve. Following this trend to provide the most up-to-date hardware and software, we are proceeding with making PHP5 part of the standard working environment on all of our servers, as well as upgrading MySQL from version 4.1 to 5.0.</p>
<p>These upgrades will be on all new servers launched from this point forward. As of March 8th , 2008, we will begin converting current production servers to this new environment as well. We are aware that differences in PHP4 and PHP5 can lead to minor problems and instabilities in certain scripts, and are taking every measure possible to ensure your websites continue to function. This includes testing scripts that may conflict with the upgrade and automatically upgrading your code to a problem-free, stable and PHP5 compatible version. The MySQL upgrade may have minor issues as well, which will be handled in a similar manner.</p>
<p>This upgrade process is going to be as automated as possible, but we understand that some customers may wish to handle upgrades themselves. All servers and accounts will be upgraded to PHP5 and MySQL 5, but if you wish to handle the upgrading of any incompatible scripts yourself, please visit ( http://www.hostgator.com/php5opt-out/ ). By authenticating your login credentials on this page, you confirm that you wish leave any incompatible common scripts as they are.</p>
<p>With that said, only a very small percentage of customers will be affected by this, as nearly all PHP scripts have been upgraded to comply with the PHP5 standards over the past few years. MySQL 5 has also been proven stable and the upgrade will be as streamlined as possible. Of those customers still concerned or looking for more information, please read this forum post ( http://forums.hostgator.com/showthread.php?p=101443 ) regarding the upgrade process. Any news or progress updates will be posted there.</p>
<p>If you are a reseller and wish to opt out of the automatic upgrade procedure, please note that all of your underlying customers will be affected by your opt-out decision.</p>
<p>This upgrade will help HostGator provide the most up-to-date, reliable and secure software to better meet the ever changing needs of it&#8217;s customers. PHP5 and MySQL 5 provide many new features and offer much more design flexibility for scripts written with the changes in mind. In the future, we intend on upgrading to the latest available Apache versions as well. We&#8217;ll be following a strict upgrade procedure to minimize any problems that could potentially occur.</p>
<p>Any future upgrades will follow a similar process with minimal conflicts and downtime. Thank you for your understanding and cooperation, and thanks for choosing <a href="http://secure.hostgator.com/cgi-bin/affiliates/clickthru.cgi?id=oneliner">HostGator</a>!</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/hostgator-upgrades-all-their-servers-to-php-mysql-5.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>always_populate_raw_post_data disabled? here&#8217;s a workaround</title>
		<link>http://www.rdlt.com/always_populate_raw_post_data-disabled-heres-a-workaround.html</link>
		<comments>http://www.rdlt.com/always_populate_raw_post_data-disabled-heres-a-workaround.html#comments</comments>
		<pubDate>Mon, 11 Feb 2008 17:20:38 +0000</pubDate>
		<dc:creator>Thomas Hambach</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://www.rdlt.com/always_populate_raw_post_data-disabled-heres-a-workaround.html</guid>
		<description><![CDATA[Since HostGator does not support changing the value of always_populate_raw_post_data in PHP to &#8220;1&#8243;, I had to find a work around. After spending an hour Googling my issue and it turning zero-dot-zero results I was forced into being creative. Appearantly you can use the input wrappers to go around this setting. Perhaps you could find [...]]]></description>
			<content:encoded><![CDATA[<p>Since HostGator does not support changing the value of always_populate_raw_post_data in PHP to &#8220;1&#8243;, I had to find a work around. After spending an hour Googling my issue and it turning zero-dot-zero results I was forced into being creative.</p>
<p>Appearantly you can use the input wrappers to go around this setting. Perhaps you could find this useful in the future</p>
<p>[snippet]&lt;php<br />
if(!$HTTP_RAW_POST_DATA){<br />
$HTTP_RAW_POST_DATA = file_get_contents(&#8216;php://input&#8217;);<br />
if(empty($HTTP_RAW_POST_DATA))<br />
{<br />
// die here<br />
}<br />
}<br />
[/snippet]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rdlt.com/always_populate_raw_post_data-disabled-heres-a-workaround.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
