I’ve been doing php/mysql tutorials all day and trying to get a grasp on everything.
I keep having problems executing a Create Table script and having it work. I’ve been using Terminal to create databases on localhost and I can create tables that way.
But in every tutorial I can’t seem to create a table or insert data into the database through php. I’ve tested the connection to mysql and it is working.
Here is the code for the current create table:
<?
/* Change next two lines */
$db="tutorialdb";
$link = mysql_connect('localhost', 'root', 'password');
if (! $link)
die(mysql_error());
mysql_select_db($db , $link)
or die(mysql_error());
/* create table */
mysql_query("CREATE TABLE birthdays(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
name VARCHAR(30),
birthday VARCHAR(7))")
or die(mysql_error());
mysql_close($link);
?>
I created the “tutorialdb” in Terminal and “password” is also the password I’m using.
Thanks for any help as it why it’s not working.