Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As <strong>hookman</strong> has rightly mentioned in comments <a href="http://news.php.net/php.internals/53799" rel="nofollow">mysql extension is depreciated</a> and should not be used.</p> <p><strong>EDIT</strong> Now that you code is edited. As you mentioned <em>I don't know the API</em> but I do know one possible solution.</p> <ul> <li>Assign your query to a variable. </li> <li>Replace the last part of the query so that the <code>,</code> is removed.</li> </ul> <p>Try:</p> <pre><code>... %[endrepeat]% $query = 'INSERT INTO `%id=table%` (%[repeat items]% %[endif]%%html="Edit Me"%%[if !edit]% %[endrepeat]% ) VALUES (%[repeat items]%"' . $form_input%id=repeatIndex% . '",%[endrepeat]%);'; $query = preg_replace('/,\);$/',');',$query); mysql_query($query); .... </code></pre> <p>The <code>preg_replace</code> will simply edit your query, so that any string that has <code>,);</code> at the end of it, will be replaced with <code>);</code>. You can use that with other queries, just figure out how to transform them with RegEx. </p> <p>I understand that your markup language (whatever it is that you use) has limitations that could prohibit you to do this utilizing it's standard functionality - in this case 'manually' (with regex or otherwise replace) editing the string is your only option (that or parsing it somehow).</p> <p>Alternatively, this might work:</p> <pre><code>... %[repeat items]% $values = array( mysql_real_escape_string($form_input%id=repeatIndex%), mysql_real_escape_string($form_input%id=repeatIndex%) ); %[endrepeat]% $query = 'INSERT INTO `%id=table%` (%[repeat items]% %[endif]%%html="Edit Me"%%[if !edit]% %[endrepeat]% ) VALUES (' . "'" . implode("','", $values) . "')"; ... </code></pre>
 

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