It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

Connecting to DB in PHP

Moderator: Malcolm

Connecting to DB in PHP

Postby vexer007 on Mon May 30, 2005 8:58 am

Hello all,

I am not sure what is going wrong. I used a piece of code to connect to my DB in my university server, and now using the same code on an external server which am paying money for hosting but the code keeps on giving me this error

Here is the code

if (!$conn = new COM("ADODB.Connection"))
exit("Unable to create an ADODB connection");


$strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("Change-DB.mdb");
$conn->open($strConn);


Here is the error:

Fatal error: Cannot instantiate non-existent class: com in /home/eorogun/public_html/registerprocess.php on line 3

Line 3 being the If statement line above.
I am using an Access DB and PHP and I uploaded the DB to the servers www folder.

Any help is much appreciated please.

Thank you all.
[/b]
vexer007
 
Posts: 0
Joined: Mon May 30, 2005 8:51 am
Location: London

Postby webmaster on Mon May 30, 2005 11:21 am

Hi and welcome to DEVPPL

This is how I do it:
Code: Select all
<?

$location = "localhost";
$username = "root";
$password = "pass";
$database = "dbname";
$conn = mysql_connect($location,$username,$password);

if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");

?>


The problem could be that the database doesen't accept remote connects, so only localhost can access it.
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden


Who is online

Users browsing this forum: No registered users and 1 guest