Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2011
    Location
    Blackpool
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post

    Connecting to a Database with Video

    Hey guys, In this thread I give you the code on how to easily connect to a database and I explain what everything does in the video below.
    Don't feel like you have to watch the video if you know what you're doing.
    PHP Code:
    <?
    //database infomation
    $dbhost "localhost";
    $dbname "projectdb";
    $dbuser "root";
    $dbpass "";
    //connect to client.
    mysql_connect $dbhost$dbuser$dbpass)or die("Could not connect: ".mysql_error());
    mysql_select_db($dbname) or die(mysql_error());
    ?>
    If you would like to know what everything does (explanation of code) check the video.
    https://www.youtube.com/watch?v=ThFjPinDod0
    Hope you guys have a good day
    Subscribe to a channel dedicated to helping people learn HTML, PHP & CSS.
    http://www.youtube.com/user/RanTutorials

  • #2
    New Coder
    Join Date
    Sep 2011
    Location
    Blackpool
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post
    Quote Originally Posted by connormcwood View Post
    *Snip*
    Would just like to add that the DBname is the database name of which the tables are sometimes users on hosts just have one while on xampp for example you can have many. DBuser & DBpass is set up with root and nothing in for each other them as that is how you connect to xampp while other localhosting software or webhost will be different.
    Subscribe to a channel dedicated to helping people learn HTML, PHP & CSS.
    http://www.youtube.com/user/RanTutorials

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I'll add as well:
    This functionality is deprecated as of PHP version 5.5.0 and will be removed in a future version. The MySQL library is in maintenance only phase, and will be replaced with MySQLi library. Any new code written (backed by MySQL dbms) should be done using either the MySQLi library, or the PDO library instead.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    connormcwood (10-05-2013)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •