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
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
25 responses to “PHP MySQL Tutorial: Connect to a MySQL Database -HD-”
you are number 1
What if you are using phpmyadmin? Would it be the same process?
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
thanks !! Good tutorial, it s very abstract until getting all working!
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??
selamlar olsun
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 ?>
🙂 so that means that any sign up form that i make in that page it will appear on my db?
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?
can u show how to create a database and how to configure database like where did u get the test123
i just get a blank screen. i am using filegator
the first part is working, but selecting my db wont work
Hi, I don't seem to be able to connect to my db. I followed everything to the letter. Can I talk to you?
THANK YOU SO MUCH! Helping me get through my project.
Im looking for a tutorial that will tell me how to call down information from a specific row.
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);
?>
or die… yeah this is a coding language for me.
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.
Thanks bro
Very clear and helpful.
Well done!
Do i need to have any database before executing that mysql_connect.php file On Localhost? cause mine says "Could not find any database"
doesnt work
thanks. helped a lot
I wish you have numberings on your videos. Good tutorial though,.
thax dude great….!!!!