I am trying to make an ajax call, passing as parameter an integer 'mySensor'. The php file of the call contains the following code:
<?php
$con = mysql_connect(...) or die('connection not made');
$db = mysql_select_db('...', $con) or die('db not selected');
$mySensor = mysql_escape_string($_POST["mySensor"]);
$query = "SELECT Unit FROM sensors WHERE SensorID = ".$mySensor;
$result = mysql_query($query, $con) or die('query not made');
echo $result;
?>
So, from the table sensors
I want to get the Unit
(which is a string) of the element with SensorID=mySensor
(there is only one such element). Echoing the $result
doesn't work. How do I return that unit (which is, again, a string) back to my js script?
Thanks!