I tried using this function to return a MySQL result in PHP. I ran the query in PhpMyAdmin and it ran successfully. But when I try to run it in PHP, nothing is returned.
My table is structured like this:
<table>
<tr>
<td>Setting</td>
<td>Value</td>
</tr>
<tr>
<td>Setting</td>
<td>stylesheet.css</td>
</tr>
</table>
Function:
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;
}
Update: Still not working
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;
}
$row- place it on top ofmysqli_close($con);so thatmysqli_close($con);is your last line.mysql_query($sql, $con);? and to close shouldnt it bemysql_close($con);? edit:: i think that is why it isnt returning.. it isnt completing the function due to the syntax errorsmysql_*andmysqli_*