PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi, i'm new to php and i'm trying to connect to a database that I've made with phpMyAdmin.
I exported the database as a .sql file en added it to my project folder
when I run my project it always says no rows found.
This is the first time I'm trying to connect to a db with php so i think it's a stupid mistake.
Firstly you don't need to export the database in order to connect to it. The exported file is simply a text dump of the database and its structure and contents.
You connect directly to the database that you created using phpMyAdmin - this is running under a mySQLd process that will serve the database and make it available for connections. Assuming you are running phpMyAdmin locally and also creating the database on your local host the connection details would be:
// set database server access variables:
$host = "localhost"; // Server name can found found at the top of the phpMyAdmin page
$user = "";
$pass = "";
$db = "upload"; // Database name as listed in phpMyAdmin (i.e. without the .sql suffix)
// open connection
$connection = mysql_connect($host, $user, $pass);
You may not ever come across the actual database file with MySQL - in most normal circumstances you will never need to. simply connect to the server that is running mySQL and the database will be available to you.