Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have more problem cases than just semicolons within strings. </p> <ul> <li>Script <a href="http://dev.mysql.com/doc/refman/5.1/en/mysql-commands.html" rel="nofollow noreferrer">builtin</a> commands that cannot be executed by <code>mysql_query()</code>, like <code>USE</code>.</li> <li>Statements that are not terminated with a semicolon, like <a href="http://dev.mysql.com/doc/refman/5.1/en/stored-programs-defining.html" rel="nofollow noreferrer"><code>DELIMITER</code></a>.</li> <li>Statements that contain semicolons, but not inside quotes, like <code>CREATE PROCEDURE</code>.</li> </ul> <p>I don't know of an easy way to handle this task, without shelling out to the mysql command-line client. I realize you said you can't rely on that client being present, but without that client, you need a large amount of PHP code to parse the script and execute statements appropriately.</p> <p>You may be able to find such code inside the <a href="http://www.phpmyadmin.net/home_page/index.php" rel="nofollow noreferrer">phpMyAdmin</a> product. However, that product is licensed under the GPL, so if you use any of the code, you must also license your own project under the GPL.</p> <hr> <p>See also my answers to these related questions:</p> <ul> <li><a href="https://stackoverflow.com/questions/4027769/running-mysql-sql-files-in-php/4028289#4028289">Running MySQL *.sql files in PHP</a></li> <li><a href="https://stackoverflow.com/questions/147821/loading-sql-files-from-within-php/149456#149456">Loading .sql files from within PHP</a></li> <li><a href="https://stackoverflow.com/questions/547915/is-it-possible-to-call-a-sql-script-from-a-stored-procedure-in-another-sql-script/548119#548119">is it possible to call a sql script from a stored procedure in another sql script?</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload