No luck making a databast connection

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 = ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-04-2003
Julian Wright
 
Posts: n/a
Default No luck making a databast connection

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?


Reply With Quote
  #2 (permalink)  
Old 11-04-2003
Taliesson Wang
 
Posts: n/a
Default Re: No luck making a databast connection


>
> $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


Reply With Quote
  #3 (permalink)  
Old 11-04-2003
Julian Wright
 
Posts: n/a
Default Re: No luck making a databast connection

"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!


Reply With Quote
  #4 (permalink)  
Old 11-04-2003
Julian Wright
 
Posts: n/a
Default Re: No luck making a databast connection


"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


Reply With Quote
  #5 (permalink)  
Old 11-04-2003
Dr.Bob
 
Posts: n/a
Default Re: No luck making a databast connection

> 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


Reply With Quote
  #6 (permalink)  
Old 11-04-2003
Taliesson Wang
 
Posts: n/a
Default Re: No luck making a databast connection

>
> $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


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:49 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0