LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-11-2008, 12:00 AM   #1
snowtigger
Member
 
Registered: Mar 2005
Location: england
Distribution: slackware, win2k
Posts: 364

Rep: Reputation: 35
a php syntax question "==@" ??


Well i'm diving in to the wonderful world of php,sql and html. But i'm a little stuck on something. I have found a little tutorial on filling a html form drop down box from a database table, however reading through the source i came across this bit,

PHP Code:
while($noticia2 mysql_fetch_array($quer2)) {

if(
$noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";}

else 
I understand most of it, its just the
PHP Code:
==@ 
that has got me. I think it is the following.....

a
PHP Code:
== 
which is a Comparison Operator.

followed by a
PHP Code:

which is a Error Control Operators.

Am i right in my thinking or is it something else altogether.
If i'm correct can i introduce a space in between, like....
PHP Code:
== @ 
Or will that start meaning something else?

 
Old 06-11-2008, 10:34 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
It doesn't look to be very conventional. I would suspect that $cat has not always been defined and so it is trying to avoid an error being displayed when the $cat variable doesn't exist. I would suggest (if that really is the case) that it would be better to code it as follows:

PHP Code:
if (isset($cat))
   if(
$noticia2['cat_id'] == $cat)
      { 
/* code here */ 
 
Old 06-11-2008, 11:30 PM   #3
snowtigger
Member
 
Registered: Mar 2005
Location: england
Distribution: slackware, win2k
Posts: 364

Original Poster
Rep: Reputation: 35
hello graemef,
Thanks for your input and the suggestion.

I got the code from here http://www.plus2net.com/php_tutorial..._down_list.php,
(to anyone else...i'm not suggesting this site, its just one i stumbled upon).
But after reading through the php manual i'm thinking more and more that the code is not very well written to start with.

You mention about $cat not being set, and i think your right there. There is this little part in the source for the tutorial.....
PHP Code:
@$cat=$_GET['cat']; // Use this line or below line if register_global is off

//@$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off 
However it has given me some pointers in the right direction and i'm now on my quest of writing what i want to achieve.

 
Old 06-12-2008, 01:14 PM   #4
AdaHacker
Member
 
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 32
Quote:
Originally Posted by snowtigger View Post
But after reading through the php manual i'm thinking more and more that the code is not very well written to start with.
You have good instincts. The code on that page is not only ugly, but also extremely out-dated. For example, the use of $HTTP_GET_VARS has been deprecated since PHP 4.1 (released in December 2001) and register_globals has been off by default since version 4.2 (released April 2002). Not exactly up-to-date stuff.
 
Old 06-13-2008, 02:26 AM   #5
snowtigger
Member
 
Registered: Mar 2005
Location: england
Distribution: slackware, win2k
Posts: 364

Original Poster
Rep: Reputation: 35
So can any of you suggest any up to date websites with some tutorials?

 
Old 06-13-2008, 10:22 AM   #6
AdaHacker
Member
 
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 32
Well, Zend's beginners tutorial looks to be fairly good. They also have a boat-load of other tutorials, though many of them are on more advanced topics.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 04:08 PM
"Count to 100" PHP Newbe question. datafan Programming 5 12-07-2006 07:14 PM
PHP / VideoLAN / Fedora Core Question - how can I get the PHP "exec" function to work gtrawoger Linux - Software 3 12-21-2005 06:51 AM
php ide with "break" and "trace" Kayaker Programming 3 04-25-2003 02:52 PM
Error Syntax Question ("Domain not bound") bison42 Linux - Newbie 1 08-30-2001 05:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration