views:

40

answers:

2

Ok I creating an application that needs to query records from my remote database. I am logged into phpmyadmin and I need to connect to this from my new PHP application. I have the cpanel access and the phpmyadmin tab. Is there something i can do to get the info needed to do this

$connection = mysql_connect(DB_HOST,DB_USER,DB_PASS,true);
mysql_select_db(DATABASE, $connection);
A: 

First of all:

Your remote database needs to be accessible by tcp/ip.

Second:

<?php

    //connect to db
    mysql_connect (DB_HOST, DB_USER, DB_PASSWORD);
    mysql_select_db (DB_NAME);

    $strSQL = "SELECT col1,col2 FROM "  . DB_NAME . "." . "tbl1";

    $obj = mysql_query ($strSQL, $objMySQL_Read);  
?>
Andreas Rehm
+2  A: 

In the Databases section of cpanel, click on the icon labeled "MySQL Databases". There you can create databases and users.

The hostname was probably provided in your welcome email, along with your FTP access. Anyway, it should appear at the top of your phpMyAdmin page, under the label "Server:"

Sebastián Grignoli
Thank you very much that was really helpful but i dont have the server info. When i look at the label Server it tells me localhost. That is fine if I am on that server, but i will be somewhere else so is there a way to retrieve this Hostname
Matt
If you don't have your welcome email you should ask your provider. I looked around but didn't find anything.
Sebastián Grignoli