1. Playing with FrogCMS (Part 7: My Conclusion)

    Posted on: March 12, 2010
    (more…)

  2. Playing with FrogCMS (Part 6: User Management)

    Posted on:
    (more…)

  3. Playing with FrogCMS (Part 5: The Blog)

    Posted on:
    (more…)

  4. Playing with FrogCMS (Part 4: The Theme [continued...])

    Posted on:
    (more…)

  5. Playing with FrogCMS (Part 3: The Theme)

    Posted on:
    (more…)

  6. Playing with FrogCMS (Part 2: The Plan)

    Posted on:
    (more…)

  7. Playing with FrogCMS (Part 1: Installation)

    Posted on:
    (more…)

  8. PHP: unserialize() Error at offset… (simple solution)

    Posted on: November 13, 2009

    Here’s what I was trying to do:

    • serialize an array on one page (PHP: serialize($array))
    • print out the results using echo or print_r
    • grab the serialized data from another script using file_get_contents
    • unserialize that array so I could go about my business

    but I kept getting this error:

    unserialize() [function.unserialize]: Error at offset 0 of 3457 bytes

    I looked around and couldn’t find a simple a solution. I’m sure this error can occur in other ways, but I was trying with the simplest of arrays:

    Array("Ryan" => "Bosinger");

    My problem was that my echo statement was throwing some whitespace in there. That’s all. This fixed it:

    $data["search_results"] = file_get_contents("http://localhost/sphider/search.php?query=" . $search_for . "&search=1&start=" . $start);
    $result_string = trim($data["search_results"]);
    $result_array = unserialize($result_string);

    Basically, try trimming the whitespace before unserializing. Hope that helps!

    Also, I was using Codeigniter but I really don’t think that has anything to do with it.


  9. Grab RSS feed with PHP

    Posted on: September 29, 2009

    I would like to share a PHP function for writing out parts of an RSS feed to a page. I used this in the redesign of ryanbosinger.com to show the latest three posts of this blog.

    To use it, just call the function where you’d like it show up like so:

    <?php getFeed("http://ryanbosinger.com/blog/feed", 3); ?>

    The second parameter is the amount of posts to show. It will write out as an unordered list. You can choose to write out different parts of the feed by changing: $x->channel->item[$i]->[name-of-feed-tag]

    <?php
    function getFeed($feed_url, $posts_to_show) {
     
    	try 
    	{
    		$content = file_get_contents($feed_url);
    		$x = new SimpleXmlElement($content);
     
    		echo "<ul>";
     
    		$i = 0;
     
    		while ($i < $posts_to_show){
    			echo "<li><a href=\"" . $x->channel->item[$i]->link . "\" title=\"" . $x->channel->item[$i]->title . "\" target=\"_blank\">" . $x->channel->item[$i]->title . "</a></li>";
    			$i++;
    		}
     
    		echo "</ul>";
     
    	} 
    	catch (Exception $e) 
    	{
    		echo "<p>The blog feed doesn't seem to be available at the moment...</p>";
    	}
    }
    ?>

  10. Wordpress: Speed up your blog with super caching!

    Posted on: November 12, 2008

    I just installed WP Super Cache and I have to say I wish I had done this earlier!

    Before I installed this I noticed that sometimes my blog would timeout and send back only a white page. I thought it was likely because I am on shared hosting and sometimes the PHP or MySQL just wasn’t ready to kick in fast enough (because it never it happens with HTML pages and it seemed like once I hit the first page everything would be “warmed up” and this blog would run normally).

    I also been meaning to figure out how to get gzip content encoding on my pages, although I never really tried.

    (more…)