Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts

    "@" needed? mysql_connect

    Okay, I've been doing a lot of coding, and I dont see what this is used for?

    PHP Code:
    @mysql_connect 
    why not just
    PHP Code:
    mysql_connect 
    or same thing
    PHP Code:
    @mysql_select_db 
    to
    PHP Code:
    mysql_select_db 
    what is the whole "@" deal?

    Thanks

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    @ is the supression operator. Any errors that may be tossed by the usage of the function are ignored. @ is almost never required with proper error checking and trapping.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Okay thanks. but is it more recommended to use it?

  • #4
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Although I'm guilty of using the error suppression operator myself on occasion, IMHO it is not recommended to use it, but rather to use proper error handling as Fou-Lu mentioned.

    PHP Language Reference : Operators : Error control operators

    Keep that language reference handy, I recommend reading through it as much as you can to gain a good grasp on PHP.

  • #5
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    You should never need to use it with any well written code.
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •