How do I check that the php script works? I'm using php -f filename.php email@address.com
, but I get errors. The php script is intended to work with an Android app to retrieve data where the email matches a posted email address. Here is the php code:
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_name", $con);
$email= mysql_real_escape_string($_POST['email']);
$result=mysql_query("SELECT * FROM `TableName` WHERE email='$email' ");
if($result){
$num_rows = mysql_num_rows($result);
print(json_encode($num_rows));
}
mysql_close($con);
?>
Or am I not able to test this script from the command line, and instead should use an html file?
Now, for example if I replace the line: $email= "myaddress@nd.edu";
and then type php -f getdbstats.php
I get the correct result.