This is a discussion on No luck making a databast connection within the PHP Language forums, part of the PHP Programming Forums category; I've included db.php into my script, and this is all it contains: $host = 'localhost'; $username = '***'; $password = '***'; $database = '***'; $connection = ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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? |
|
|||
|
> > $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 |
|
|||
|
"Taliesson Wang" <wangii@163.net.no.spam> wrote in message
news:bo7bfh$2soj$1@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! |
|
|||
|
"Taliesson Wang" <wangii@163.net.no.spam> wrote in message news:bo7bfh$2soj$1@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 |
|
|||
|
> 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 |
|
|||
|
>
> $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 |