Connect to MySQL with PHP in XAMPP / Create a new database

Поділитися
Вставка
  • Опубліковано 15 жов 2024

КОМЕНТАРІ • 380

  • @kenson_kw
    @kenson_kw 2 роки тому +93

    I just realized, information never dies! This video is 8 years old and turns out this information is exactly what i needed and how i needed it in 2022 😮‍💨. Thank you dude!

  • @GabbeSama
    @GabbeSama 4 місяці тому +1

    i'm a student and i'm here to say that your video still saves me, thanks a lot!

  • @rahulsyt_
    @rahulsyt_ Рік тому +1

    10 years later I am watching these videos. Real G(Old) videos.

  • @maxmoore8480
    @maxmoore8480 8 років тому +6

    This tutorial was not only exactly what I needed but well explained, clear, and slow but concise, thanks a lot!

  • @TheOriginalDarkGlitch
    @TheOriginalDarkGlitch 4 роки тому +1

    Thanks for making this video. I just started fooling around with MySQL and was following another tutorial that didn't explain this part at all.

  • @Mayur_
    @Mayur_ 10 років тому +15

    Thank you!
    :)
    I was trying to connect html form to my database, wasn't working.
    But it's perfect now.
    Simple and correct video.

  • @Tommeke11
    @Tommeke11 10 років тому +4

    Thank you for this video! My course notes weren't complete for the starting part and connection. This video saved me from a lot of headaches. The start is definitely the most difficult part.

    • @KenSwartwout
      @KenSwartwout  10 років тому

      Getting started can be intimidating. Very happy to help!

  • @robynbazsika239
    @robynbazsika239 9 років тому +6

    Thanks so much. I am just teaching MySQL and PHP to my High School Students. This is a great video and very informative.

    • @KenSwartwout
      @KenSwartwout  9 років тому +3

      Great to hear. Getting started is one of the more difficult parts of the process.

    • @420blazeurmomacrossmaptoma5
      @420blazeurmomacrossmaptoma5 9 років тому +3

      Robyn Bazsika You're a teacher you swine, you should know this shit and not have to google it in order to understand it - i hate you and your students.

    • @420blazeurmomacrossmaptoma5
      @420blazeurmomacrossmaptoma5 9 років тому +1

      Robyn Bazsika 22 Middleton Rd, Kew, Dunedin 9012 got u bitch

    • @420blazeurmomacrossmaptoma5
      @420blazeurmomacrossmaptoma5 9 років тому +1

      420blazeurmom acrossmaptomahawk im coming to teach ur students a real lesson \
      for once

    • @420blazeurmomacrossmaptoma5
      @420blazeurmomacrossmaptoma5 9 років тому

      420blazeurmom acrossmaptomahawk .

  • @ismailabdow3844
    @ismailabdow3844 3 роки тому

    Now connected after 10hrs of struggling with other videos .. Very helpful

  • @swolyjr
    @swolyjr 7 років тому

    which program are you using in notepad++ to 'RUN' the php code? i lick run and it asks me to choose a program to run it. i dont know which program to choose.

  • @haritastbg
    @haritastbg 10 років тому +6

    Thank you Ken. I have just started learning php. This video is of great help to me to create my database and first php program.

    • @KenSwartwout
      @KenSwartwout  10 років тому

      Great to hear. Getting started with a test bed like XAMPP is a large barrier to overcome!

    • @shahsulaiman851
      @shahsulaiman851 5 років тому

      ulearn

  • @coolsmarty5137
    @coolsmarty5137 8 років тому

    I am unable to connect my database. it gives me error your php server doesn't have mysql module loaded or you cant use the mysql_(p) connect fuctions..can u suggest why?

  • @chethanabhaskara480
    @chethanabhaskara480 9 років тому +1

    This video is great. However, after creating a database using phMyAdmin, if I open the mysql shell via xampp control panel and query "Show databases" , I'm only seeing the 'test' database and not the one I created. How I do I access it using the shell?

  • @itstobystic
    @itstobystic 4 роки тому +1

    This guy's voice is cool, he made the video sound like a movie trailer. Thank you

  •  10 років тому

    I started with these:
    define('DB_NAME', 'test');
    /** Username MySQL */
    define('DB_USER', 'root');
    /** Password to the database MySQL */
    define('DB_PASSWORD', '');
    /** The server name MySQL */
    define('DB_HOST', 'localhost');
    And I get this messange:
    Could not establish database connection. Please check the username, password and hostname in the config file, and if necessary set up the appropriate MySQL user and privileges.
    Any idea?

  • @davidsmith-ws4bz
    @davidsmith-ws4bz 4 роки тому

    For learning right click the XAMPP ICON and select" Run as Administrator", otherwise its easy to end up locked out. Thanks for the vid.

  • @gunner9456
    @gunner9456 10 років тому +2

    when i click on the admin button, it gives me error 404 not found message .
    please tell me how tosolve this problem, please someone help me

  • @uday0532
    @uday0532 Рік тому +1

    Information never dies this is exactly what I need and it is from 9 years ago
    😄😄😄

  • @kennethkath6527
    @kennethkath6527 2 роки тому

    I've made a website but I cant save the data in the database which was entered by the user(me) in the website. I'm wondering whats wrong.

  • @lewioesports
    @lewioesports 7 років тому +1

    I didt everything you did in the video, but when i open the connect.php (i have it in the right folder /htdocs) it loads infinitly. Does someone know why it is loading all time?

  • @doc-holiday
    @doc-holiday 8 років тому

    I installed the xamp program on my own pc using Windows 10 and all seems fine and up and running but when i connect the mysql and follow your instruction its seems i am getting an error. I am not sure as to what is wrong here but something is telling me the directory folder for this script is incorrect.
    If i write basic php script all goes to plan using xamp but soemthing is telling me that the url of the data base is incorrect
    Any ideas?

  • @stevodoe4900
    @stevodoe4900 5 років тому +2

    Very Helpful thank you! As someone who struggles with learning PHP I thought this was one the best videos I've seen in a while. If you haven't done so would you consider doing a beginner PHP / MySqL Tutorial Series for phpMyAdmin. Preferably focus on more the PHP aspect but general overview of the others would amazing also.

  • @marcaboujaoude5874
    @marcaboujaoude5874 9 років тому

    sorry but when i'm running your code is giving that "sqli" was not found
    can you help me out on this one ?

  • @PanduricaBlues
    @PanduricaBlues 6 років тому +4

    That´s the voice I want to have in my tutorials. Even if you´d be talking about how to eat pudding I would listen to you :)

  • @certifiedprogrammer4598
    @certifiedprogrammer4598 6 років тому

    iam using vmware so that i used port 8080 in mysql so localhost:8080/myweb/conn.php is not working
    how i can get-rid of this problem Ken Swartwout plz?

  • @jupitersmoon_europa_
    @jupitersmoon_europa_ 4 роки тому

    honestly i still dont understand how to create a file.sql ? like you write the script on an editor saved with an .sql i guess, but how do u connect it with ur php file that got the data ?

  • @vavr8231
    @vavr8231 5 років тому

    But one question, why would you have a password if you dont use it? I mean in the code....

  • @vyuutuube
    @vyuutuube 9 років тому

    it does not kick me to phpmyadmin HTTP Error 404. The requested resource is not found.
    what can i do?

  • @yogendralakraj3214
    @yogendralakraj3214 4 роки тому

    i keep getting this error do you kbow whats going on:
    Fatal error: Uncaught Error: Class 'mysqli' not found in C:\Users\Andy Lakraj\phpproject\index.php:9 Stack trace: #0 {main} thrown in C:\Users\Andy Lakraj\phpproject\index.php on line 9

  • @vamsikrishnakikkuri2140
    @vamsikrishnakikkuri2140 6 років тому

    will "mysql_connect(host,user,password)" work.
    if yes please tell me how. i am having a problem when i have used it.

  • @theunknownhue
    @theunknownhue 7 років тому

    If i change my port for phpmyadmin,do i have to specify in the code too? or 'localhost' is all i need to write?

  • @chrisniell3915
    @chrisniell3915 6 років тому

    It can be access with different computers or guest ? Who connected to your hub.

  • @gopeswarnamasudra8895
    @gopeswarnamasudra8895 7 років тому

    well i tried to connect to databse in xampp through brackets but it gives me error , while i verified that php code like echo" xxxx"; runs well, but could not connect with the database ,always get some error please help

  • @juhainamusthafa
    @juhainamusthafa 5 років тому

    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.
    how to solve this sir???

  • @imtiazxkhan
    @imtiazxkhan 4 роки тому

    7 years and still this video is lit!!!

  • @larryshamala8929
    @larryshamala8929 2 роки тому

    hi thanks for your great work. i tried at once and it worked but then i dont know what happened. when i load the connect.php file on the browser it echos the html content. what is happenning?

  • @99plus89
    @99plus89 8 років тому

    It was a day saver for me! I tried 5-7 another PHP ways connect to the database on latest versions XAMPP Unsuccessfully. This video obviously showed the right way. Thank You very much.

  • @narsicreation7977
    @narsicreation7977 9 років тому

    I got this 'Parse error: syntax error, unexpected 'new' (T_NEW) in C:\xampp\htdocs', solution please ?

  • @aghartaatlantean4517
    @aghartaatlantean4517 5 років тому

    how can i create database on my computer only when i don't have phpmyadmin account set up already?

  • @apoozkan8361
    @apoozkan8361 6 років тому

    Hi, i did the same thing but it just shows my code when i run it ? how can i fix this

  • @radeepyenni5541
    @radeepyenni5541 6 років тому

    when i want to connect to database of other than the root then it was not connected what can i do to connect to the datbase of user account

  • @reynpimentel6819
    @reynpimentel6819 9 років тому

    i have a problem in starting the MySQL and i dont know wht to do

  • @davidmallar4608
    @davidmallar4608 7 років тому

    Can someone help me, when I click on admin button, my web browser opens but it says This site can't be reached. What to do?

  • @user-en5vj6vr2u
    @user-en5vj6vr2u 5 років тому

    how do you access the db now bc i barely know sql

  • @goatskills2382
    @goatskills2382 8 років тому

    +Ken Swartwout What should I do when I don't have a hosting (yet)?

    • @KenSwartwout
      @KenSwartwout  8 років тому +3

      +GoatSkills If you don't have a host, then a tool like XAMPP is exactly what you need. XAMPP (or similar tools) turn your local machine into a host.

  • @IshaqKhan010
    @IshaqKhan010 9 років тому

    thankss.. i question : we connect android to mysql database through localhost as we connect in java through mysql jdbc driver ? and the php script is neccessary to connect mysql database ?

  • @ronaldvonk
    @ronaldvonk 3 роки тому

    I don't really understund why you use the $db variable twice?

  • @saraosama18
    @saraosama18 8 років тому

    it does not work with me , shall i download xampp ?

  • @ayodelearibisala468
    @ayodelearibisala468 9 років тому

    hey how do you get that notepad youre using.. i think my netbeans is making it more difficult for me

    • @KenSwartwout
      @KenSwartwout  9 років тому

      +jerry walker Notepad++. It is free and very popular. Give it a try!

  • @babuhussain8215
    @babuhussain8215 8 років тому

    Warning: mysqli::mysqli(): (HY000/1049): Unknown database 'testdb' in C:\xampp\htdocs\connect.php on line 7 .
    im getting this error could u please guide..?

  • @tahsinhimu3609
    @tahsinhimu3609 2 роки тому

    finalllyyyy after trying for 3 days your way got this connected!

  • @subhashtitkare348
    @subhashtitkare348 6 років тому

    hi sir
    I want to change MariaDB to Mysql on xampp.
    plz tell me.

  • @unorthodoxjourney
    @unorthodoxjourney 10 років тому

    ken thanks for the video but i am getting access denied error and the message i have printed

  • @Herculean61
    @Herculean61 2 роки тому

    Do you have a video on an event locator database..just like this one

  • @kryptoniancuber6063
    @kryptoniancuber6063 6 років тому

    I think I'm connected, but my server won't load when I put in the connection :(

  • @vishnukv4186
    @vishnukv4186 7 років тому +1

    i got one error Fatal error: Class 'mysql' not found in C:\XAMPP\htdocs\test\connect.php on line 9
    on the line $db = new mysql('localhost', $user, $pass, $db) or die("unable to connect") ;

  • @TheAhernFamily1
    @TheAhernFamily1 9 років тому +19

    This is really easy to follow thanks for the great tutorial.

    • @KenSwartwout
      @KenSwartwout  9 років тому +1

      +Aheezy Da Islander You are welcome and thanks for the feedback.

  • @proo5577
    @proo5577 7 років тому

    Just used this works great. Any updated info I should look into?

  • @AISHUPONNE
    @AISHUPONNE 5 років тому

    what coding you using for connect.php

  • @nicolecaldwell168
    @nicolecaldwell168 8 років тому

    Where did you get the html that you copied and pasted.. you went too fast I could not follow

  • @sirrodd11
    @sirrodd11 10 років тому

    cant get my results to display! I type in localhost and I keep getting error
    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.9 (Win32) OpenSSL/1.0.1g PHP/5.5.11
    HELP!!

    • @deepakchaudhary392
      @deepakchaudhary392 10 років тому +2

      you must store your php file under xamp/htdocs/yourfile.php

    • @1nst1nkt
      @1nst1nkt 9 років тому

      Deepak Chaudhary
      thanks man!!

    • @NewVidDotCo
      @NewVidDotCo 9 років тому

      Deepak Chaudhary What if I am using Wamp Server 64. Would I have to store the php file in C:\wamp\bin\apache\apache2.4.9\htdocs ?
      Also another question what is the differences between Wamp and Apache?

  • @HustlerEli
    @HustlerEli Рік тому +1

    Amazing and well explained tutorial.

  • @ethanlee2197
    @ethanlee2197 10 років тому +3

    Hi there, I wanted you to know how much I appreciate you video. Thank you very much. I've been having trouble connecting to database for like a whole day and then after watching this video, man its funny really. I put the password as root.

    • @KenSwartwout
      @KenSwartwout  10 років тому

      When you are not sure exactly what you should be doing it can be a nightmare!

  • @karvin9
    @karvin9 9 років тому

    Thank you Ken, I found this video a lot more helpful than other videos I found online

  • @soudabuhanak7141
    @soudabuhanak7141 4 роки тому

    cool cool cook
    i watched a 100's of video regarding this, but all of that video no going success
    you are only the one who make it success 100%
    thank you so much
    voice tone amazing!!!
    i appreciate this video since 2013

  • @eldranoson1243
    @eldranoson1243 7 років тому

    xampp doesnt work some port for apache is always already used

  • @sticky13337
    @sticky13337 4 роки тому +1

    Still i woudlnt name the $db variable the same as the connector, it causes unwanted confusion.

  • @purpleprincess4126
    @purpleprincess4126 6 років тому

    Sir, will this also work on wamp server?

  • @surajk3651
    @surajk3651 8 років тому

    can u tell me the command for inserting values into the database..

    • @KenSwartwout
      @KenSwartwout  8 років тому +1

      +suraj k You can insert data from that admin console pretty easily. I assume you are asking what the SQL looks like - in that case, you are interested in an "INSERT" statement. There are tons of resources on creating an INSERT statement - a quick Google search will get you on your way!

  • @michairynizarichlellyn9721
    @michairynizarichlellyn9721 8 років тому +2

    " your php server doesn’t have the mysql module loaded or you can’t use mysql_(p)connect function."
    How do I fix this? Thanks

    • @krank3869
      @krank3869 5 років тому

      Make sure you have mysql running

    • @theoschnell2272
      @theoschnell2272 5 років тому

      You can start mysql in the control window that you can see in 0:05 in this video. Next to mysql is a start button.

  • @lakemartin4959
    @lakemartin4959 7 років тому

    I got it, so i'm giving you a thumbs up and because you don't move super fast and speak very plainly i.m going to subscribe...:-)

  • @eJelly183
    @eJelly183 10 років тому

    when i press on admin nothing happen it does not show anything

  • @laoadventuretour5012
    @laoadventuretour5012 2 роки тому

    Very good Video which easy to understand and thank you for sharing

  • @WOODSYMAN
    @WOODSYMAN 8 років тому +5

    I'm confused. You have two variables called $db. Why doesn't that cause an issue?

    • @xploit6589
      @xploit6589 7 років тому

      It just replaces the old variable as it runs from my guess..

    • @kenswartwout1246
      @kenswartwout1246 7 років тому +1

      I meant to call it $dbc, but as said below it works by overwriting the variable.

    • @loomer107
      @loomer107 7 років тому

      Andrew Woods I checked the comments specifically for this question. I highly recommend putting a small correction text banner on the video for good habit formation of novice viewers

    • @froglicker9267
      @froglicker9267 6 років тому

      it is good for new SQL code to reference the old as a template

  • @woofroof166
    @woofroof166 6 років тому

    the page is empty even when i used echo please help asap

  • @BrofaBloke
    @BrofaBloke 10 років тому +9

    No comments pointing out he used the $db variable twice? (Once to store the dbname and again to create the connection). Either way good video as this bit of information is often overlooked in the classroom...

    • @knlkumar
      @knlkumar 6 років тому

      assigned to a function mysqli with new prefix. i think both variable works differently even after having same name

  • @MohamedOsama-vj5jp
    @MohamedOsama-vj5jp 7 років тому

    How i can insert image url in phpmyadmin ? please reply

  • @mehakonline
    @mehakonline 7 років тому

    it is unable to load once database is added to it

  • @GlennGasner
    @GlennGasner 2 роки тому +1

    Thank you for this!

  • @TimeLords910
    @TimeLords910 5 років тому

    Does apache not have a password

  • @ankitabhishek5575
    @ankitabhishek5575 6 років тому

    thanks a lot.was misguided by other videos.saw yours and it worked.

  • @Nelseru
    @Nelseru 9 років тому

    it dosnet take me to theat page when i start up admin it takes me to a login page

    • @Nelseru
      @Nelseru 9 років тому +1

      420blazeurmom acrossmaptomahawk I don't even know what that means but it sounds derogatory...so...kiss my ass

  • @tareqmahmud3902
    @tareqmahmud3902 2 роки тому

    this is the cleanest tutorial ever! thank you, god bless you!

  • @fahmyamn13
    @fahmyamn13 10 років тому +1

    Localhost is always default is it ?

    • @KenSwartwout
      @KenSwartwout  10 років тому

      Yes, you are running it locally.

  • @rafaelmarques5623
    @rafaelmarques5623 8 років тому

    Hi Ken, great tuturial. I just don't know where should i save the php file, i'm newbie on this stuff.
    Thanks

    • @devchawda9414
      @devchawda9414 8 років тому

      +Rafael Marques C drive->xampp->htdoc there u should make ur project folder and then just save it there...... Enjoy!!!

    • @rafaelmarques5623
      @rafaelmarques5623 8 років тому

      +Dev Chawda thank you !

    • @devchawda9414
      @devchawda9414 8 років тому

      +Rafael Marques But u should install Xampp 1st :)

    • @rafaelmarques5623
      @rafaelmarques5623 8 років тому

      +Dev Chawda i know that

  • @harryjohn6736
    @harryjohn6736 4 роки тому

    can anybody tell me what is mysqli_connect(HY000/1049) ERROR ?
    plsss help me.

  • @arbudastudio5864
    @arbudastudio5864 2 роки тому +1

    This is really easy to follow thanks for the great tutorial. ☺

  • @MikesTrackBuilding
    @MikesTrackBuilding 9 років тому +1

    Thank you so very much for the little series. Are you by chance going to do some more videos showing how to create and query databases?
    Mike

  • @George_Washington_
    @George_Washington_ 4 роки тому

    hold on why use $db for database name and the connection function

  • @lakemartin4959
    @lakemartin4959 7 років тому

    move to fast... if you don't tell us and we can't see mouse motion we can't follow... I'm going to go here at 1:26 does not tell me anything or where you're going. But I did find it after going back twenty times.

  • @NikhilKumar-bn2mz
    @NikhilKumar-bn2mz 6 років тому

    im getting this erroe
    Parse error: syntax error, unexpected '$pass' (T_VARIABLE) in R:\xampp\htdocs\connect.php on line 3
    this is my code....
    anyone has a solution to this.

  • @KerleyVinas
    @KerleyVinas 9 років тому

    Excellent tutorial it saved me lots of time and aggravation...Quick question do you know how to make this work with a copy of an existing wordpress site? I tried and I got "Error establishing a database connection" Please help Thanks

    • @KenSwartwout
      @KenSwartwout  9 років тому

      Kerley Vinas You certainly can make it work. The issue is likely that you need to copy the database over to your installation of XAMPP. You probably only have a copy of the html/css/scripts - the DB is a separate entity. It is easy enough to import/export through phpMyAdmin.

  • @rafaelmarques5623
    @rafaelmarques5623 8 років тому

    Hi +Ken Swartwout , great tuturial. I just don't know where should i save the php file, i'm newbie on this stuff.
    Thanks

    • @David0072007
      @David0072007 8 років тому

      +Rafael Marques, if you have installed xampp on tu pc, save ty php file in x:\xampp\htdocs

    • @rafaelmarques5623
      @rafaelmarques5623 8 років тому

      +Jesus Santisteban thanks, alteady did that:)

  • @srilekhatulluri3766
    @srilekhatulluri3766 7 років тому

    I got this error. Can anyone plz help. Thank you in advance. mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO)

  • @venkateshprasad6432
    @venkateshprasad6432 6 років тому

    short and simple tutorials ,thanks dude

  • @ihabs2150
    @ihabs2150 7 років тому

    Do you have other videos for this topics?

    • @KenSwartwout
      @KenSwartwout  7 років тому +1

      Yes, I do. I don't have them particularly well organized but my channel is full of them. If you are getting started with PHP, then search my channel. Thanks for watching!

  • @iconsworld9
    @iconsworld9 2 роки тому

    Found this extremely useful, appreciate it

  • @elvisadjei2062
    @elvisadjei2062 9 років тому

    Good work done. uv really helped me in my assignment. Thumps Up......

  • @Shiroyashasama
    @Shiroyashasama 2 роки тому

    nothing happens when I try to run it

  • @lakshyasingh1771
    @lakshyasingh1771 2 роки тому

    I am no able to find this web site