Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
GreenGeeks Web Hosting - Faster, Scalable & Eco-Friendly

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


7,788 questions

10,874 answers

573 users

How to create MySQL table in PHP

OneTravel.com | Grab our Special Flight Deal!


25 views
asked Jul 13, 2014 by avibootz
edited Mar 3, 2015 by avibootz

1 Answer

0 votes
$db_host     = 'localhost';
$db_user     = 'user_name';
$db_pass     = 'password';
$db_database = 'database_name';
 
$con = mysql_connect($db_host, $db_user, $db_pass) or die('Unable to establish a DB connection');

$sql = "CREATE TABLE IF NOT EXISTS `posts` (
    `post_id` int(11) NOT NULL AUTO_INCREMENT,
    `user_id` int(11) NOT NULL,
    `post` text COLLATE utf8_unicode_ci NOT NULL,
    `IP` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
    `add_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    PRIMARY KEY (`post_id`),
    FULLTEXT KEY `post` (`post`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; 
    
$result = mysql_query($sql, $con);
if ( ! $result ) die("Line: " . __LINE__  . " Error: ". mysql_error());   



answered Jul 13, 2014 by avibootz
...