• Sunday , 24 September 2017

3. MySQL Database Tables Creation PHP Script Logic Tutorial

Code Canyon



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

3d Ocean

Related Posts

40 Comments

  1. Teri E
    August 29, 2017 at 13:04

    Does anyone know why the ip address should be stored in the user table?

  2. SogMosee
    August 29, 2017 at 13:04

    this was dope!

  3. Sagar Balyan
    August 29, 2017 at 13:04

    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 !

  4. Felli fel
    August 29, 2017 at 13:04

    Creates other tables but fails to create the "users tables" , not sure why .Still troubleshooting though , share ur thoughts . !

  5. Rick Miles
    August 29, 2017 at 13:04

    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

  6. Mark Sampler
    August 29, 2017 at 13:04

    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
    ;

  7. Jer DES
    August 29, 2017 at 13:04

    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 🙂

  8. PhilMagicman
    August 29, 2017 at 13:04

    So if PRIMARY KEY('id') in table 'a', will that remain the users id in any other table in the database?

  9. Somber Response
    August 29, 2017 at 13:04

    How much of this is still valid?

  10. Somber Response
    August 29, 2017 at 13:04

    What if you wanted the ID in the first table to be random or increased by 10s?

  11. Lokesh Pandey
    August 29, 2017 at 13:04

    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";
    }
    ?>

  12. Dimitri Gbo
    August 29, 2017 at 13:04

    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?

  13. Mohammad Helal Uddin
    August 29, 2017 at 13:04

    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:

  14. Ricki Moore
    August 29, 2017 at 13:04

    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?

  15. Alex Casajuana
    August 29, 2017 at 13:04

    all'right i got nothing but smiley faces baby! :'DDD

  16. Dhruvil Thaker
    August 29, 2017 at 13:04

    no tables found in database

  17. Saul Gavrilov
    August 29, 2017 at 13:04

    If you have problem in MYSQL what I need do ?

  18. Abanoub Nassem
    August 29, 2017 at 13:04

    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 ^_^

  19. Raymond Jender
    August 29, 2017 at 13:04

    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?

  20. Birbilgi & Birsoru
    August 29, 2017 at 13:04

    it's not working

  21. Allan Alexander
    August 29, 2017 at 13:04

    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 🙁

  22. Michael G.
    August 29, 2017 at 13:04

    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!

  23. Kadiah Zaman
    August 29, 2017 at 13:04

    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. 

  24. Collin Platt
    August 29, 2017 at 13:04

    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.

  25. Richard Barrett
    August 29, 2017 at 13:04

    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)

    )";

  26. BunnyHop1337
    August 29, 2017 at 13:04

    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.

  27. DINEROA DIARIO
    August 29, 2017 at 13:04

    Wow bro! Thnx so much, run fineee! 😀

  28. Joseph Clement
    August 29, 2017 at 13:04

    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

  29. Chris Powell
    August 29, 2017 at 13:04

    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. 

  30. Alexius Laundromat
    August 29, 2017 at 13:04

    i copied the script from your website word by word made the conexions and everything and i only get sad faces….

  31. Joemckellar2014
    August 29, 2017 at 13:04

    cool 

  32. John Fit
    August 29, 2017 at 13:04

    You the Man Adam ! .. Learned so much just by following you step by step.. Each day I'm learning how code works.. 

  33. mohd sheraz
    August 29, 2017 at 13:04

    $query=mysqli-query($db_conx,$tbl_users);
    this line here the $db_conx does it have to be your database name?

  34. Mahammad Rustamzade
    August 29, 2017 at 13:04

    Adam thank you very much. 

  35. Cheap Cars Finder App - Autopten
    August 29, 2017 at 13:04

    Thanks Adam!

  36. kevin inalu
    August 29, 2017 at 13:04

    why are you writing UNIQUE KEY username (username, email)?
    shouldnt it be: UNIQUE KEY(username, email)??

  37. Patrick Jenkins
    August 29, 2017 at 13:04

    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?

  38. Ivan Rogic
    August 29, 2017 at 13:04

    amazing!

  39. Lucas Elias Gattás a.k.a Mr. Gattax
    August 29, 2017 at 13:04

    GENIOUS! 

  40. Alfy George
    August 29, 2017 at 13:04

    Adam i have  tell you that you help me very much in my programming carrier. Thanks bro 

Leave A Comment

You must be logged in to post a comment.