gpt4 book ai didi

PHP mysql 未定义索引 : timestamp

转载 作者:太空宇宙 更新时间:2023-11-03 10:58:04 25 4
gpt4 key购买 nike

请帮帮我。我面临错误,因为 Undefined index: timestamp in line 24 不确定我错过了什么。 :(任何帮助表示赞赏!提前致谢

$mysql_connect = mysql_connect($db_host, $db_user, $db_pword, $db_name);
$query = "SELECT DATE_FORMAT(`timestamp`,'%d-%m-%Y') from statistics";
if (!$mysql_connect)
die("unable to connect to database: " . mysql_error());

@mysql_select_db($db_name) or die( "Unable to select database");

$result = mysql_query($query);
$response = array();
$stats = array();
while ($row=mysql_fetch_array($result))
{
$stats[] = array (
'date' => $row ['timestamp']
);
}

$Response['stats'] = $stats;

$fp = fopen('results.json', 'w');
fwrite($fp, json_encode($Response));
fclose($fp);

die ("Failed to execute Query: " . mysql_error());

mysql_close($mysql_connect);

/*$views = mysql_fetch_array($result);
print("<pre>");
print_r($views);
print("</pre>");*/

?>

最佳答案

也许你忘了给你的领域取别名

SELECT DATE_FORMAT(`timestamp`,'%d-%m-%Y') AS "timestamp"
FROM statistics

关于PHP mysql 未定义索引 : timestamp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18470599/

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