Tuesday, May 1, 2007

My PHP Finally Creates A Database

I finally created a database using PHP. I just followed the example closely:
<?php
$link = mysql_connect('localhost', 'root', '*****');
if (!$link) {
die('Could not connect: ' . mysql_error());
}

$sql = 'CREATE DATABASE dental_office';
if (mysql_query($sql, $link)) {
echo "Database dental_office created successfully\n";
} else {
echo 'Error creating database: ' . mysql_error() . "\n";
}
?>


Using a string variable to capture the connection tag makes it a lot easier to call in the future. Soon I will be able to create code that allows patients to fill out information online and sent it to the dental office immediately. (This happens to be a very big convenience as I work at a dental office where that is needed :p)

My code went off without a hitch. I even found there are ways to connect directly to specific ports and sockets by replacing localhost with the site's name or IP. I only have one server and one data base so I don't think I'll be needing that I'm happy to finally be on track. Variables are running well, I'm connecting to MySQL through PHP, I've even gotten PHPMyAdmin to create tables for me on the database.

Everything is looking up for Milhouse, er Jay.

1 comment:

Unknown said...
This comment has been removed by a blog administrator.