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. Quote Link to comment Share on other sites More sharing options...
Solution Ansego Posted March 22, 2014 Author Solution Share Posted March 22, 2014 Disregard, works ;-) 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.