Archive

Archive for the ‘MySQL’ Category

Setting up Apache, PHP 5 and MySQL on Leopard

March 24th, 2009

Going to be a short blog post as Leopard has made this process very simple as PHP5 has been included as standard with the new OSX.

First thing you need to do is open terminal and edit your http.conf file by typing:

nano -sw /etc/apache2/httpd.conf

Firstly you need to enable the php module. Search for ‘php5_mod’ by typing it in when you press ctrl+w and press enter. This will bring you to a line with a hash before it….

#LoadModule php5_module libexec/apache2/libphp5.so

Remove this hash to enable php5.

Next you need to setup your document root, i.e. the location your webserver will default to when you go to http://localhost. Search for ‘DocumentRoot’ within nano again by pressing Ctrl+w and hitting return. Alter the location (I think its Library/WebServer or something by default) to be whatever you wish your webserver root to be. I set it to be the Sites folder of the User I setup for Leopard.

Next you need to enable Apache, this is exceedingly easy. Go to System Preferences and then Sharing. Click the checkbox next to Web Sharing and apache should be ready to do. Put a sample html or php file(including is always a good way to test if php is working) in the document root and go to http://localhost and you should see the sample page.

Next you need to get MySQL. I got it here: http://mirrors.sunsite.dk/mysql/downloads/mysql/5.0.html#macosx-dmg.
Follow the very easy steps in the package and you should be hunky-dorey!

edlong Archive Post, MySQL, PHP

PHP dump, Beejive and MySQL tidbits

March 24th, 2009

Hi,
Haven’t had time to post recently and this is a relatively short one.

I’ve been coding with PHP again recently and was looking for something similar to ColdFusions cfdump and didn’t know until last week that the var_dump function existed, its very handy although it doesn’t output the dumped variable in a very user-friendly fashion.

As I posted previously I jailbroke my iTouch and was looking for a good app for IM. I installed Apollo IM hearing that it was meant to be very good but it only has .Mac, MSN, AIM and one other I can’t remember, the main problem with the app is that there doesn’t seem to be Google Talk support. After looking around for a bit I found Beejive which is excellent, very nice to use but unfortunately only works from within Safari and isn’t a standalone app but will do for the moment. Check it out at Beejive.

I had this error during the week when doing some CF troubleshooting. I couldn’t figure it out for a while and the error message wasn’t especially helpful.

Element 25316 is undefined in a Java object of type class coldfusion.runtime.TemplateProxy.

The error occurred (I don’t know why I was doing this) when I was trying to index into a CF object as you would a struct! So if I had an object oObject and try to do something like oObject["someValue"] you will get an error like above.

Finally just a couple of quick really useful MYSQL snippets I picked up during the week. I needed to rename a MYSQL table, the SQL below does this nicely.

[code lang="sql"]
rename table myOriginalTable TO newTableName;
[/code]

Another really great piece of SQL performs an insert if a record doesn’t exist and if it does exist it performs an update on the record.

[code lang="sql"]
INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
[/code]

Coalesce is a nice MYSQL function, it returns the first non-null in a list. If there is nothing besides NULL in the list, 1 is returned as in the case below.

[code lang="sql"]
SELECT COALESCE(NULL,1) FROM tbl_test
[/code]

edlong Archive Post, ColdFusion, MySQL