gpt4 book ai didi

php - MySQL 查询适用于服务器但不适用于 PHP

转载 作者:行者123 更新时间:2023-11-30 23:03:22 24 4
gpt4 key购买 nike

问题解决了!

mysql_set_charset('utf8',$conn);

如果我直接在服务器上运行以下 mysql 查询,它就可以正常工作。如果我尝试通过 php 运行它,我既没有错误也没有结果……有什么建议吗?

查询

Select Distinct 
users.last_name,
accounts.name,
Max(Distinct tasks.date_entered) as credate,
accounts_cstm.kategorie_c,
accounts_cstm.geschaeftsfeld_c as Geschäftsfeld,
Count(tasks_cstm.betreff_c),
tasks_cstm.nz_c,
tasks_cstm.betreff_c
From
tasks Left Join users On tasks.created_by = users.id
Inner Join accounts On tasks.parent_id = accounts.id
Left Join tasks_cstm On tasks.id = tasks_cstm.id_c
Inner Join accounts_cstm On accounts.id = accounts_cstm.id_c
Where tasks_cstm.betreff_c In ('Call', 'Angebot', 'Mail')
And tasks.deleted = 0
Group By
accounts.name, tasks_cstm.betreff_c
Having
(tasks_cstm.betreff_c = 'Call') Or
(tasks_cstm.betreff_c = 'Angebot') Or
(tasks_cstm.betreff_c = 'Mail')
Order By
credate Desc;

PHP 代码

$conn = mysql_connect($dbserver, $dbuser, $dbpw);
if (!$conn || !mysql_select_db('sugar', $conn)) {
echo "con error"; }
else {
$query = "[query from above]";
$push = mysql_query($query);
if (!$push) {
echo "query error"; }
else {
echo "query ok";
mysql_free_result($push); }
mysql_close($conn); }

任何简单的查询都可以正常工作...

谢谢

最佳答案

问题已解决。

错过了“As Geschäftsfeld”...

mysql_set_charset('utf8',$conn);

关于php - MySQL 查询适用于服务器但不适用于 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22939078/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com