Note that there are some explanatory texts on larger screens.

plurals
  1. POConfusing in phpmysql concatenation
    text
    copied!<p>I have the script like:</p> <pre><code>$sLimit = ""; if ( isset( $_POST['iDisplayStart'] ) &amp;&amp; $_POST['iDisplayLength'] != '-1' ) { $sLimit = "LIMIT ".mysql_real_escape_string( $_POST['iDisplayStart'] ).", ". mysql_real_escape_string( $_POST['iDisplayLength'] ); } if ( isset( $_POST['iSortCol_0'] ) ) { $sOrder = "ORDER BY "; for ( $i=0 ; $i&lt;intval( $_POST['iSortingCols'] ) ; $i++ ) { if ( $_POST[ 'bSortable_'.intval($_POST['iSortCol_'.$i]) ] == "true" ) { $sOrder .= $aColumns[ intval( $_POST['iSortCol_'.$i] ) ]." ".mysql_real_escape_string( $_POST['sSortDir_'.$i] ) .", "; } } $sOrder = substr_replace( $sOrder, "", -2 ); if ( $sOrder == "ORDER BY" ) { $sOrder = ""; } } $sGroupBy = " GROUP BY A.Range_sampling, A.Lot_no "; $sQuery = "SELECT SQL_CALC_FOUND_ROWS DATE(A.Inspection_datetime) AS Date, A.Line, A.Model, A.Lot_no,A.Range_sampling,COUNT(A.Serial_number) AS Error,B.name AS PIC FROM inspection_report A LEFT JOIN Employee B ON A.NIK=B.NIK WHERE CHAR_LENGTH( A.Range_sampling ) &lt; 17 AND MONTH(A.Inspection_datetime)=MONTH(CURRENT_DATE)" .$sGroupBy.$sOrder.$sLimit; //error $rResult = mysql_query($sQuery) or _doError(_ERROR30 . ' (&lt;small&gt;' . htmlspecialchars($sql) . '&lt;/small&gt;): ' . mysql_error() ); </code></pre> <p>for this script I got error:</p> <pre><code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0, 10' at line 7 </code></pre> <hr> <p>after add space show:</p> <pre><code>Error message is :: "Error occuered during query execution: (&lt;small&gt;&lt;/small&gt;): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc LIMIT 0, 10' at line 8"; </code></pre> <hr> <p>The full query:</p> <p><code>SELECT SQL_CALC_FOUND_ROWS DATE(A.Inspection_datetime) AS Date, A.Line, A.Model, A.Lot_no,A.Range_sampling,COUNT(A.Serial_number) AS Error,B.name AS PIC FROM inspection_report A LEFT JOIN Employee B ON A.NIK=B.NIK WHERE CHAR_LENGTH( A.Range_sampling ) &lt; 17 AND MONTH(A.Inspection_datetime)=MONTH(CURRENT_DATE) GROUP BY A.Range_sampling, A.Lot_no ORDER BY desc LIMIT 0, 10</code></p>
 

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