处理我的第一个与 SQL 交互的 PHP 脚本。我离得很近,我闻到了!
我正在尝试在表格中返回 MAX 日期,并收到以下消息,日期应该是:
解析错误:语法错误,第 25 行 /Applications/XAMPP/xamppfiles/htdocs/tslocal/themes/myname/views/reports/get_vote_date.php 中的意外 T_VARIABLE
第 25$result = mysqli_query($dbc, $query);
行在下面的脚本中。
这是剧本,我一直盯着它看,直到我的眼睛流血,但不确定它是“错误的”,因为我是新手:
<?php # script get_vote_date
// This file contains the db info
// This file establishes a mysql connection, connects to the db and then gets the most recent vote date for a particular page (incident_id).
DEFINE ('DB_USER', 'myname');
DEFINE ('DB_PASSWORD', 'somepass123');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'sitename');
// make the db connection
$dbc = @mysqli_connect('DB_HOST','DB_USER','DB_PASSWORD','DB_NAME')
OR die ('Could not connect to mysql: ' . mysqli_connect_error());
// Set the encoding
mysqli_set_charset($dbc, 'utf8');
// set the query variable
$query = 'SELECT MAX(rating_date)
FROM rating
WHERE incident_id = $incident_id;'
//connect and run the query
$result = mysqli_query($dbc, $query);
echo $result;
?>
如果它有任何价值,这里是我试图从中提取数据的表格屏幕: