Re: MySQL PHP =@ symbol
- From: Chris Hope <blackhole@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 18 May 2005 05:47:22 +1200
Good Man wrote:
> "Angelos" <angelos@xxxxxxxxxxxxxxx> wrote in news:d6ck7q$fo7$1
> @nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com:
>
>>> MySQL errors aren't displayed anyway, unless you make a syntax error
>>> when calling the function. To find out if MySQL returned an error
>>> you need to use the mysql_error() or mysql_errno() functions.
>>
>> oh ok, didn't know that...
>> I always use mysql_error() anyway...
>
> the '@' is most valuable when you're requesting variables that have
> been POSTed or REQUESTed:
>
> @$Name = $_POST['Name'];
>
> So, in case someone DIDN'T fill out the field 'Name', the script won't
> go
> all ugly. It lets you handle errors gracefully. Without the @ in the
> above line, the output would be "Notice: Undefined Variable 'Name'"
> or
> something. Instead I can just add:
>
> if ($vName=="") {
> echo "Sorry, please fill out your name.";
> exit;
> }
>
> ... to handle the error gracefully...
You could do it like this instead of using the @, although your way is
less verbose.
$name = isset($_POST['name']) ? $_POST['name'] : '';
An advantage of doing it this way is it this way lets you specify a
default value.
--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
.
- Follow-Ups:
- Re: MySQL PHP =@ symbol
- From: Mike Willbanks
- Re: MySQL PHP =@ symbol
- References:
- MySQL PHP =@ symbol
- From: Angelos
- Re: MySQL PHP =@ symbol
- From: Chris Hope
- Re: MySQL PHP =@ symbol
- From: Angelos
- Re: MySQL PHP =@ symbol
- From: Chris Hope
- Re: MySQL PHP =@ symbol
- From: Angelos
- Re: MySQL PHP =@ symbol
- From: Good Man
- MySQL PHP =@ symbol
- Prev by Date: Re: PHP/MySQL - Splitting similar data to two tables and querying as a whole
- Next by Date: Re: apache php write permissions
- Previous by thread: Re: MySQL PHP =@ symbol
- Next by thread: Re: MySQL PHP =@ symbol
- Index(es):
Relevant Pages
|