a horror of php

Uncategorized | Posted by Gauthier
Apr 17 2014

To start off with PHP has always been on my list of acceptable languages to test things out with. Today i decided to add database queries and times to my tiny library to speed things up. The reason was after reading this article .After implementing a quick tally, My code all worked flawlessly, now it just needs something to display on the GUI.

Someone I know using my code suddenly had all of his code break. At first I couldn’t even guess what the problem was, but it boiled down to uninitialized PHP variables.

They write code like the top half. I change my function to be like the bottom half.

function x() { return 'z';}
function data() { throw Exeception(); }

$data[itemone]['array'][1.+2][x().y][$news][] = data;

echo '['.print_r($data, true) . ']';

// vs this little bit of logical code

if (array_key_exists('somedata', $otherdata)) {
$otherdata['somedata'] = array();

echo '['.print_r($otherdata, true) . ']';

The concept that PHP magically makes variables and nested arrays breaks my head a title.

I alerted them of the uninitialized variables, also I altered my function to check if the parameter in the function is an array.

if (!is_array($otherdata)) {
$otherdata = array();
if (array_key_exists('somedata', $otherdata)) {
$otherdata['somedata'] = array('timer'=>0);

echo '['.print_r($otherdata, true) . ']';

Mysql preserving autoincrement values and adding auto_increment

Programming | Posted by Gauthier
Sep 30 2013

This was a difficult query to come by. Just a book mark for future reference, and hopefully this will help someone else.
Originally the answer was here http://stackoverflow.com/questions/7995427/1062-duplicate-entry-1-for-key-1-no-duplicate-entries-found


ALTER TABLE Some_Table modify column uid int(11) auto_increment;



Programming magic

Uncategorized | Posted by Gauthier
Jan 31 2011

Almost anything can be done with a small bit of code. Doing it properly is the real problem. There are so many security risks, and things that can be injected in to your code.
I have a new website project I am going to be starting on. First I have to get the basic crud interface up. Time to find some basic templates.

Wordbook plugin success

Uncategorized | Posted by Gauthier
Aug 15 2010

One of the basic plugin for the site http://wordpress.org/extend/plugins/wordbook/ had a face-lift of sorts and now works with the latest version of Facebook. I have to mention it and see if it posts online.

A thought crossed my mind to redo some of the backend and have it work myself, however I seem to have the motivation of cat.

Overload Clone

Experiments | Posted by Gauthier
Jul 11 2010

This is my first test in html5 and javascript. I have used javascript before, but never really for anything useful.

Gauthierstudio overload version
Generic html5 overload