cluce Posted June 24, 2008 Share Posted June 24, 2008 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); ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 24, 2008 Share Posted June 24, 2008 At the very least the parameters for mysqli_query() need to be switched, but you should also add some error handling as well. mysqli_query($sql, $mysqli) or die (mysql_error()); Quote Link to comment Share on other sites More sharing options...
cluce Posted June 24, 2008 Author Share Posted June 24, 2008 I solved it. I had to move up my bracket. } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.