Jump to content

[SOLVED] I am not sure my insert sql is correct?


cluce

Recommended Posts

can someone look at my code to see if it is using the correct syntax?

 


<?
##########################################
# read the data file into an array
# each element of this array contains all of the information for each item

$data_file = "UserInfo.csv";
$line_array = file($data_file);

########################################
# make your database connection here

include'db.php';
include'salt.php';

####################################################
# loop through the first array

$number_of_items = count($line_array);
$i =0;
for($i=0;$i<$number_of_items;$i++) {

########################################
# explode each element into a new array using the comma as the delimiter

$temp_array = explode(",",$line_array[$i]);

###########################################
# make your mysql query here and
# insert each field from the temp array into the proper mysql fields like $temp_array[1] in order of your rows affected

$sql = "INSERT INTO employees (username, password, f_name, l_name, email, last_login, failed_logins, privilege, company, division_number)  VALUES('$temp_array[0]', '$temp_array[1]', '$temp_array[2]', '$temp_array[3]', '$temp_array[4]', '$temp_array[5]', '$temp_array[6]', '$temp_array[7]', '$temp_array[8]') ";
}
mysqli_query($mysqli, $sql);   
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.