Error in query with parameter.

QuestionsError in query with parameter.
Daniel Valinotti asked 10 years ago

Good afternoon, I have a problem, wanting to bring the data of the table where they were saved, I need to make a where the query with a parameter, here I post the query sample and the error I get:

Query:
$ g-> select_command = "SELECT * FROM Customers Where customer_id = $ ultimo_id";

Error:
Could not execute query. 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 1 OFFSET 0' at line 1 – SELECT * FROM Customers Where customer_id = LIMIT 1 OFFSET 0

Stay tuned for your help, thank you very much.

1 Answers
Abu Ghufran answered 10 years ago

To use post variables in query, you need to use sessions.

Q) How to load grid based on $_POST data from other page?

The grid is loaded with 2 server calls.

1) load the columns of grid.
2) do an ajax call, to load data of grid.

Now, if you want to pass data from external form, it is available for step1. But not there in 2nd ajax call, as it is not posted.
Solution is to put the POST variable in session and use it from session for step2.

e.g.

if (!empty($_POST["personid"]))
{
$_SESSION["personid"] = $_POST["personid"];
}
$pid = $_SESSION["personid"];

and use `$pid` in your SQL.

Your Answer

6 + 19 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?