При запуске код:PHP/SQL - Ошибка SQL Синтаксис
$result = select_query("tblinvoices", "", "id IN
(SELECT invoiceid FROM tblinvoiceitems
WHERE description LIKE '%Project #" . $projectid . "%'
OR " . $ticketinvoicesquery . " (type='Project'
AND relid='" . $projectid . "'))
OR id IN (" . db_build_in_array(db_escape_numarray($invoiceids)) . ")",
"id", "ASC");
ошибка появляется в журнале:
SQL Error: 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 ') ORDER BY `id` ASC' at line 1
- Full Query: SELECT * FROM tblinvoices WHERE id IN (SELECT invoiceid
FROM tblinvoiceitems WHERE description
LIKE '%Project #4%' OR (type='Project' AND relid='4'))
OR id IN() ORDER BY `id` ASC
Как решить эту ошибку?
UPDATE:
Когда у меня нет счета-фактуры не эта ошибка в журнале. Когда у меня есть счет, код работает отлично.
{include file="$template/subheader.tpl" title=$_lang.associatedinvoices}
{if $invoices}
<table class="table table-striped table-framed">
<thead>
<tr>
<th style="width:10%" class="textcenter">N°</th>
<th style="width:15%" class="textcenter">Date</th>
<th style="width:15%" class="textcenter">Due date</th>
<th style="width:20%" class="textcenter">Price</th>
<th style="width:20%" class="textcenter">Status</th>
<th style="width:20%" class="textcenter">View</th>
</tr>
</thead>
<tbody>
{foreach from=$invoices item=invoice}
<tr>
<td class="textcenter">#{$invoice.id}</td>
<td class="textcenter">{$invoice.date}</td>
<td class="textcenter">{$invoice.duedate}</td>
<td class="textcenter">{$invoice.total}</td>
<td class="textcenter"><span class="label {$invoice.rawstatus}">{$invoice.status}</span></td>
<td class="textcenter"><a href="viewinvoice.php?id={$invoice.id}"><i class="fa fa-eye icon_view" title="View"></i></a></td>
</tr>
{/foreach}
</tbody>
</table>
<br />
{else}
<p>{$_lang.none}</p>
{/if}
Спасибо!
'db_build_in_array (db_escape_numarray ($ invoiceids))' является NULL value..It должен быть массив .. –
Там нет 'ORDER BY' в вашем коде. Покажите нам, что генерирует этот код. –
@Shaunak Shukla: он не должен быть массивом, он должен быть строкой, в частности строкой, содержащей хотя бы одно значение списка, например: '1,2' или' "one", "two" ' – SpliFF