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);   
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.