Hi guys i have been trying to use cURL to send and retrieve data.
I am new to php as only been doing this for about 3 weeks.
I have setup 2 variables from the database and when called from another site through cURL it should send them using json but for some reason it is not sending the data,
Could someone please tell me what i am doing wrong, everything works fine untill it gets to the json section and then it just does nothing.
code:
if(isset($_REQUEST['token'])){
$token = $_REQUEST['token'];
$url = $_REQUEST['www'];
$token = trim(htmlentities($token));
$safetoken = mysql_real_escape_string($token);
$url = trim(htmlentities($url));
$safeurl = mysql_real_escape_string($url);
$checkwebsite = "SELECT message,islive FROM websitetokens WHERE url='".$safeurl."' AND token='".$safetoken."'";
$checkwebsite_result = mysql_query($checkwebsite) OR die();
$numberofrows = mysql_num_rows($checkwebsite_result);
if($numberofrows > 0){
$website = mysql_fetch_array($checkwebsite_result);
$message = stripslashes($website["message"]);
$islive = stripslashes($website["islive"]);
json_encode(array('message' => $message,'islive' => $islive,));
$date = date('Y-m-d');
$time = gmdate('H:i');
$loginwebsite = "UPDATE websitetokens SET loggedin='".$date."',time='".$time."' WHERE url='".$safeurl."' AND token='".$safetoken."'";
$loginwebsite_result = mysql_query($loginwebsite) OR die(mysql_error());
} else {
json_encode(array('message' => '','islive' => '1',));
}
}
Thanks
there will be an output if you
echothe result ofjson_encode. Also, it may also be wise if you set the content type of the output like so: