Yes. Disallowed Key Character, is a REALLY annoying error. It shows me absolutely NOTHING.

When you’re developing, you ought to modify this file:

system/core/Input.php

Modify the following function:

_clean_input_keys

And just above

exit('Disallowed Key Characters.');

Put in:

echo "Error string: {$str}";

So now, if you get that PESKY error it’ll show you where it’s failing.

Tags: , ,

· · · ◊ ◊ ◊ · · ·

If you’re trying to load more than one view in CodeIgniter, you may find it a bit weird.

For example, if you’re going to load 3 views at the same time within the same function, that’ll be fine. However, what happens if another function within that same controller wants to load a view?

It’s possible. You just need to put a

return false;

on the previous function.

Let’s explain it by simply showing you the code:

Class Something extends CI_Controller {
 public function __construct()
 {
  parent::__construct();
  $this->load-model('some_model');
 }

 public function step_one() {
  $this->load->view('some_view');
  return false;
 }

 public function step_two() {
  $this->load-view('some_view_more');
 }

Without the

return false;

part, then step_two view won’t load.

Hope that helps.

Tags: , ,

· · · ◊ ◊ ◊ · · ·

Here’s a basic config for nginx. There are two files. It has a easy to read log output, PHP and phpmyadmin.

Simply make two files, nginx.conf and fastcgi.conf and pop the text into their respective place. Then change example.com to your site, /var/www where you keep your hyper text docs are and phpmyadmin where phpmyadmin is (if you have it).

#nginx.conf
events {
    worker_connections  1024;
}

http {
        index index.html index.php;
        server {
                server_name example.com localhost;
                log_format custom '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent"';
                access_log /var/log/nginx/access.log;
                server_tokens off;

                root /var/www;
                location ~ \.php$ {
                        include fastcgi.conf;
                        fastcgi_pass  127.0.0.1:9000;
                }
                location /phpmyadmin {
                        root /usr/share/phpmyadmin;
                        index index.php;
                }
        }
}

#fastcgi.conf
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

Tags: , ,

· · · ◊ ◊ ◊ · · ·

Last week, I installed XAMPP on a brand new Windows 2008 server, with the sole purpose of running production servers with PHP and MySQL.

One of the websites I copied over, was a WordPress CMS. I imported the database and made the user credentials. All good.

Then I tried going to this wordpress website, and I received a lovely ERROR 500. Nothing was showing in the error log, nor the access logs. I was completely mystified.

Then, when looking at the user credentials for MySQL, I noticed a difference between the ‘pma’ user and the ‘wordpress’ user – the ‘wordpress’ user had a wildcard (as to expect a connection from any machine) which effectively broke the server, outputting an error that explained nothing.

I’ve posted this in case anybody else has the same problem. Triple check your user permissions for connecting to MySQL.

(I blame Windows for being ghey)

Tags: , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

Here’s a fast, effective way of drawing a Bezier Curve in PHP with no cumbersome libraries or extensions.

<?php
$im = imagecreate(500, 500);

function quadBezier($im, $x1, $y1, $x2, $y2, $x3, $y3, $color) {
    $b = $pre1 = $pre2 = $pre3 = 0;
    $prevx = 0;
    $prevy = 0;
    $d = sqrt(($x1 - $x2) * ($x1 - $x2) + ($y1 - $y2) * ($y1 - $y2)) +
        sqrt(($x2 - $x3) * ($x2 - $x3) + ($y2 - $y3) * ($y2 - $y3));
    $resolution = (1/$d) * 10;
    for ($a = 1; $a >0; $a-=$resolution) {
        $b=1-$a;
        $pre1=($a*$a);
        $pre2=2*$a*$b;
        $pre3=($b*$b);
        $x = $pre1*$x1 + $pre2*$x2  + $pre3*$x3;
        $y = $pre1*$y1 + $pre2*$y2 + $pre3*$y3;
        if ($prevx != 0 && $prevy != 0)
            imageline ($im, $x, $y, $prevx,$prevy, $color);
        $prevx = $x;
        $prevy = $y;
    }
    imageline ($im, $prevx, $prevy, $x3, $y3, $color);
}
$bg = imagecolorallocate($im, 255, 255, 255);
$color = imagecolorallocate($im, 0, 0, 0);
for ($i = 0; $i<20; $i++){
    quadBezier($im, 40,100, 150 , 20 + $i * 10 , 500, 100,$color);
}
header("Content-type: image/jpeg");
imagejpeg($im,"",100);

?>

Tags:

· · · ◊ ◊ ◊ · · ·