Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth
Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

42,690 questions

55,449 answers

573 users

How to create MySQL table in PHP

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

Related questions

1 answer 320 views
1 answer 357 views
1 answer 371 views
1 answer 297 views
1 answer 213 views
213 views asked Jul 13, 2014 by avibootz
...