Re: Import .sql file via PHP



On 2005-05-30, Jamie Meyers <gtg061q@xxxxxxxxxxxxxxx> wrote:
> Nevermind, I decided to parse the .sql file and create the query there. I
> do not think there is any way to import the .sql file via php. Thanks
> anyways. And if anyone would like this script after I fix it up a little
> more, let me know.

Assuming each instruction is on a line.. (untested)

$db = mysql_connect(....);
mysql_select_db(....);

$fp = fopen('somefile.sql', 'r');
while($fp != feof())
{
$line = fread($fp, 2048);
$line = mysql_real_escape_string($db, $line);
mysql_query($line);
}
fclose($fp);


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



Relevant Pages

  • Re: happy new year with a simpleton question...
    ... of all I think we should put the names of the pictures into an array, ... Ok so now the script knows the names of the files we may display. ... Prev by Date: ...
    (alt.php)
  • Re: confusing >> results
    ... > yawnmoth wrote: ... The following script better demonstrates this: ... > My guess is that PHP sees 0x8000000 as a *signed* integer ... Prev by Date: ...
    (comp.lang.php)
  • simple question
    ... I am fairly new to php and I am trying to develop a simple script that ... Basically, I want a login ... Prev by Date: ...
    (comp.lang.php)
  • Re: Version
    ... subdirectory from php to phpinfo, the script started to work. ... Prev by Date: ...
    (alt.php)
  • Re: Import .sql file via PHP
    ... do not think there is any way to import the .sql file via php. ... And if anyone would like this script after I fix it up a little more, ...
    (comp.lang.php)