• Thursday , 21 September 2017

PHP MySQL Tutorial: Connect to a MySQL Database -HD-

Code Canyon



In this tutorial, you will learn how to connect to a MySQL database using PHP. Be sure to SUBSCRIBE because there will be a new tutorial every week. Follow …

Original source

3d Ocean

Related Posts

25 Comments

  1. Lovely Heart
    August 20, 2017 at 12:36

    you are number 1

  2. hannah ajayi
    August 20, 2017 at 12:36

    What if you are using phpmyadmin? Would it be the same process?

  3. Jack Claudiu
    August 20, 2017 at 12:36

    Doesn't work. I get this when I try to run localhost/mysql_connect.php –> Object not found!

    The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

    If you think this is a server error, please contact the webmaster.

    Error 404

    localhost
    Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28

  4. Felipe Cort
    August 20, 2017 at 12:36

    thanks !! Good tutorial, it s very abstract until getting all working!

  5. Leon Safal
    August 20, 2017 at 12:36

    it says "Parse error: syntax error, unexpected T_ECHO in C:connect.php on line 10" what can i do to fix it can anybody help me??

  6. Umut Karapınar
    August 20, 2017 at 12:36

    selamlar olsun

  7. Arkaidyn
    August 20, 2017 at 12:36

    Can someone help me out? Got this error message; **(I"ve solved this now, resolution is at the bottom for anyone that needs it)**
    Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:xampphtdocstest_db.php:8 Stack trace: #0 {main} thrown in C:xampphtdocstest_db.php on line 8

    this is my php;
    1 <?php
    2
    3 $db_host = "localhost";
    4 $db_username = "root";
    5 $db_pass = "password";
    6 $db_name = "test_database";
    7
    8 @mysql_connect("$db_host","$db_username","$db_pass") or die ("Could not connect to MySQL.");
    9 @mysql_select_db("$db_name") or die ("Cannot find specified database.");
    10
    11 echo "You have successfully connected to the database.";
    12 ?>

    Resolution from here down 🙂
    I did a bit of googling and as of PHP version 5 the line "@mysql_connect" is not supported anymore, so instead i did the following to connect;
    1 <?php
    2
    3 $connection = mysqli_connect('localhost', 'root', 'password2016', 'test_database');
    4
    5 mysqli_query($connection, 'CEATE TEMPORARY TABLE `table`');
    6
    7 echo "You have successfully connected to the database.";
    8 ?>

  8. Apollyon
    August 20, 2017 at 12:36

    🙂 so that means that any sign up form that i make in that page it will appear on my db?

  9. Ruttna Samhället
    August 20, 2017 at 12:36

    In order to make extend my db-connect script to take a username and password from form input and modify those values in the included file to I have to declare the form data variables as globals?

  10. orange18
    August 20, 2017 at 12:36

    can u show how to create a database and how to configure database like where did u get the test123

  11. Viral Thread
    August 20, 2017 at 12:36

    i just get a blank screen. i am using filegator

  12. Dukez Venom
    August 20, 2017 at 12:36

    the first part is working, but selecting my db wont work

  13. Daniel Nicolas
    August 20, 2017 at 12:36

    Hi, I don't seem to be able to connect to my db.  I followed everything to the letter.  Can I talk to you?

  14. Anna Turitsyna
    August 20, 2017 at 12:36

    THANK YOU SO MUCH! Helping me get through my project.

  15. William Pearson
    August 20, 2017 at 12:36

    Im looking for a tutorial that will tell me how to call down information from a specific row. 

  16. Graphic Island
    August 20, 2017 at 12:36

    I tried connect to my database and it did work. Please tell me whats wrong with my code.

    <?php
    $Name= $_POST ['Name'];
    $Number= $_POST ['Number'];
    define ( 'DB_NAME', 'counter');
    define ( 'DB_USER', 'bartleys_latty');
    define ( 'DB_PASSWORD', 'romans828');
    define ( 'DB_HOST', 'localhost');

    $link = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)
        or die (mysql_error());
    if ($link == true){
    echo "connected successfully";    
    }

    $select_db = mysql_select_db('DB_NAME');

    if ($select_db == false){
        
    echo "did not connect";    
    }

    mysql_query($sql, $link);
    ?>

  17. Alec Worwa
    August 20, 2017 at 12:36

    or die… yeah this is a coding language for me. 

  18. Kerim Timirbulatov
    August 20, 2017 at 12:36

    Hi, i'd like to know when we connect PHP to the Database, 
    Do you need more than one connection to it, i mean when you have a Website that should store data such as: (registered users, orders, comments, so on). Is MySQL database that smart to store every peace of database itself after defining one connection to it with PHP?
    I'm actually using wordpress, but i'd like to know the basics behind it.

  19. Wennie Sasotona
    August 20, 2017 at 12:36

    Thanks bro

  20. Uchan Hatari
    August 20, 2017 at 12:36

    Very clear and helpful.
    Well done!

  21. Kerim Timirbulatov
    August 20, 2017 at 12:36

    Do i need to have any database before executing that mysql_connect.php file On Localhost? cause mine says "Could not find any database"

  22. MangoIceCreamLover
    August 20, 2017 at 12:36

    doesnt work

  23. jinjakka
    August 20, 2017 at 12:36

    thanks. helped a lot

  24. Katsune Shinsengumi
    August 20, 2017 at 12:36

    I wish you have numberings on your videos. Good tutorial though,.

  25. Sunny Jain
    August 20, 2017 at 12:36

    thax dude great….!!!!

Leave A Comment

You must be logged in to post a comment.