Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Just to be sure : when you are trying to execute these 4 queries from PHP, you're calling <code>mysql_query</code> four times ?</p> <p>For instance :</p> <pre><code>mysql_query("INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,1,1)"); mysql_query("INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,2,1)"); mysql_query("INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,3,1)"); mysql_query("INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,4,1)"); </code></pre> <p><br> What I mean is : you cannot send several distinct queries at once, with only one call to <a href="http://php.net/mysql_query" rel="nofollow noreferrer"><code>mysql_query</code></a> <em>(quoting, emphasis mine)</em> :</p> <blockquote> <p><code>mysql_query()</code> sends a unique query <strong>(multiple queries are not supported)</strong> to the currently active database on the server that's associated with the specified <code>link_identifier</code> .</p> </blockquote> <p>You have to "separate" your queries -- which is probably something phpMyAdmin does without telling you.</p> <p>And, as <a href="https://stackoverflow.com/users/162407/alexandre-jasmin">@Alexandre pointed out</a> in the comments :</p> <blockquote> <p>The query string should not end with a semicolon.</p> </blockquote> <p><br> If you are using the <a href="http://php.net/mysqli" rel="nofollow noreferrer"><code>mysqli_*</code></a> functions (and not <code>mysql_*</code>) to access your database, you could try using <a href="http://php.net/manual/en/mysqli.multi-query.php" rel="nofollow noreferrer"><code>mysqli_multi_query</code></a>.</p> <p>Unfortunately, there is such function for <code>mysql_*</code>.</p> <p>(BTW : the <code>mysql_*</code> API is the old one -- it would be better, especially for a new project, to use <code>mysqli_*</code>)</p> <p><br></p> <hr> <p><strong>Edit after the comment :</strong></p> <p>If it's about performances, yes, doing a single call to the database, instead of four successive <code>PHP &lt;-&gt; MySQL</code> calls, could be better.</p> <p>In this case, you could try using the insert syntax that allows to insert several lines at once ; see <a href="http://dev.mysql.com/doc/refman/5.1/en/insert.html" rel="nofollow noreferrer">12.2.5. INSERT Syntax</a> in MySQL's manual <em>(quoting)</em> :</p> <blockquote> <p><code>INSERT</code> statements that use <code>VALUES</code> syntax can insert multiple rows. <br>To do this, include multiple lists of column values, each enclosed within parentheses and separated by commas. <br>Example:</p> <pre><code>INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9); </code></pre> <p>The values list for each row must be enclosed within parentheses.</p> </blockquote>
 

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