By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,729 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,729 IT Pros & Developers. It's quick & easy.

No luck making a databast connection

P: n/a
I've included db.php into my script, and this is all it contains:

$host = 'localhost';
$username = '***';
$password = '***';
$database = '***';
$connection = mysql_pconnect($host, $username, $password);
$mysql_select_db($database, $connection);

obviously with the other fields filled out.

My webhost tells me to use this script:

$dbh=mysql_connect ("localhost", "<USERNAME HERE>", "<PASSWORD HERE>") or
die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("<TABLE NAME>");

neither one of these methods work, actually - I get this error:
[the contents of my db.php file here, in plain text!]No Database Selected

Anyone know what I'm doing wrong?
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

$dbh=mysql_connect ("localhost", "<USERNAME HERE>", "<PASSWORD HERE>") or
die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("<TABLE NAME>"); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^???
should be:
mysql_select_db($database);
neither one of these methods work, actually - I get this error:
[the contents of my db.php file here, in plain text!]No Database Selected

Anyone know what I'm doing wrong?

Good luck this time!
Wangs
Jul 17 '05 #2

P: n/a
"Taliesson Wang" <wa****@163.net.no.spam> wrote in message
news:bo***********@news.wplus.net...

$dbh=mysql_connect ("localhost", "<USERNAME HERE>", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("<TABLE NAME>");

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^???
should be:
mysql_select_db($database);

neither one of these methods work, actually - I get this error:
[the contents of my db.php file here, in plain text!]No Database Selected
Anyone know what I'm doing wrong?

Good luck this time!
Wangs


That's what I've been doing

doesn't work!
Jul 17 '05 #3

P: n/a

"Taliesson Wang" <wa****@163.net.no.spam> wrote in message
news:bo***********@news.wplus.net...

$dbh=mysql_connect ("localhost", "<USERNAME HERE>", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("<TABLE NAME>");

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^???
should be:
mysql_select_db($database);

neither one of these methods work, actually - I get this error:
[the contents of my db.php file here, in plain text!]No Database Selected
Anyone know what I'm doing wrong?

Good luck this time!
Wangs


This is what i have, the database is empty, and it's just a testing server
anyway, so you can have the username+password:

$host = 'localhost';
$username = 'yem_dbtest';
$password = 'dbpass';
$database = 'yem_testdb';

$connection = mysql_connect($host, $username, $password);

//$mysql_select_db($database, $connection);
mysql_select_db($database);

Not working!!!
This is what I have on my IE:

$host = 'localhost'; $username = 'yem_dbtest'; $password = 'dbpass';
$database = 'yem_testdb'; $connection = mysql_connect($host, $username,
$password); //$mysql_select_db($database, $connection);
mysql_select_db($database); No Database Selected
Jul 17 '05 #4

P: n/a
> Not working!!!
This is what I have on my IE:

$host = 'localhost'; $username = 'yem_dbtest'; $password = 'dbpass';
$database = 'yem_testdb'; $connection = mysql_connect($host, $username,
$password); //$mysql_select_db($database, $connection);
mysql_select_db($database); No Database Selected


If *this* really is what your IE comes up with, than it's just that the
page doesn't get parsed with PHP! Cause it's showing it as plain text.
Is it a *.php file? And do other *.php files work for instance with only
<?php phpinfo(); ?>

stevijn
// @
// drbobco
// .com
Jul 17 '05 #5

P: n/a
>
$host = 'localhost'; $username = 'yem_dbtest'; $password = 'dbpass';
$database = 'yem_testdb'; $connection = mysql_connect($host, $username,
$password); //$mysql_select_db($database, $connection);
mysql_select_db($database); No Database Selected

seems that your php engine not work.
check the doc type, maybe should be .php not .php3.

T.Wang
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.