mageamida Posted December 17, 2012 Share Posted December 17, 2012 Hi everyone, Need some help here guys please. When I try to complete the 197 columns on my loop statement the loop wont start, but when the columns is equal or lower than 90 columns the loop starts but the entire loop wont finish, it suddenly stop on some random rows. I need to upload the entire file of the .csv in mysql with a 197 columns and more than 900 rows... Here is the structure of my code. if ($_FILES[file] > 0) { $file = $_FILES[file][tmp_name]; $handle = fopen($file,"r"); do { if ($data[0]) { mysql_query ("INSERT INTO createdfault ( total number of columns are 197 ) VALUES ( '".addslashes($data[0])."', ) and so on.. "); } } while ($data = fgetcsv($handle,1000, ",","'")); header('Location: admin.php?success=1'); die; Quote Link to comment https://forums.phpfreaks.com/topic/272082-problem-with-the-197-columns-in-uploading-a-csv-file/ Share on other sites More sharing options...
Christian F. Posted December 17, 2012 Share Posted December 17, 2012 (edited) Why, for the love of $Deity, do you have 197 columns/fields in your table?! Edited December 17, 2012 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/272082-problem-with-the-197-columns-in-uploading-a-csv-file/#findComment-1399809 Share on other sites More sharing options...
PFMaBiSmAd Posted December 17, 2012 Share Posted December 17, 2012 See the following link for the maximum amount of columns/data that can be stored in one row - http://dev.mysql.com/doc/refman/5.5/en/column-count-limit.html If you had some error checking logic for your query statement, you would be getting an error that indicates why your query is failing. As to the number of rows being inserted before the code randomly stops, your logic is foo-bar. Any time $data[0] evaluates as a FALSE value (0, '0', or an empty string) the loop will stop. You should be using a while(){} loop that will test if $data is false or not. There's an example at this link - fgetcsv Quote Link to comment https://forums.phpfreaks.com/topic/272082-problem-with-the-197-columns-in-uploading-a-csv-file/#findComment-1399834 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.