0

use ereg_replace are error : Deprecated: Function ereg_replace() is deprecated. and preg_replace are error : Warning: preg_replace(): Empty regular expression. how to fix problems ?

 for ($i = 0; $i < $numFields; $i++) 
            {
                while($row = mysql_fetch_row($result))
                {
                    $sql .= 'INSERT INTO '.$table.' VALUES(';
                    for($j=0; $j<$numFields; $j++) 
                    {
                        $row[$j] = addslashes($row[$j]);
                        $row[$j] = ereg_replace("\n","\\n",$row[$j]);
                        if (isset($row[$j]))
                        {
                            $sql .= '"'.$row[$j].'"' ;
                        }
                        else
                        {
                            $sql.= '""';
                        }

                        if ($j < ($numFields-1))
                        {
                            $sql .= ',';
                        }
                    }

                    $sql.= ");\n";
                }
            }
  • your preg_replace is? – miglio Jul 14 '15 at 13:40
  • have you changed `ereg_replace` with `preg_replace("/\n/","\\n",$row[$j]);` ? – miglio Jul 14 '15 at 13:41
  • Better yet, replace it with `mysql_real_escape_string`. Because that's what your code is doing there (in a rather tedious way). Using a table gateway and parameter binding would be much easier even. Just saying. – mario Jul 14 '15 at 13:47

0 Answers0