PHP

HackNY Hackathon Starter Script

Posted in HackNY, PHP, Tips, Uncategorized, Web Development on April 8th, 2011 by j3nnings – Be the first to comment

My buddy Andrew wanted to be able to hack on something a tomorrow’s HackNY competition. He’s never used PHP before so I wrote him this file to help him make an api call and display it on a web page. I’m assuming that you’ve already got a PHP environment set up somewhere. If not, check out XAMPP.

This file is intended to give new programmers (hackathon or else) something to start hacking on quick. Of course, you would have already needed to set up PHP and a webserver.

This file just makes a simple api request and displays the response. The API for this example is embed.ly, an API for turning normal links (http://…) into embeddable widgets (video players, slideshows, etc) .

The actual code can be found here. you should copy and paste it into an index.php file in your htdocs directory (if using XAMPP).

CodeIgniter URL Rewrite with .htacccess AND populated $_GET variables

Posted in CodeIgniter, How To, PHP, Web Development on December 7th, 2010 by j3nnings – Be the first to comment

Everytime I start a new CodeIgniter project on Dreamhost I face the same two problems.

  1. How can I get URL rewriting to work properly?
  2. How can I repopulate $_GET variables once they are stripped by CodeIgniter?

The problem with this pair of tasks is that task 2 is dependent on how you solve task 1. I’ve solved both problems (on dreamhost) with the following fixes:

Make sure your config.php has these values set:

$config['base_url'] = "http://domain.com/";
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['enable_query_strings'] = TRUE;

Your .htaccess looks like this:

RewriteEngine on
RewriteCond $1 !^(index\.php|public|favicon\.ico|static|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]

And add this to the top of any Controller you wish to use $_GET variables in.

function __construct() {
parse_str(substr(strrchr($_SERVER['REQUEST_URI'], "?"), 1), $_GET);
parent::Controller();
}

Now you’ll be able to access the $_GET variables as you would expect:

echo $this->input->get('foo');

22Pixels Slowness

Posted in 22Pixels.com, PHP on April 9th, 2010 by j3nnings – Be the first to comment

I figured out why 22Pixels has been loading extremely slow over the past few months. It had to do with some extremely inefficient tag queries, something I should be able to clear up within the coming weeks.

How to check if PHP is in safemode

Posted in How To, PHP on April 29th, 2009 by j3nnings – Be the first to comment

Simple, all you need to do is create a new php document, and paste the following into it.

<?php phpinfo(); ?>

Load the page in your browser, and then press Control + F and search for “safe_mode.”

Find SQL Bottlenecks With CodeIgniter

Posted in CodeIgniter, How To, PHP, Web Development on April 6th, 2009 by j3nnings – 3 Comments

I have been using my latest project, VentStatus, as a an opportunity to learn a new framework: CodeIgniter. It has treated me well so far, most problems encountered only required a short workaround. Lately I’ve been concerned with the scale-ability of VentStatus, it’s my first project on this large of a scale. Luckily, CodeIgniter has some benchmarking classes built in, and it really helped me cut down my load times.
read more »