Jump to content

MYSql Connection Issues


adamdavis

Recommended Posts

edit: Sorry, forgot to include MySQL Version Info: "MySQL client version: 3.23.49"

 

 

Hello. I will preface this with the fact that I have very limited MySQL experience.

Right now I am simply trying to be able to login to my database and run queries via PHP.  However when I do so i am receiving the following error message;

 

Could not connect to the database:

connect failed

 

The Code which i am using is pasted below;

test.php

<?php

require_once('db_login.php');

require_once('DB.php');

$connection = DB::connect("mysql://$db_username:$db_password@$db_host/$db_database");

if (DB::isError($connection)){

die ("Could not connect to the database: <br />". DB::errorMessage($connection));

}

$query = "DROP TABLE purchases";

$result = $connection->query($query);

if (DB::isError($result)){

die("Could not query the database: <br />". $query." ".DB::errorMessage($result));

}

echo "Table dropped successfully!";

$connection->disconnect( );

?>

 

I have verified that the login information include in my db_login.php allows me to login to PHPadmin where i can view / modify the database, so i assume this information should also be good for use in my php files to access MySQL.  Any help / suggestions you may be able to provide will be appreciated, thank you. :)

Link to comment
https://forums.phpfreaks.com/topic/171668-mysql-connection-issues/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.