Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.