CREATE TABLE on database
Hi all,
I’m new to php, so I’m going through a few tutorials like the one below. I’m stuck why I carn’t create a table on the database. I get the “success in database connection” and “success in database creation”, but then “No tables”. Is there an obvious problem with the code.
<?php
//set your info
$dbhost =‘localhost’;
$dbusername =‘root’;
$dbpassword = ‘root’;
$dbname = ‘firstdb’;
//
//connect to the mysql database server.
$link_id = mysql_connect($dbhost,$dbusername,$dbpassword);
echo"success in database connection <br>";
//
//create database.
$dbname = $dbusername."_".$dbname;
if(!mysql_query(“CREATE DATABASE $dbname”))
die(mysql_error());
echo"success in database creation <br>";
$result=“CREATE TABLE address_book (first_name VARCHAR(25) last_name VARCHAR(25) phone_number VARCHAR(15))”;
if(mysql_query($result)){
echo"table created";
}else{
echo"No tables";
}
?>