Lesson Code: http://www.developphp.com/video/PHP/MySQL-Database-Tables-Creation-Script-Logic Learn to script table creation into your MySQL database to …
Original source
Lesson Code: http://www.developphp.com/video/PHP/MySQL-Database-Tables-Creation-Script-Logic Learn to script table creation into your MySQL database to …
Original source
40 responses to “3. MySQL Database Tables Creation PHP Script Logic Tutorial”
Does anyone know why the ip address should be stored in the user table?
this was dope!
Anyone has this entire code? Please provide me the while folder, i really need it very badly right now. I will appreciate the one who would provide me the while code. Thanks !
Creates other tables but fails to create the "users tables" , not sure why .Still troubleshooting though , share ur thoughts . !
Php reports an error every time I use a parameter. Such as for "gender" or "userlevel".
Parse error: syntax error, unexpected 'a' (T_STRING) in /Applications/MAMP/htdocs/db.php on line 29
Proper table 'users'
CREATE TABLE `users` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`username` VARCHAR(16) NOT NULL DEFAULT '0' COLLATE 'utf8mb4_polish_ci',
`email` VARCHAR(50) NOT NULL DEFAULT '0' COLLATE 'utf8mb4_polish_ci',
`password` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_polish_ci',
`gender` ENUM('m','f') NOT NULL COLLATE 'utf8mb4_polish_ci',
`country` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_polish_ci',
`website` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_polish_ci',
`userlevel` ENUM('a','b','c','d') NOT NULL DEFAULT 'a' COLLATE 'utf8mb4_polish_ci',
`avatar` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_polish_ci',
`ip` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_polish_ci',
`signup` DATETIME NOT NULL,
`lastlogin` DATETIME NOT NULL,
`notescheck` DATETIME NOT NULL,
`activated` ENUM('0','1') NOT NULL DEFAULT '0' COLLATE 'utf8mb4_polish_ci',
PRIMARY KEY (`id`),
UNIQUE INDEX `username` (`username`, `email`)
)
COLLATE='utf8mb4_polish_ci'
ENGINE=InnoDB
;
If you guys are using Xampp by example and want to use root as username without using a password. You need to put null value to the third argument in order to be able to pass the db name as fourth argument. The syntax of mysqli_connect will be: $db_conx = mysqli_connect("localhost", "root", null, "social");
Hey Adam, thanks a lot for theses tutorials, even if english isn't my first language, you speak very clearly and make this easily understanable for foreign language speaker and newb like me.
Comment created OK 🙂
So if PRIMARY KEY('id') in table 'a', will that remain the users id in any other table in the database?
How much of this is still valid?
What if you wanted the ID in the first table to be random or increased by 10s?
why this code is not working any sugestion ???
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db('contact');
$vari="demotable_name";
$sql= "CREATE TABLE '".$vari."'(id int(10) AUTO_INCREMENT PRIMARY KEY,name VARCHAR(30) NOT NULL,contact1 VARCHAR(15),contact2 VARCHAR(15),contact3 VARCHAR(30),email VARCHAR(30),email2 VARCHAR(30),email3 VARCHAR(30),website VARCHAR(40),address text(30))";
if(mysql_query($sql))
{
echo "table created";
}
?>
Hi Adam…
Would it be possible to copy, paste and then change the wording in of the photo portion of the table in order to make my web application accept and support videos?
Please Sir help me.I am facing in the problem.
Please how ill i solve the problem.
Connected Successfully!!
Warning: mysql_query() expects parameter 2 to be resource, string given in /home/learnbiology24/public_html/make_my_tables.php on line 26
Users table not Created Ok:
Warning: mysql_query() expects parameter 2 to be resource, string given in /home/learnbiology24/public_html/make_my_tables.php on line 48
UserOptions table not Created Ok:
Warning: mysql_query() expects parameter 2 to be resource, string given in /home/learnbiology24/public_html/make_my_tables.php on line 69
Friends table not Created Ok:
Warning: mysql_query() expects parameter 2 to be resource, string given in /home/learnbiology24/public_html/make_my_tables.php on line 90
Blockedusers table not Created Ok:
Warning: mysql_query() expects parameter 2 to be resource, string given in /home/learnbiology24/public_html/make_my_tables.php on line 111
Status table not Created Ok:
Warning: mysql_query() expects parameter 2 to be resource, string given in /home/learnbiology24/public_html/make_my_tables.php on line 131
Photos table not Created Ok:
Warning: mysql_query() expects parameter 2 to be resource, string given in /home/learnbiology24/public_html/make_my_tables.php on line 153
Notifications table not Created Ok:
I followed step by step yet when i run it I dont even get smilely or sad faces. It echoes nothing. I did the second tuturial and reached good results. what could I be doing wrong?
all'right i got nothing but smiley faces baby! :'DDD
no tables found in database
If you have problem in MYSQL what I need do ?
you would better improve that code by avoiding " redundant code" , so like you would do $quires[] = array(); and you start adding to it all your quires , then at the end , you would foreach it , so you avoid redundant code 🙂 , overall everything seems perfect ^_^
Very nice tutorial. So, when you do the connect command then run a mysqli command, you are disconnected from the DB after the query runs?
it's not working
can somebody pls help… when i tried to run the codes ..i'm getting this kinda problem..
user table NOT created 🙁
useroptions table NOT created 🙁
friends table NOT created 🙁
blockedusers table NOT created 🙁
status table NOT created 🙁
photos table NOT created 🙁
notifications table NOT created 🙁
Hello all. To those who are having trouble getting the tables to successfully create, it's most likely because when you are uploading to the ftp, most of us are uploading the db_conx.php file by itself. We're supposed to upload the ENTIRE php_includes FOLDER to the ftp, which should have the db_conx.php file in it. Since in the make_my_tables.php file we put the folder name in the include function. Adam mentions this at 2:43!
WOW i did it right i thought i wouldnt be able to but i won, thanx buddy ur so awesome.
I use WAMP and working on it cause my host server isn't functioning well with me.
And fox watch out one little comma mistake can mess up ur work.
I know that my db-conx is connecting to my sql because I got the password error. I fixed the password and now all I am getting is a blank screen when I do /makemytables.php. Any idea? I don't know what I have done wrong.
mY sQL cODE nO WORK hELP
$tbl_users = "CREATE TABLE IF NOT EXISTS users(
'id' INT(11)NOT NULL AUTO_INCREMENT,
'firstname' VARCHAR(20) NOT NULL,
'lastname' VARCHAR(20) NOT NULL,
'email' VARCHAR(50) NOT NULL,
'username' VARCHAR(20) NOT NULL,
'password' VARCHAR(20) NOT NULL,
'active' ENUM('0','1') NOT NULL DEFAULT '0'
'gender' ENUM ('m','f') NOT NULL
'website' VARCHAR(255) NULL,
'country' VARCHAR(25) NOT NULL,
'userlevel' ENUM('a','b','c','d') NOT NULL DEFAULT 'a',
'avatar' VARCHAR(25) NOT NULL,
'ip' VARCHAR(25) NOT NULL,
'signup' DATETIME NOT NULL,
'lastlogin' DATETIME NOT NULL,
'notescheck' DATETIME NOT NULL
'PRIMARY KEY' (id),
'UNIQUE KEY' username (username,email)
)";
is it smart to put an avatar image inside ur users table? I guess it's smarter to make a new table & put it separate plus a foreign key.
Wow bro! Thnx so much, run fineee! 😀
This is really a wonderful series! As I understand, this is cPanel based, while I m having Plesk in Windows. Installed Joomla also. I could set up the data base, but finding it difficult to set tables. The permissions settings, control panel etc are totally different. Can someone help me the similar way this wonderful Adam does
sad faces … 🙁 / I can connect to the database however this php script does not create the tables. Any suggestions? I am using a MYsql db under Godaddy.
i copied the script from your website word by word made the conexions and everything and i only get sad faces….
cool
You the Man Adam ! .. Learned so much just by following you step by step.. Each day I'm learning how code works..
$query=mysqli-query($db_conx,$tbl_users);
this line here the $db_conx does it have to be your database name?
Adam thank you very much.
Thanks Adam!
why are you writing UNIQUE KEY username (username, email)?
shouldnt it be: UNIQUE KEY(username, email)??
do you've to have a actual registered domain name to test out the make my tables php file , to see if it works? , and that goes for the database conx , right?
amazing!
GENIOUS!
Adam i have tell you that you help me very much in my programming carrier. Thanks bro