Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 代码在服务器上工作,而不是在Xampp:json_encode上_Php_Json_Xampp - Fatal编程技术网

Php 代码在服务器上工作,而不是在Xampp:json_encode上

Php 代码在服务器上工作,而不是在Xampp:json_encode上,php,json,xampp,Php,Json,Xampp,嗨,我有一段代码可以在我的uberspace服务器上运行,但不能在xampp(mac)上运行 代码基本上是一个数据库请求: get_all_experts($errors, $rows, ' WHERE active < CURDATE() AND active IS NOT null'); echo count($rows);//Is 14 in the example echo json_encode($rows);//Doesn't return anything $arr = a

嗨,我有一段代码可以在我的uberspace服务器上运行,但不能在xampp(mac)上运行

代码基本上是一个数据库请求:

get_all_experts($errors, $rows, ' WHERE active < CURDATE() AND active IS NOT null');
echo count($rows);//Is 14 in the example
echo json_encode($rows);//Doesn't return anything 
$arr = array (1,'b'=>'2','c'=>3,'d'=>4,'e'=>5);
echo json_encode($arr);//works

function get_all_experts(&$errors, &$rows, $selector)
{
  $result = mysql_query('SELECT * FROM experts'.$selector);
  if (!$result) {
    $errors['sql_experts'] = 'Kein Ergebnis: '.mysql_error();
  }
  else {
    while($r = mysql_fetch_assoc($result)) {
        $rows[] = $r;
        get_expert_tags($errors, $rows, $r);
        get_last_expert_experience($errors, $rows, $r);        
        }

  }
};

它以什么方式不起作用?你犯了什么错误?你知道错误发生在哪条线上了吗?这就是问题所在。它没有显示任何错误,只是告诉我“无属性”(在网络的预览选项卡中)检查。我认为这是同样的问题。Thx,这就是问题所在。我的表应该是utf-8,但是有一个消息配置缓存被禁用,这可能会阻止它使用我的设置。现在我只需要找出解决方法。
$conn = mysql_connect('localhost', 'blub', 'mySecretPassword') or exit(mysql_error());
mysql_select_db('blab', $conn) or exit(mysql_error());
mysql_query("SET NAMES 'utf8'"); 
mysql_query("SET CHARACTER SET 'utf8'");