0

I am continuously having this internal server error to a very simple php code working with JSON. The values I am logging from the code is absolutely correct, yet when in action I am getting an internal server error 500 from this particular code. I had a similar code working previously. What am I doing wrong? or how should I proceed with debugging the error?

<?php

$var2 = $_POST['phn'];
$phone_received = json_decode($var2);

$adb = PearDatabase::getInstance();

$query1 = "SELECT addressid FROM address WHERE mobile = ?"; 
$leadID = $adb->pquery($query1, array($phone_received));

$row= $adb->num_rows($leadID);

if ($row != 0) {      
    $result = 'This number has already been used in the system.';
    echo json_encode($result); 
}else{
    $result = 'Good to go!';
    echo json_encode($result); 
}    

?>
Abir Imtiaz
  • 33
  • 1
  • 10

1 Answers1

-1

Did you try to add true parameter to your json_decode call? I suppose the problem is with the $phone_received param. I also suggest you line by line debugging: try to retrun some dummy result after each line of code step by step so you can detect the place where the error occurs.

Azuloo
  • 461
  • 2
  • 9