Re: isset problem
| From: | Philip Olson | Date: | Sun, 17 Dec 2000 19:30:08 +0000 |
| Subject: | Re: isset problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30756@lists.php.net to get a copy of this message | ||
The way I see it you should get parse errors each time. Count your ('s
and )'s .
if ( isset($foo) )
or
if ( (isset($foo)) )
Keeping the if ( ) spaced out is helpful. So in your case, you want :
if ( isset($firstname) && isset($lastname) && isset($phone) ) {
And I am unsure if your use of '<' is a typo but it does not belong, at
all. Also, consider empty() and strlen() and ereg() and ... :-)
Regards,
Philip
--.sig
[ Want to write Good code? First, write Bad code. ]
On Sun, 17 Dec 2000, Douglas A. Maske wrote:
> Hello,
> I am new to php 4. I am trying to modify a script I downloaded to
> add more than the name to a mysql database, I wanted first and last name.
> The question is, why does php accept the following:
>
> <?
> if (isset($firstname) && isset($phone)< {
> mysql_connect("localhost", "surreal", "123654");
> $query = "INSERT INTO mytable VALUES ('$firstname',
> '$lastname',
> '$phone
> ')";
> $result = mysql_db_query("example", $query);
>
> if ($result) {
> echo "<$firshname $lastname was added to the database</p>";
> }
> }
> ?>
>
> But when I change the first one line to this:
> <?
> if (isset($firstname) && isset($lastname) && isset($phone)< {
>
> I then get a parse error? how can I specify more than 2 issets in one
> line?
>
> Thanks,
> Doug
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>