Re: Connecting to a MySQL database
| From: | John | Date: | Mon, 14 Apr 2003 20:03:32 +0000 |
| Subject: | Re: Connecting to a MySQL database | ||
| References: | 1 2 3 | Groups: | php.install |
| Request: | Send a blank email to php-install+get-10627@lists.php.net to get a copy of this message | ||
Here is the connection/query stuff I use. the $dbHost, etc., variables are
stored in a seperate file and I use an include statement.
mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error
connecting to
database.");
@mysql_select_db("$dbDatabase") or die ("Couldn't select the database.");
$query="select blah blah blah";
$result=mysql_query($query);
mysql_close();
John
"David Fleming" <ddallasnc@dslextreme.com> wrote in message
news:3E99D0CB.405AD038@dslextreme.com...
> <?php
> $conn = mysql_connect("localhost", "john","");
> mysql_select_db("contactDB", $conn);
> ?>
>
> Does not work and gives the typical "This document contains no data ... as
it always
> does when the script has a problem. Do I not have something setup right in
the
> php.ini file?
>
>
> The following DOES work.
>
> <?php
> $conn = mysql_connect("localhost", "john","");
> echo "$conn";
> ?>
>