From:             leonardodeconti at yahoo dot com dot br
Operating system: Linux 2.6.24.2
PHP version:      5.2.6
PHP Bug Type:     MSSQL related
Bug description:  Error in mssql_query when the script create large text files

Description:
------------
Into of a loop(while):
1) I open the file handler (w)
2) Caught data on database (MSSQL 2005)
3) Record the data to file (fwrite)
4) Close handler
5) Continue loop until end

If the file created (step 3) is large (over +- 25MB), the next query gives
error. But if the file is small, the script works well.

In my script, I have to make the export of large tables, separated.

If I remove the element 'large_table' of the array $tables, the export
will work perfectly.



Reproduce code:
---------------
<?php
function replace_characters($value) {
   return str_replace("'","''",$value);
}

mssql_connect('server_name','user_name','passwrd') or die('error connect
to database');
mssql_select_db('database_name');

$tables =
array('large_table','medium_table','small_table','medium_table');
$hadler = '';
foreach($tables as $table) {
   $handler = fopen("$tabele.sql","w");
   $res_sql = mssql_query("SELECT * FROM $table");
   while($table_data = mssql_fetch_assoc($res_sql)) {
      $table_data = array_map('replace_characters',$table_data);
      fwrite($handler,"INSERT INTO $table
values('".implode("','",$table_data)."');\n");
   }
   echo "\n$table exported";
   fclose($handler);
}
echo "export finished";
?>

Expected result:
----------------
large_table exported
medium_table exported
small_table exported
medium_table exported
end

Actual result:
--------------
large_table exported
Warning: mssql_query(): Query failed in
/htdocs/export_data_as_sql_insert.php on line 15


-- 
Edit bug report at http://bugs.php.net/?id=45812&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45812&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45812&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45812&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45812&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45812&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45812&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45812&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45812&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45812&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45812&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45812&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45812&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45812&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45812&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45812&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45812&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45812&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45812&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45812&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45812&r=mysqlcfg

Reply via email to