Tuesday 15 September 2015

Not able to run create sql command with mysqli_query php -



Not able to run create sql command with mysqli_query php -

i have below code trying run..connection created still mysqli_query not create table.what missing...

here script executing...

error_reporting(e_all); ini_set('display_errors', '1'); $con=mysqli_connect("localhost","xxxxxx","xxxxx","xxx"); if (mysqli_connect_errno()) { echo mysqli_connect_error(); exit(); } else { echo "successful database connection"; } $tbl_users = "create table if not exists users ( id int(11) not null auto_increment, firstname varchar(255) not null, lastname varchar(255) not null, email varchar(255) not null, password varchar(255) not null, gender enum('m','f') null, state varchar(255) null, country varchar(255) null, userlevel enum('admin','user') not null default 'user', ip varchar(255) not null, signup datetime not null, lastlogin datetime not null, activated enum('0','1') not null default '0', primary key (email) )"; $query = mysqli_query($con, $tbl_users); if ($query === true) { echo "<h3>user table created ok :) </h3>"; } else { echo "<h3>user table not created :( </h3>"; }

you need alter primary key auto_increment column, remove email, can set (email) unique if should be

create table if not exists users ( id int(11) not null // >>> primary key //<<< auto_increment, firstname varchar(255) not null,

php

No comments:

Post a Comment