inserting data into mysql

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • anom

    inserting data into mysql

    I have a simple loop
    include '../php_library/connect.php';
    include '../php_library/opendb.php';

    $conn=mysql_con nect($host,$dbu ser,$dbpass) or die ('Error');
    mysql_select_db ($dbname);
    //Open the file
    $fp = fopen($src,"r") ;
    //for each line in the file
    while ($row=fgetcsv($ fp,10000,';')) { //Get line
    $sql_insert="IN SERT INTO ...";
    if (!mysql_query($ sql_insert,$con n)){
    OutputError($sq l_insert,$mysql _error());
    $FailedCount++;
    }
    else {$InsertCount++ ;}
    }


    It works fine for the first couple of hundred or so rows but the stops -
    no errors, it just stops mid-loop.

    I'm guessing some sort of buffer problem (needs flushing?) but it is a
    guess.

    I'm running this all locally - XP, Apache2, PHP5, mySQL 4.1

    Keith
  • Tim Van Wassenhove

    #2
    Re: inserting data into mysql

    On 2005-09-06, anom <anommail@hotma il.co.uk> wrote:[color=blue]
    > I have a simple loop
    > include '../php_library/connect.php';
    > include '../php_library/opendb.php';
    >
    > $conn=mysql_con nect($host,$dbu ser,$dbpass) or die ('Error');
    > mysql_select_db ($dbname);
    > //Open the file
    > $fp = fopen($src,"r") ;
    > //for each line in the file
    > while ($row=fgetcsv($ fp,10000,';')) { //Get line
    > $sql_insert="IN SERT INTO ...";
    > if (!mysql_query($ sql_insert,$con n)){
    > OutputError($sq l_insert,$mysql _error());
    > $FailedCount++;
    > }
    > else {$InsertCount++ ;}
    > }
    >
    >
    > It works fine for the first couple of hundred or so rows but the stops -
    > no errors, it just stops mid-loop.[/color]

    Prepend the following to your script:

    ini_set('error_ reporting', E_ALL);
    ini_set('displa y_errors', TRUE);

    I've got a feeling you will see a message like: max execution time has
    been exceeded... http://www.php.net/set_time_limit


    --
    Met vriendelijke groeten,
    Tim Van Wassenhove <http://timvw.madoka.be >

    Comment

    • anom

      #3
      Re: inserting data into mysql

      Tim Van Wassenhove wrote:[color=blue]
      > On 2005-09-06, anom <anommail@hotma il.co.uk> wrote:
      >[color=green]
      >>I have a simple loop
      >> include '../php_library/connect.php';
      >> include '../php_library/opendb.php';
      >>
      >> $conn=mysql_con nect($host,$dbu ser,$dbpass) or die ('Error');
      >> mysql_select_db ($dbname);
      >> //Open the file
      >> $fp = fopen($src,"r") ;
      >> //for each line in the file
      >> while ($row=fgetcsv($ fp,10000,';')) { //Get line
      >> $sql_insert="IN SERT INTO ...";
      >> if (!mysql_query($ sql_insert,$con n)){
      >> OutputError($sq l_insert,$mysql _error());
      >> $FailedCount++;
      >> }
      >> else {$InsertCount++ ;}
      >> }
      >>
      >>
      >>It works fine for the first couple of hundred or so rows but the stops -
      >>no errors, it just stops mid-loop.[/color]
      >
      >
      > Prepend the following to your script:
      >
      > ini_set('error_ reporting', E_ALL);
      > ini_set('displa y_errors', TRUE);
      >
      > I've got a feeling you will see a message like: max execution time has
      > been exceeded... http://www.php.net/set_time_limit
      >
      >[/color]
      Thank you - spot on

      Comment

      Working...