Ansego Posted March 22, 2014 Share Posted March 22, 2014 Hello, I can't see what I am doing wrong, not getting any errors and the data is not storing the database, can you see what I've missed? (SQL Statement correct?) Objective: Pull data from *.CSV and dump it into MySQL Database; $fin = fopen('db/pc.csv','r') or die('cant open file'); $mysqli = new mysqli('localhost', 'user', 'password', 'aupostcode'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $mysqli->select_db("dbleads"); If (!$mysqli) { die ('Could not connect: ' . mysqli_error()); } echo "Connection succeeded <br />\n"; while (($data=fgetcsv($fin,1000,","))!==FALSE) { $sqlstring = "INSERT INTO `aupostcode`.`tbl_aupc` (`PCode`, `Locality`, `State`, `Comments`, `Deliveryoffice`, `Presortindicator`, `ParcelZone`, `BSPnumber`, `BSPname`, `Category`, `Lat`, `Long`) VALUES ('" . $data[0] . "', '" . $data[1] . "', '" . $data[2] . "', '" . $data[3] . "', '" . $data[4] . "', '" . $data[5] . "', '" . $data[6] . "', '" . $data[7] . "', '" . $data[8] . "', '" . $data[9] . "', '" . $data[10] . "', '" . $data[11] . "'); "; $mysqli->query($sqlstring); } echo "Insert Complete </br>"; fclose($fin); $mysqli->close(); Kind regards and advance thanks. Link to comment https://forums.phpfreaks.com/topic/287168-database-insert-fail-no-errors-sql/ Share on other sites More sharing options...
Ansego Posted March 22, 2014 Author Share Posted March 22, 2014 Disregard, works ;-) Link to comment https://forums.phpfreaks.com/topic/287168-database-insert-fail-no-errors-sql/#findComment-1473510 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.