Re: No Database Connection possible (mySQL)
| From: | David Robley | Date: | Fri, 04 Jul 2008 10:02:33 +0000 |
| Subject: | Re: No Database Connection possible (mySQL) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-276283@lists.php.net to get a copy of this message | ||
Aviation Coding wrote:
> Hi all,
>
> I am having problems with a connection to a mysql database.
>
> I am using
>
> ----
> function con()
> {
> mysql_connect("localhost","user","pass") or die(mysql_error());
> mysql_select_db("tava") or die(mysql_error());
> }
> ----
>
> Now, when I call the _function_ (!)
> ----
> con() or die("no con");
> ----
> I get the "no con" output.
>
> When I call the mysql_connect and mysql_select directly before executing a
> query, I get some DB output. But that won't work when I am using the
> function...
>
> Any ideas would be greatly appreciated.
>
> Cheers!
>
> Chris
I think you need to return something from the function, like true if the
connection/select worked, false if not.
Cheers
--
David Robley
If I were two faced, would I wear this one?
Today is Setting Orange, the 39th day of Confusion in the YOLD 3174.