Is there a brain mod for avoiding deprecated function calls?
Results 1 to 7 of 7

Thread: Is there a brain mod for avoiding deprecated function calls?

  1. #1
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,715

    Is there a brain mod for avoiding deprecated function calls?

    The other day I was typing away at some code in some file or another.

    I linted it and then ran it in the browser. Although lint was fine, the browser test croaked.

    A survery of the server logs produced:
    Quote Originally Posted by Apache2.2
    Fatal error: mysql_result() expects parameter 1 to be string, object given in /something.php on line X
    Now, one could argue that my mysqli_result() hack is partially responsible for this, but I'm gonna blame my fingers, which are connected via a complex organic control/feedback loop from my central processing wetware.

    Anyone got any hints for teaching your fingers to always type the "i" after mysql?

    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  2. #2
    PHP Witch laserlight's Avatar
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    13,563
    Use its object oriented interface?
    Use Bazaar for your version control system
    Read the PHP Spellbook
    Learn How To Ask Questions The Smart Way

  3. #3
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    13,943
    disable the MySQL extension?
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

  4. #4
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,428
    My editor of choice is Vim these days, so I'd probably augment my _vimrc with an autocmd that checks all *.php files upon writing for instances of /mysql_[a-z_]+\(/ and warns me.

  5. #5
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,885
    I can't think of a fail-fast method, only ones that fail at runtime (which you already have) or avoid the issue completely.

    Set disable_functions in php.ini? (except this would turn that fatal error into a mere warning)

    Use the PDO interface?

    ...or a different DBMS?
    Last edited by Weedpacket; 05-09-2013 at 12:00 AM.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  6. #6
    Senior Member
    Join Date
    Mar 2009
    Posts
    811
    Autocomplete.
    Declare variables, not war.

  7. #7
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,715

    Thanks, gents! :D

    Quote Originally Posted by laserlight View Post
    Use its object oriented interface?
    If I'm in an OO context that would work ... and does

    Quote Originally Posted by NogDog View Post
    disable the MySQL extension?
    And break backwards compatibility? Sounds good, but cannot be done for reasons of keeping my job.

    Quote Originally Posted by bradgrafelman View Post
    My editor of choice is Vim these days, so I'd probably augment my _vimrc with an autocmd that checks all *.php files upon writing for instances of /mysql_[a-z_]+\(/ and warns me.
    Not sure if I really have an editor of choice anymore; I've got nano, Notepad++ and NetBeans all running even now

    Quote Originally Posted by Weedpacket View Post
    I can't think of a fail-fast method, only ones that fail at runtime (which you already have) or avoid the issue completely.

    Set disable_functions in php.ini? (except this would turn that fatal error into a mere warning)

    Use the PDO interface?

    ...or a different DBMS?
    A complete abstraction layer might be nice, I suppose. Since it seems I only learn those that I write myself, though ... not gonna happen soon. Certainly not before vacation next week

    Quote Originally Posted by Bonesnap View Post
    Autocomplete.
    Now you're just teasing me!
    Last edited by dalecosp; 05-17-2013 at 11:44 AM. Reason: punctuation and whitespace
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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