php – i am getting this error: Warning: Undefined variable $sql on line 257

Question

Warning: Undefined variable $sql on line 257

Fatal error: Uncaught ValueError: mysqli::query(): Argument #1 ($query) cannot be empty in C:\xampp\htdocs\volunteer.php:257 Stack trace: #0 C:\xampp\htdocs\volunteer.php(257): mysqli->query(”) #1 {main} thrown in C:\xampp\htdocs\volunteer.php on line 257

here is code:

if(isset($first) && $first != "" && isset($last) && $last !="" && isset($address) && $address !="" && isset($tel) && $tel !="" && isset($date) && $date !="" && isset($email) && $email !="" && isset($gender) && $gender !="" && isset($age_group) && $age_group !="" && isset($reason) && $reason !="" && isset($whyjoin) && $whyjoin !="" && isset($experience) && $experience !="" && isset($howlong) && $howlong !="" && isset($interests) && $interests !="" && isset($commitment) && $commitment !="" && isset($fr_name) && $fr_name !="" && isset($fr_email) && $fr_email !="" && isset($fr_add) && $fr_add !="" && isset($fr_tel) && $fr_tel !="" && isset($sr_name) && $sr_name !="" && isset($sr_mail) && $sr_mail !="" && isset($sr_add) && $sr_add !="" && isset($sr_tel) && $sr_tel !="" && isset($special) && $special !="" && isset($comments) && $comments !="" && isset($days) && $days !="" && isset($hours) && $hours !="" && isset($area) && $area !=""){

        $sql= "INSERT INTO volunteer( First_name, Last_name, U_Address, Phone, date_birth, email, gender, age, reason, why_join, experience, how_long, interests, commitment, fr_name, fr_add, fr_email, fr_tel, sr_name, sr_add, sr_email, sr_tel, special, any_comments, duty_days, duty_hours, area  ) VALUES ('$first', '$last', '$address', '$tel', '$date', '$email', '$gender', '$age_group', '$reason', '$whyjoin', '$experience', '$howlong', '$interests', '$commitment', '$fr_name', '$fr_email', '$fr_add', '$fr_tel', '$sr_name', '$sr_mail', '$sr_add', '$sr_tel', '$special', '$comments', '$days', '$hours', '$area')";
       
    }

if($connection->query($sql) === TRUE) {
    echo "Thank you for contacting";
    // send email
    //mail($email,"My subject",$comments);
} else {
    echo "There was an error. ".$connection->error;
}

$connection->close();   

0
Rup 2 weeks 2024-02-12T06:05:23-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse