Matt23

PDO ERROR

Feb 1st, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. function setProperCollation($character, $collation)
  2.     {
  3.         $tables = $this->getAllTables();
  4.  
  5.         for ($i = 0; $i < count($tables); $i++)
  6.         {
  7.             try
  8.             {
  9.                 $newSettings = $this->conn->prepare('ALTER TABLE ? CONVERT TO CHARACTER SET ? COLLATE ?');
  10.                 $newSettings->bindParam(1, $tables[$i][0], PDO::PARAM_STR);
  11.                 $newSettings->bindParam(2, $character, PDO::PARAM_STR);
  12.                 $newSettings->bindParam(3, $collation, PDO::PARAM_STR);
  13.                 $newSettings->execute();
  14.             } catch (PDOException $e)
  15.             {
  16.                 echo "Error: " . $e->getMessage() . "<br>";
  17.                 die();
  18.             }
  19.         }
  20.  
  21.         echo "Done";
  22.     }
  23.  
  24.  
  25. // Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;
  26. // check the manual that corresponds to your MySQL server version for the right syntax to use near
  27. // '? CONVERT TO CHARACTER SET ? COLLATE ?' at line 1
Advertisement
Add Comment
Please, Sign In to add comment