“Illegal mix of collations for operation 'concat'” appears after data base import

浪尽此生 提交于 2019-12-13 07:37:44

问题


In my old site, this problem does not exist. But after I have changed the server and imported the data base, this message appears. The PHP version is 5.3 and this is the code:

$sql = "SELECT * FROM movcaixa 

    WHERE data BETWEEN '$data1' AND '$data2' AND empresa = $empresa 

    ORDER BY data ASC";
   $resMovCaixa = mysql_query($sql, $cnn) or die('Falha na conexão com o banco de dados');
   $sql = "SELECT cp.id AS codigo, CONCAT('Pagamento ref. a ', des.descricao, ', conforme doc. nº ',  cp.documento) AS hist, DATE_FORMAT(cp.quitacao, '%d/%m/%Y') AS data, cp.valorpago AS vlr, cp.documento AS doc, fr.nome AS forn, des.descricao AS desp 

    FROM contaspagar cp, fornecedor fr, despesa des 

    WHERE cp.fornecedor = fr.id AND cp.despesa = des.id AND cp.quitacao BETWEEN '$data1' AND '$data2' AND empresa = $empresa 

    ORDER BY data ASC";
    $resContasPagar = mysql_query($sql, $cnn) or die(mysql_error($cnn));
    $sql = "SELECT cr.id AS codigo, DATE_FORMAT(cr.quitacao, '%d/%m/%Y') AS data, CONCAT('Recebimento ref. ', cli.nome, ', conforme doc. ', cr.documento) AS hist, cr.valorpago AS vlr, cr.documento AS doc, cs.descricao AS cont 

    FROM contasreceber cr, contratoservico cs, cliente cli 

    WHERE cr.contratoservico = cs.id AND cs.cliente = cli.id AND cr.quitacao BETWEEN '$data1' AND '$data2' AND empresa = $empresa 

    ORDER BY cr.quitacao";

Can somebody help me?


回答1:


Check the collations for the tables, you use inside CONCAT function:

  1. des
  2. cp
  3. cli
  4. cr

Use the same collation for all of them.



来源:https://stackoverflow.com/questions/17762989/illegal-mix-of-collations-for-operation-concat-appears-after-data-base-impor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!