View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 09:51 AM
Dikkie Dik
 
Posts: n/a
Default Re: mysql queries in file

> Can someone explain me how to execute a mysql file with php.
>
> I try:
> fopen(myfile)
> $sql = fread( myfile )
> mysql_query( $sql )
>
> But it doesn't semms to work.


Correct. But the function mysqli_multi_query() should. You'd have to
have the mysqli library enabled, off course

>
> The other way is to "explode" $sql by ";",
> and then execute the queries one by one.


Which would give you the opportunity to check the lines beforehand,
_and_ to check the results and error conditions afterward.

>
> But executing entire file like in phpmyadmin is what i try to do.


My version of phpmyadmin does exactly what you describe above. It
returns the status for each single query.

Happy new year!
Reply With Quote