Page 1 of 2

Syntax error at "h" And SQLPrepare() failed

Posted: Wed Mar 18, 2015 9:08 am
by princegoyal91
Hi Team,

I have indexed the records in texis DB. But whenever I try to search the data from front end, it does not show any results.

On checking logs I am getting below error:

015 2015-03-18 07:00:13 /webinator/search:1966: Line 7: syntax error at "h"
000 2015-03-18 07:00:13 /webinator/search:1966: SQLPrepare() failed with -1 in the function prepntexis

On debug the code I found that this "h" is coming from a RAM table which ideally must have other values(Numeric values).

I tried killing the cache of Linux server as-well but it could not help.

Please Advise as soon as possible as it is very urgent.

Thanks for the co-operation.

Regards,
Dipander Goyal

Syntax error at "h" And SQLPrepare() failed

Posted: Wed Mar 18, 2015 10:01 am
by John
The message indicates the "h" is part of a SQL statement. What is the complete SQL statement on line 1966? Are you pulling parts of the SQL from a RAM table? If so I think that must be a modified script, so it's difficult to diagnose without more information. Please email support to start a more indepth process.

Syntax error at "h" And SQLPrepare() failed

Posted: Wed Mar 18, 2015 10:02 am
by mark
Show us the code on, and possibly around, line 1966 of your search script.

Syntax error at "h" And SQLPrepare() failed

Posted: Wed Mar 18, 2015 10:23 am
by princegoyal91
Thanks for the quick response.

on line 1966, we are pulling the part of query from RAM table.

Query is:

<sql "select count(*) ic from $tablename where ProdName\Desc\Keywords likep $likep_query
and (" $comsqlquery $sqlGrpsQuery ") " $commCatgClause>
</sql>

$comsqlquery variable fetches the information from RAM Table.

Is there any way to get the records a particular RAM table is containing?

Syntax error at "h" And SQLPrepare() failed

Posted: Wed Mar 18, 2015 10:56 am
by John
The RAM table only exists in the process it's running in, so a select * from the table is the way to get the records.

Syntax error at "h" And SQLPrepare() failed

Posted: Wed Mar 18, 2015 11:02 am
by princegoyal91
Yes, RAM table is present only in that process.

Can you please tell me if there is any particular PATH/Location to run this select query for RAM Table?

Syntax error at "h" And SQLPrepare() failed

Posted: Wed Mar 18, 2015 11:06 am
by mark
$tablename can't be a parameter. Try
"select count(*) ic from " $tablename " where ...

And make sure $tablename is sanitized (not coming from user input).

Syntax error at "h" And SQLPrepare() failed

Posted: Wed Mar 18, 2015 11:07 am
by mark
But since the syntax error is at line 7, perhaps the problem is in your $comsqlquery $sqlGrpsQuery or $commCatgClause.

Turn on tracesql to see what's actually getting executed.

Syntax error at "h" And SQLPrepare() failed

Posted: Wed Mar 18, 2015 11:36 am
by princegoyal91
Sorry, I did not get the path where we will run your mentioned query("select count(*) ic from " $tablename ") for RAM Table.

Syntax error at "h" And SQLPrepare() failed

Posted: Wed Mar 18, 2015 11:58 am
by princegoyal91
I kept sqltrace ON and below query is getting executed:

select Prod, ProdName, Busid, SubBusid, SupCommFlag, comm_hits, Desc, Keywords from community where ProdName\esc\Keywords likep ? and ( ( CommRstdFlag=0 or Prod in ( h:&#9618;&#9618; )) ) ; FAILED

It says Prod in (h:) but "Prod in" must have few id's. Example (Prod in(1232,2434))

This "Prod in" query data is coming from RAM Table and it is the part of $comsqlquery.