I have a db open but have a problem creating a table: // Create table in my_db database mysql_select_db("kjv", $con); $sql2 = "CREATE TABLE person ( PRIMARY KEY(id) smallint, recordType char, book_title, book smallint, chapter smallint, verse smallint, book_spoke smallint, chapter_spoke smallint, verse_spoke smallint, text_data longtext )"; mysql_query($sql2,$con); PHP:
it says: kjv is supposed to be the existing database which is open. I got my example from http://www.w3schools.com/php/php_mysql_create.asp <?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create database if (mysql_query("CREATE DATABASE my_db",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } // Create table in my_db database mysql_select_db("my_db", $con); $sql = "CREATE TABLE person ( FirstName varchar(15), LastName varchar(15), Age int )"; mysql_query($sql,$con); mysql_close($con); ?> PHP: Except that I thought I should delete part of it because I don't intend to create a NEW database and the database is already open. My intention is to insert data from one table to the other ( created table ).
dear gigal, first of all u connect ur database, then the table u have created in it u have to define the datatype of book-title,and give the size to recoredtype column name, REMEMBER : if u select datatype character or number then u have to specifie the size also.