我尝试使用此函数在PHP中返回MySQL结果。我在PhpMyAdmin中运行了查询,它运行成功。但是当我尝试在PHP中运行它时,什么都没有返回。
我的表结构如下:
<table>
<tr>
<td>Setting</td>
<td>Value</td>
</tr>
<tr>
<td>Setting</td>
<td>stylesheet.css</td>
</tr>
</table>
功能:
function getData()
{
require 'config.php';
$con = mysql_connect($hostname, $username, $password, $database);
$sql = "SELECT Value FROM Settings WHERE Setting = 'Stylesheet'";
$result = mysql_query($con,$sql);
$row = mysql_result($result, 0);
mysqli_close($con);
return $row;
}
更新:仍然无法正常工作
function getData()
{
require 'config.php';
$con = mysql_connect($hostname, $username, $password, $database);
$sql = "SELECT Value FROM Settings WHERE Setting = 'Stylesheet'";
$result = mysql_query($sql, $con);
$row = mysql_result($result, 0);
mysql_close($con);
return $row;
}