1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Latest & Best/secure way for PHP, MYSQL connection

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

  1. #1
    Hi,
    SEMrush
    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
    SEMrush
  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:
    1
    Best Answers:
    0
    Trophy Points:
    3
    #3
    Use pdo!
    https://php.net/pdo.connections :D
     
    AndresB, Jul 16, 2019 IP
  4. JEET

    JEET Well-Known Member

    Messages:
    2,275
    Likes Received:
    118
    Best Answers:
    2
    Trophy Points:
    185
    #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