Help - Search - Member List - Calendar
Full Version: cannot connect to database -_-
WorkTheWeb Forums > Web Hosting Help > MySQL Help
Support our Sponsors!
cpweaver
i can connect to the server but i cannot seem to connect to my database?

here is my code

CODE


<?php

$dbcnx = @mysql_connect("localhost", "username", "password");

if (!$dbcnx) {
 echo( "<P>Unable to connect to the " .
       "database server at this time.</P>" );
 exit();
} else {

echo ' Connected to the database server!';
}
//time to connect to the database
mysql_select_db("database_name", $dbcnx);

if (!@mysql_select_db("database_name") ) {
 echo( "<P>Unable to locate the Calendar " .
       "database at this time.</P>" );
 exit();
}


?>




Thanks
-Paul
phpfreak
Paul, in the future please do not post your username or password, or even dabase name.

What errors are you getting?
cpweaver
well when i run this script i get this back

Connected to the database server!

Unable to locate the Calendar database at this time.

when i try to select the database i guess it is failing?

i also tried using this to add a table to the database and it did not work

CODE

<?
// connect to mysql and select database
$db = mysql_pconnect("localhost","USER","PASS");
mysql_select_db("DATABASENAME",$db);

// build query
$create = "CREATE TABLE news(
id INT(5) unsigned NOT NULL auto_increment,
author VARCHAR(32),
content TEXT,
posted DATE,
PRIMARY KEY (id));";

// run the query
mysql_query($create);
?>
phpfreak
Have you granted permissions to this database for this user in cPanel? You may want to submit a support ticket and our staff can help you there.
cpweaver
LOL...

oh my... i totally forgot about that part. I have not played with mysql for awhile..

thanks eric!

PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.