Posted by Ivan Marsh on 06/18/07 22:35
On Mon, 18 Jun 2007 15:21:34 -0700, Computer Guy wrote:
> Hi I have recently started working with PHP and am making a neighborhood
> website. I am connecting to my Mysql database and am having difficulty
> understanding what is happening in the example on the PHP website. It
> connects fine but I do not understand the code. I do not just like to
> take other people's code so if someone can explain this to me that would
> be great.
>
> <?php
> $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if
> (!$link) {
> die('Could not connect: ' . mysql_error());
> }
> echo 'Connected successfully';
> mysql_close($link);
> ?>
>
> I do not understand the if (!$link) part what does the ! mean and what
> is the value of link?
It's checking to see if $link has been assigned a valid connection. The
exclamation point means "not" or "false" however you'd like to turn it
into English.
[Back to original message]
|