Created
November 12, 2014 18:25
-
-
Save hansent/0724ae23e88db129e751 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Creating MySQL Tables</title> | |
</head> | |
<body> | |
<?php | |
$dbhost = 'localhost:3036'; | |
$dbuser = 'root'; | |
$dbpass = 'rootpassword'; | |
$conn = mysql_connect($dbhost, $dbuser, $dbpass); | |
if(! $conn ) | |
{ | |
die('Could not connect: ' . mysql_error()); | |
} | |
echo 'Connected successfully<br />'; | |
$sql = "CREATE TABLE tutorials_tbl( ". | |
"tutorial_id INT NOT NULL AUTO_INCREMENT, ". | |
"tutorial_title VARCHAR(100) NOT NULL, ". | |
"tutorial_author VARCHAR(40) NOT NULL, ". | |
"submission_date DATE, ". | |
"PRIMARY KEY ( tutorial_id )); "; | |
mysql_select_db( 'TUTORIALS' ); | |
$retval = mysql_query( $sql, $conn ); | |
if(! $retval ) | |
{ | |
die('Could not create table: ' . mysql_error()); | |
} | |
echo "Table created successfully\n"; | |
mysql_close($conn); | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment