0

I am doing a pretty simple script to check if a given url exists in a database. I have checked and EVERY column, table, and the database itself is set for 'latin1_general_ci' so I don't see how it is even possible this is showing :

PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='' in /home/user/public_html/checkurl.php:17

//get url passed
$url = $_GET['u'];

    //dating
    $stmt = $db->prepare("
        SELECT *
        FROM testing    
        WHERE url = :url
    ");
    $stmt->execute(array(':url' => $url));

    $result = $stmt->fetch(PDO::FETCH_ASSOC);

    if($result)
    {
        $db = null;
        exit("1");
    }

I thought maybe this might have to do with cached queries so I reset the cache as well using RESET QUERY CACHE, but it still occurs.

user756659
  • 3,372
  • 13
  • 55
  • 110
  • http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Marc B Oct 05 '15 at 16:30
  • May be of help: http://stackoverflow.com/questions/20928647/how-to-solve-illegal-mix-of-collations-latin1-general-ci-implicit-error – Script47 Oct 05 '15 at 16:30
  • The client is connecting using utf_8 (and sending utf_8 content). For ascii characters, this isn't an issue because all charsets treat the ascii set the same. – samlev Oct 05 '15 at 16:33
  • ahh, good call there... I now noticed the pdo connect script is set as `new PDO("mysql:host=$db_host;port=$db_port;dbname=$db_database;charset=utf8", $db_user, $db_pass, ...`. I never has an issue with this on other servers... I take it this needs changed to 'latin1'? – user756659 Oct 05 '15 at 16:34
  • Is `$url` encoded in latin1 or in utf8? – Rick James Oct 26 '15 at 05:39

0 Answers0