Connecting to a Remote Host who uses PHPMyAdmin
I have a remote host who uses phpmyadmin.
How do I create a connection string in my php pages to connect (I have all the relevant remote host, username and password), to connect to the host?
I have a remote host who uses phpmyadmin.
How do I create a connection string in my php pages to connect (I have all the relevant remote host, username and password), to connect to the host?
You could use somethings like this:
<?php
$hostname_conn = "localhost";
$database_conn = "databasename";
$username_conn = "username";
$password_conn = "password";
$conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Replace the italics with your own info. It really doesn't matter what program the host uses to view the database.
More info here:
function.mysql-pconnect
Thank you for your help. Would this be on each php page or in singularly in the connections php, for example : connections/mysql.php
You only need to connect once.
Create a php document and put code in it:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_bgweb = "localhost";
$database_bgweb = "database name";
$username_bgweb = "database user name";
$password_bgweb = "database password";
$bgweb = mysql_pconnect($hostname_bgweb, $username_bgweb, $password_bgweb) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Just that text, nothing else.
Save this as (say) connect.php in a folder called Connections
Then at the beginning (first line) of any php page that needs to make a connection to your mySql database put the line:
<?php require_once('Connections/connect.php'); ?> (or whatever the path would be in relation to your page)
This is neater and easier in the long run, - DreamWeaver for example will look in the 'Connections' folder to see if you have a connection already set up, and will use it automatically as an option if ever you are creating code that requires calling on your mySql database.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.