Re: Another Newbie Question
| From: | Nicole Amashta | Date: | Fri, 12 Apr 2002 19:09:16 +0000 |
| Subject: | Re: Another Newbie Question | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-13065@lists.php.net to get a copy of this message | ||
######## Your code:
<snip>
<?php
mysql_connect("nik", "", "") or
die("could not connect to the database");
mysql_select_db("guestbook") or
die ("could not connect to the specified database");
?>
</snip>
######## My code:
## Assuming "nik" is your host
## and no username and password are required ...
<snip>
$link = mysql_connect("nik", "", "") or die("Could not connect
to host.
Reason: " . mysql_error_message() );
mysql_select_db("guestbook", $link) or die ("Could not connect to the
specified database. Reason: " mysql_error_message());
</snip>
Notice that you need to get the return from mysql_connect and pass it as 2nd
param to mysql_select_db.
Hope that works.
--
Nicole Amashta
Web Application Development
ABOL Software, Inc.
"Nik Alleyne" <nik@guyanachronicle.com> wrote in message
news:20020410174328.38875.qmail@pb1.pair.com...
> Good evening everyone,
> I am new (very new) to php. I was doing some research on the net and learn
> of this packaged and after reading just a couple of pages, i figure i
should
> learn this instead of ASP. It looks so easy. Anyhow here is my problem.
>
> I am trying to connect to the database (MySQL) however, I can't I am
> connecting to the server, but I cannot connect to my sample database.
>
> Here is my script?
> <?php
> mysql_connect("nik", "", "") or
> die("could not connect to the database");
> mysql_select_db("guestbook") or
> die ("could not connect to the specified database");
> ?>
> I'm getting the "could not connect to the specified database" message.
> P.S. The database exists.
>
> Please Help
> Thx
> Nik
>
>
>
>