vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi all, 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. The other way is to "explode" $sql by ";", and then execute the queries one by one. But executing entire file like in phpmyadmin is what i try to do. Thanks in advance, |
| ||||
| > 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! |