0

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.

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Coyx
0

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/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.