This site includes academic coursework, my resume, and projects I have done for work. This also serves as a place to post code and other programming-related information that I have found useful.

Backup an entire database to a file (Mysql)

July 14, 2008

mysqldump --opt -u username -p database name > backup.sql

Fatal error: Call to a member function bind_param() on a non-object (PHP)

July 01, 2008

The cause of this error is most likely due to the statement object returning false when attempting to be created. The cause of the statement object returning false is that the SQL statement is incorrect. Try running the same SQL command line and see if you get errors there.

$updateStatement = "UPDATE $db_table SET refID = ? WHERE trans_num = ?";
$stmt = $mysqli->prepare($updateStatement);
if(!$stmt) echo "error"; //Will print "error"
$stmt->bind_param("ss", $newTransNum, $originalTransNo); //This fails
//The SQL statement is wrong (there is no field trans_num in the table)

Format to two decimal places (PHP)

June 18, 2008

I was looking all around for this and even tried to do it manually, but I found this function number_format. I used it to make sure that a dollar amount was to have two decimal places. Original amount: 5.3
$newAmount = number_format(5.3, 2)
$newAmount = 5.30.

http://us3.php.net/manual/en/function.number-format.php

Firefox 3 Released (Browsers)

June 17, 2008

Today marks the launch of Firefox 3 (10 AM Pacific Time). Mozilla is trying to break a world record for the most downloads. My co-worker is hosting a launch party today at 7PM at his apartment at RIT.

http://seanhayes.name/2008/06/17/firefox-3-launch-party-rit/

Linux moo command (Linux)

April 27, 2008

Type "apt-get moo" at the terminal

http://ubuntulinuxhelp.com/friday-fun-useful-linux-terminal-commands-for-new-users/

Function Exists (PHP)

December 02, 2007

To see if a function is defined, use the function function_exists. It takes a function name (as a string) as the parameter.

http://us3.php.net/function_exists

heredoc (PHP)

November 28, 2007

This is a way to use HTML code within PHP without having to escape anything.

echo <<<TEST
	<p>some text</p>

TEST;

http://www.tizag.com/phpT/strings.php

highlight_string (PHP)

November 28, 2007

This function takes a string of PHP code and displays the code with syntax highlighting.

http://us.php.net/highlight_string

Attribute Selectors (CSS)

November 27, 2007

You can select an element in CSS using an attribute of that tag. For example img[src="dir/image.ext"] {border: 0;}

http://css.maxdesign.com.au/selectutorial/selectors_attribute.htm