![]() |
CSV upload, once uploaded to a temp folder overwrite the existing database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: CSV upload, once uploaded to a temp folder overwrite the existing database (/showthread.php?tid=57525) |
CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-24-2013 [eluser]the_unforgiven[/eluser] played around with that, but no still throws an error CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-24-2013 [eluser]TheFuzzy0ne[/eluser] Is it the same error as before? It's possible I've made a syntax error somewhere. Try echoing $insert_str to see what's in there. CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-24-2013 [eluser]the_unforgiven[/eluser] Yes same error as before, I checked it with echo print_r and is fine so something else is wrong., like i said the previous code i posted befroe yours works but doesn't strip out ' - _ chars CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-24-2013 [eluser]the_unforgiven[/eluser] I changed my original to incorporate what you said: Code: $csv_upload = array('upload_data' => $this->upload->data()); Quote:Error Number: 1064 As you can see from Code: .strtr(implode('","', $line_of_data), array("'" => "''", "-" => " ", "/" => " ", "(" => " ", ")" => " ")) CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-24-2013 [eluser]TheFuzzy0ne[/eluser] That's a different syntax error. I was forgetting to put a comma on the end of each insert line. I've modified the code above. It should work now. If it doesn't, please let me know. CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-24-2013 [eluser]the_unforgiven[/eluser] Weird one this... But still syntax error: Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2 INSERT INTO wc_program_temp (JobRef, Area, Parish, AbbrWorkType, WorkType, Timing, TrafficManagement, Location, Duration, Start, Finish) VALUES ("911847","Coastal","Yapton","Micro","Micro Asphalt Surfacing","TBC","No Positive Traffic Management","Canal Road added PMI 16 07 12 ","2 days","0000 00 00","0000 00 00"), Filename: C:\xampp\htdocs\sussex\system\database\DB_driver.php Line Number: 330 CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-24-2013 [eluser]TheFuzzy0ne[/eluser] I think the problem is that I've used double-quotes. Please try my revised code (again...). If it doesn't work, I'm going to weep softly into my pillow as I cry myself to sleep tonight... CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]the_unforgiven[/eluser] Looks like you will have to cry mate, but dry your eyes, cos it still don't work ![]() CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]TheFuzzy0ne[/eluser] Aw! What's the error now? I might have to see if I can get your code setup and working at my end. It would certainly be easier to debug. Any chance you could give me access to some sample CSV data and your database table structure? CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]the_unforgiven[/eluser] Attached is the csv file i'm using which is dummy data. An you have the code right? |