I’ve decided that I’m going to learn how to use the codeigniter framework, because it looks like something that I would benefit from knowing, and that would make any coding I do quite a bit easier. (0)
I made my first bit of code!
Yep, I’ve written my first thing in php! :D
I’ve written a very basic advertising rotation script, which I’ll put online sometime soon, because I can.
Basically, it selects a random banner from a table defined in the script, and then puts the code into html format for it. It also counts the total number of impressions on that code, not clicks, but impressions, and I’ll make a (very basic) stats page for it soon.
Next up, a tinyurl redirection script for GPearce :D
PHP Cheat Sheet
I’ve put together this ‘cheat sheet’ in the hope that it helps some people, it shows the correct syntax for various statements and I shall add to it as I have time.
PHP Statements
array ( “key” => “value”, … );
die(”messagetoshow”);
echo item;
extract ($array;)
header (”Location: url“);
if (condition) {operation]
elseif (condition) {operation}
else {operation};
session_start();
session_destroy();
PHP MySQL Functions
mysql_connect(”host”,”uname”,”password”);
mysql_select_db(”dbname“);
mysql_query(”query“);
mysql_num_rows($result);
mysql_fetch_array($result,type_of_array);
I hope this helps someone, a lot of it was learned from the dummies book and W3schools ![]()
-G
Installing Apache, PHP and MySQL on Ubuntu
This tutorial is designed to help you install the LAMP (Linux,Apache,MySQL,PHP) combo on your Ubuntu machine.
What You Need
Ubuntu (Obviously)
Root Access Password
About 7gigs HDD space (ish)
Step 1
You firstly need to install Apache 2 onto your machine. Fire up the terminal, and enter:
sudo apt-get install apache2
It should then install automatically.
To start Apache, use the following command:
sudo /etc/init.d/apache2 start
And to stop it;
sudo /etc/init.d/apache2 stop
You should then be able to goto http://localhost , and see some default text, something like “It works!”
Step 2
Next up is PHP, enter the following code in terminal:
sudo apt-get install php5 libapache2-mod-php5
Then restart Apache;
sudo /etc/init.d/apache2 restart ;
and PHP is done. You can change PHP5 to any version you like , but PHP5 is recommended.
Step 3
Next, we install MySQL. It’s also very simple, run the following in terminal:
sudo apt-get install mysql-server
And then you need to set the root password for MySQL (important)
mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(’password!’);
And that’s MySQL In. Restart Apache again;
sudo /etc/init.d/apache2 restart ;
And it should all work nicely!
An excellent tool for PHP is PhpMyAdmin, which can be installed with the following:
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
And that’s it! All done. If you have any problems with PhpMyAdmin, try rebooting apache.
Have fun with LAMP!
–George
,

| All rights reserved.