PHP Tutorial for Beginners 30 # How to connect to MySQL database using PHP

preview_player
Показать описание
PHP Connect to the MySQL Server
connecting to mysql database php
android connecting to php mysql
How to access a MySQL database with PHP code
How to Connect to MySQL From a PHP Document
3 Ways to Connect to MySQL Using PHP
MySQL Tutorial - Connect
PHP/MySQL Tutorial
Connect to Your MySQL Database using PHP
PHP Connect to the MySQL Server
Рекомендации по теме
Комментарии
Автор

If you are getting error on using "mysql_connect()" and "mysql_select_db()" use instead "mysqli_connect()" and "mysqli_select_db()". And "mysqli_select_db()" needs 2 parameters: (1) mysqli_connect(); (2)'database_name'.Also I am using latest version so I haven't set password for database. Here is the code that worked for me :
$mysql_host='localhost';
$mysql_user='root';
{
die('Connection unsuccessful');
}
else
{
if(mysqli_select_db(mysqli_connect($mysql_host, $mysql_user), 'students'))
{
echo 'connection success';
}
else
die('can not connect to data base');
}
?>

noobiebro
Автор

mysql_connect() is depecrated. use mysqli_connect() instead :)

ForgottenLegendsOfTomorrow
Автор

Yeah Thank U Sir Now I'm not worry.
Now I can get easily connected to database Successfully.
Thanks a lot Good Bye.

raghuveerb
Автор

Very nice! I'm really enjoying your lessons. 
I watched from beginning to here .. (y) I'm learning a lot .. congratulations!

renaturjf
Автор

It giving me this error
"Fatal error: Uncaught Error: Call to undefined function mysql_connect() in Stack trace: #0 {main} thrown in on line 7"

yayalabayneh
Автор

Anyone who is facing regarding the error "Call to undefined function mysql_connect()" try using this
<?php
$dbhost = 'localhost';
$user ='root';
$pass ='';
$db ='testdb'; // databasename
$conn=mysqli_connect("$dbhost", "$user", "$pass", "$db");
echo "Connected";

?>

waichan
Автор

Sir I hv installed campo and running successfully, I have changed the password through phpmyadmin-user account-root local host-edit priveledge.But connection through PHP is giving error, I have tried as per your codes and with the changed password.Please clear the bug

rajeshupadhyaya
Автор

hello sir, why code is printed on a screen while connecting to database?

ankitgrover
Автор

as of 2020 mysql_connect won't work use mysqli_connect instaed

sparshtaneja
Автор

Enjoying your videos but i get a fatal error:call to undefined function mysql_connect in C..
Any help?

johnkaita
Автор

It's showing an error. Please tell me why so? It's showing that Filezilla is not found. And phpmyadmin showing as access denied

pushparay
Автор

says a lot that 40, 000 people couldnt figure it out by looking in the sql program / php program

rw
Автор

I did not set any password during installation, what should I do?

nikkipandey
Автор

i'm using ubuntu.
i'm getting this error "localhost is currently unable to handle this request.
HTTP ERROR 500" please help me

mohammedmuzammil
Автор

Fatal error: Uncaught Error: Call to undefined function mysql_select_db() in C showing this error help me

skyflowertraders
Автор

Sir this is old way pls update this video

us
Автор

sir i tried to change the password from phpmyadmin but suddenly it disconnected and strated showing the following message


Error

MySQL said: Documentation
#1045 - Access denied for user 'root'@'localhost' (using password: NO)
mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

sankhyadipchoudhury
Автор

i was getting error 500 in my chrome (Ubuntu 16.04 LTS)
and firefox shows just a white screen

everything worked and including echo, except "mysql_connect"

at last, it it was "mysqli_connect" in php7.0

that "i" wasted my 5 days (reinstalled ubuntu, , lamp, phpmyadmin.... and running many commands in terminal)

i am writing that, because it can save 5 days of someone.. lol :P

devalkathrecha
Автор

What if we didn't set password during install?

traveller
Автор

i got this error (i am using windows 10)
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in Stack trace: #0 {main} thrown in on line 9

VeErEnDrAVeErU