Dear all,,

As i used to display pagination along with searching the script work first time correctly and When i try to see the first or previous page this error message is occuring...
What is the error in this ...


Second Query= SELECT SQL_CALC_FOUND_ROWS * FROM reg_personal inner join reg_english_level inner join reg_services inner join reg_status ON(reg_personal.personal_code=reg_english_level.english_code AND reg_english_level.english_code=reg_services.services_code AND reg_services.services_code=reg_status.status_code)WHERE LIMIT 0,5
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 'LIMIT 0,5' at line 1

Thanks in advance..
Jino.

there is no where condition for limit. select * from table where limit 0,5 Wrong. select * from table limit 0,5 Right.

Nav there is a searching query and i want to display the result as paginated....
The search conditions are entered into an arrray variable and it is included after the WHERE CLAUSE of the query...
At first when the page is loaded there is no prob
but when i click the next or previous button in the pagination page then the previous mentioned error occured......

I have noticed that this time the $array variable containing the search conditons are not displaying there in the query, that conatins the $limit variable.

What i want to do for displaying the string array after the WHERE CLAUSE & before the $limit;

Please help me...
Jino.

Well, you can put the where clause in the condition. If it satisfies the condition, print it. Else dont !
Eg.

if ($condition){
$where = "where x='$x' and y='$y'";
} else {
$where = "";
}
$query = "select * from table $where"; //it will have where clause only if the condition is satisfied. Else where will be null and it wont affect the query!

There is no prob with the WHERE CLAUSE.....
Let me explain a littel more clearer

I have a search query like..

$query_data=" SELECT SQL_CALC_FOUND_ROWS * FROM reg_personal inner join reg_english_level inner join reg_services inner join reg_status ON(reg_personal.personal_code=reg_english_level.english_code AND reg_english_level.english_code=reg_services.services_code AND reg_services.services_code=reg_status.status_code) WHERE $query_string ";

If i search for the male records then the result will be...

$Query_string= reg_personal.personal_sex = 'Male'

Second Query= SELECT * FROM reg_personal inner join reg_english_level inner join reg_services inner join reg_status ON(reg_personal.personal_code=reg_english_level.english_code AND reg_english_level.english_code=reg_services.services_code AND reg_services.services_code=reg_status.status_code)WHERE reg_personal.personal_sex = 'Male' LIMIT 5,5

And when i click on the link for the first page I am getting this error message..

Second Query= SELECT * FROM reg_personal inner join reg_english_level inner join reg_services inner join reg_status ON(reg_personal.personal_code=reg_english_level.english_code AND reg_english_level.english_code=reg_services.services_code AND reg_services.services_code=reg_status.status_code)WHERE LIMIT 0,5
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 'LIMIT 0,5' at line 1.

Please note the blank between the WHERE AND LIMIT clauses...This means we want to pass the $query_string through the url along with the pageno, of pagination...

and i have given like
<a href='{$_SERVER}?pageno=1&query_string=$query_string1'>&lt;&lt;First</a>

and i can retrive the value of pageno via the statement ...$pageno=$_get;

But i can't retrive the value of query_string using the statement ...$query_str=$_get;

I hope my way of thinking is correct...

Is there bug in php when inner join and $limit will come together..?????

Please help me.....

Jino..

There is no Prob with the Where Clause

Let me explain a little more clearer

I have a search query like..

$query_data=" SELECT SQL_CALC_FOUND_ROWS * FROM reg_personal inner join reg_english_level inner join reg_services inner join reg_status ON(reg_personal.personal_code=reg_english_level.english_code AND reg_english_level.english_code=reg_services.services_code AND reg_services.services_code=reg_status.status_code) WHERE $query_string ";

If i search for the male records then the result will be...

$Query_string= reg_personal.personal_sex = 'Male'

Second Query= SELECT * FROM reg_personal inner join reg_english_level inner join reg_services inner join reg_status ON(reg_personal.personal_code=reg_english_level.english_code AND reg_english_level.english_code=reg_services.services_code AND reg_services.services_code=reg_status.status_code)WHERE reg_personal.personal_sex = 'Male' LIMIT 5,5

And when i click on the link for the first page I am getting this error message..

Second Query= SELECT * FROM reg_personal inner join reg_english_level inner join reg_services inner join reg_status ON(reg_personal.personal_code=reg_english_level.english_code AND reg_english_level.english_code=reg_services.services_code AND reg_services.services_code=reg_status.status_code)WHERE LIMIT 0,5
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 'LIMIT 0,5' at line 1.

Please note the blank between the WHERE AND LIMIT clauses...This means we want to pass the $query_string through the url along with the pageno, of pagination...

and i have given like
<a href='{$_SERVER}?pageno=1&query_string=$query_string1'>&lt;&lt;First</a>

and i can retrive the value of pageno via the statement ...$pageno=$_get;

But i can't retrive the value of query_string using the statement ...$query_str=$_get;

I hope my way of thinking is correct...

Is there bug in php when inner join and $limit will come together..?????

Please help me.....

Jino..

Second Query= SELECT * FROM reg_personal inner join reg_english_level inner join reg_services inner join reg_status ON(reg_personal.personal_code=reg_english_level.english_code AND reg_english_level.english_code=reg_services.services_code AND reg_services.services_code=reg_status.status_code)WHERE LIMIT 0,5

LIMIT 0,5 cannot be in the where clause. And, there's no bug in php w.r.t inner joins and limit.

LIMIT 0,5 cannot be in the where clause. And, there's no bug in php w.r.t inner joins and limit.

Nav Please read the above thread completly

The Query_string is needed to come in between WHERE and LIMIT...

Please show kind towards me to read the explanation given above...

Thanks in advance,
Jino

This article has been dead for over six months. Start a new discussion instead.