# CREATE TABLE on database

**URL:** <https://forum.kirupa.com/t/create-table-on-database/209418>\
**Category:** programming\
**Created:** [December 8, 2006, 4:22pm UTC](https://forum.kirupa.com/t/create-table-on-database/209418 "2006-12-08T16:22:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![coop](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coop](https://forum.kirupa.com/u/coop)\
**Post date:** [December 8, 2006, 4:22pm UTC](https://forum.kirupa.com/t/create-table-on-database/209418/1 "2006-12-08T16:22:04Z")

</div>

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";

}  
?\>
