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); ?> Link to comment https://forums.phpfreaks.com/topic/111725-solved-i-am-not-sure-my-insert-sql-is-correct/ 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()); Link to comment https://forums.phpfreaks.com/topic/111725-solved-i-am-not-sure-my-insert-sql-is-correct/#findComment-573515 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. } Link to comment https://forums.phpfreaks.com/topic/111725-solved-i-am-not-sure-my-insert-sql-is-correct/#findComment-573522 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.