我正在尝试显示或返回所选用户的日期值
function mysql_select_one_data($database, $table, $data, $country, $phone){
$conn = mysql_connect("localhost", "root", "test123");
mysql_select_db($database, $conn) or die (mysql_error());
$query = "SELECT DATE FROM Temp_Users WHERE Country = '+94' AND Phone = '1234539543';";
$result = mysql_query($query) or die (mysql_error());
if (mysql_num_rows($result) > 0) {
// output data of each row
while($row = mysql_fetch_assoc($result)) {
echo "Date: " . $row["Date"]. "<br>";
}
} else {
echo "0 results";
}
return $result;
}
结果:
Date:
Resource id #5
但是当我在phpmyadmin中执行查询时,它会返回
我是Php的新手,我不知道自己做错了什么,谢谢你的帮助。
答案 0 :(得分:0)
更改此
$query = "SELECT DATE FROM Temp_Users WHERE Country = \"+94\" AND Phone = \"1234539543\";";
到这个
$query = "SELECT DATE FROM Temp_Users WHERE Country = '+94' AND Phone = '1234539543';";
将echo
命令更改为echo "Date: $row['DATE']<br>"