Hi,
My phpmyadmin is inside the server. I want to connect my database from my remote PC to the database in the server using php. I would greatly appreciate if someone can suggest a way to connect the database remotely in windows platform.
Thank you.

Recommended Answers

All 2 Replies

Set your GLOBALS in a constants.inc.php file, or something similar. So;

$db_server would be: (for example) 127.0.0.1
$db_user would be: (for example) root
$db_pass would be: (for example) password

Use this as a function to connect to your databases in your code.

function dbConnect()
{
    @mysql_connect($GLOBALS['db_server'], $GLOBALS['db_user'], $GLOBALS['db_pass']) or trigger_error("Could not connect to MySQL database", E_USER_ERROR);
}
function dbOpenDatabase($dbName)
{
    @mysql_select_db($dbName) or trigger_error("Unable to access $dbName database", E_USER_ERROR);
}

To connect to your database, simply do this in the code where you'd like to connect;

dbConnect();
dbOpenDatabase('mydatabase');

To connect to your databases through phpMyAdmin to make changes, etc etc; in your browser - simply do your webservers IP address or domain name like so.

http://127.0.0.1/phpMyAdmin/
http://www.yourwebsite.com/phpMyAdmin/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.