Jump to content

Problem With The 197 Columns In Uploading A .csv File


mageamida

Recommended Posts

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;

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.