Latest & Best/secure way for PHP, MYSQL connection

Discussion in 'PHP' started by dineshsingh1984, Oct 26, 2018.

  1. #1
    Hi,

    Please tell me what the Latest and Secure way for the connection of Mysql and PHP 7 or upper version.
     
    Solved! View solution.
    dineshsingh1984, Oct 26, 2018 IP
  2. #2
    Using either PDO or mysqli_ (instead of mysql_), both with their respective method for using prepared statements. There are plenty of examples on this sites, for using both of them. Personally, I prefer PDO, although mysqli_ might be slightly easier to grasp. However, since mysqli_ is completely swappable with mysql_, it's a lot easier to do "wrong", and it's also less efficient. Hence, I recommend PDO, although it will involve a bit of a rewrite, for existing solutions, and a bit of a read-up if you're learning things from the start.
     
    PoPSiCLe, Oct 26, 2018 IP
    deathshadow and sarahk like this.
  3. AndresB

    AndresB Peon

    Messages:
    4
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    3
    #3
    Use pdo!
    https://php.net/pdo.connections :D
     
    AndresB, Jul 16, 2019 IP
  4. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #4
    You can use mysqli
    The important thing is how you handle the data which is going in the database.
     
    JEET, Jul 22, 2019 IP