Changing MySQL to PDO in PHP

Discussion in 'General PHP' started by jurekni, Jan 31, 2018.

  1. jurekni

    jurekni Member

    Joined:
    Feb 13, 2017
    Messages:
    32
    Likes Received:
    2
    Would someone be willing to change below MySQL code to PDO, because I do not know how to do it, I would be very grateful for your help. Regards Jerzy

    $query ="DELETE FROM ". $DBPrefix ."conditions";
    $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
    //$rebuilt_item_condition
    for($i =0; $i < count($rebuilt_item_condition); $i++)
    {
    $query ="INSERT INTO ". $DBPrefix ."conditions VALUES ('". $rebuilt_item_condition[$i]."', '". $system->cleanvars($rebuilt_condition_desc[$i])."')";
    $system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
    }

    $ERR = $MSG['1043'];
    }

    $query ="SELECT * FROM ". $DBPrefix ."conditions ORDER BY item_condition";
    $res = mysql_query($query);
    $system->check_mysql($res, $query, __LINE__, __FILE__);

    $i =0;
    while($row = mysql_fetch_assoc($res))
    {
     
  2. jurekni

    jurekni Member

    Joined:
    Feb 13, 2017
    Messages:
    32
    Likes Received:
    2
    Of course, change mysql_query to PDO
     

Share This Page