I am a beginner in PHP and MySQL. Here I am in stuck in one of the problem namely
Fatal error : Uncaught Error: Call to undefined function call() in PHP
in my developing application. Below is the code sample of the specific problem.
// get the user id from the db
$stmt = $con->prepare("SELECT * FROM doctor_specialist WHERE username = ? ");
$stmt->bind_param("s",$doctor_name);
$stmt->execute();
$result = $stmt->get_result();
if($result->num_rows > 0){
while($row = $result->fetch_assoc()) {
$user_id = $row['user_id'];
// check the time slots whether it is available
$stmt9 = $con->prepare("SELECT * FROM doctor_schedule WHERE user_id = ? AND DATE_FORMAT(end_time,'%Y-%m-%d') = ? ");
$stmt9->bind_param("ss",$user_id,$date);
$stmt9->execute();
$result9 = $stmt9->get_result();
if($result9->num_rows > 0){
while($row = $result9->fetch_assoc()) {
$end_times_doctor = date('Y-m-d H:i:s', strtotime($row['end_time']));
}
}
// check the time slots whether it is available
$stmt10 = $con->prepare("SELECT * FROM patient_schedule WHERE user_id = ? AND DATE_FORMAT(end_time,'%Y-%m-%d') = ? order by end_time DESC LIMIT 1 ");
$stmt10->bind_param("ss",$user_id,$date);
$stmt10->execute();
$result10 = $stmt10->get_result();
if($result10->num_rows > 0){
while($row = $result10->fetch_assoc()) {
$end_times_patient = date('Y-m-d H:i:s', strtotime($row['end_time']));
$time_interval = date('Y-m-d H:i:s',strtotime('+15 minutes',strtotime($row['end_time'])));
}
$diff = strtotime(date($end_times_doctor)) - strtotime($end_times_patient);
$time = date('i:s', $diff);
if ($time <= 14 ) {
echo 'Time passed';
}else{
call();
}
} else {
call();
function call() {
// something else
Whenever I execute the application, this will error occurred. Actually I don't know where I went wrong. Could someone help me may highly appreciated.
callfunction is defined inside anelseblock?elseblock, wouldn't that mean it's not in scope for the otherelseblock? Why would you define a function inside of anelseblock? What is the intent for doing that?if ($time <= 14 ) {minutes is more than 15 minutes, it should call the call() function. Other thing is when there is no row in databaseif($result10->num_rows > 0){, it should call the call () function