I have a problem with inserting array values into the DB table, which I defined 4 arrays and I'm trying to Insert these arrays values using for loop, and I got this Error:
Here is My Code:
<?php
$servername = "localhost";
$username = "root";
$password = "12345678";
$db_name = "blooddonation";
//////////////////////*********** Blood Donation System **************//////////////////////
//Create Connection
$conn = new mysqli($servername, $username, $password, $db_name);
//Check Connection
if($conn -> connect_error){
die("Connection falied :(". $conn -> connect_error."<br>");
}else {
echo "Connection Success! :)"."<br>";
//Insert patient's Info
$Names = array("Ahmad", "Abdullah", "Hashim", "Rahaf", "Jood", "worood", "Heba", "Hamza", "Fatima", "Danea");
$Hospital = array("Istishari Hospital", "Ibn AlHaytham Hospital", "Islamic Hospital", "Palestine Hospital",
"Istiklal Hospital", "Jordan Hospital", "Al Khalidi Hospital", "Amman Surgical Hospital",
"Shmaisani Hospital", "Al-Essra Hospital");
$bType = array("AB+", "O-", "A-", "B+", "AB-", "B-", "A+", "O+", "AB+", "B+");
$Status = array("Emergency", "Normal", "Normal", "Emergency", "Emergency", "Normal", "Normal", "Normal", "Emergency","Normal");
$Pass = "12345678";
for($i = 0; $i < 10; $i++){
$sql1 = "INSERT INTO patients (name, password, hospital, bloodType, status) VALUES ($Names[$i], $Pass, $Hospital[$i], $bType[$i], $Status[$i])";
if($conn -> multi_query($sql1) == TRUE){
echo "Patient's Info Inserted Successfuly :)"."<br>";
}else{
echo "Error: ".$sql1."<br>".$conn -> error."<br>";
}
}//End of for loop
}
//Close Connection
$conn -> close();
?>
so how can I solve this problem?