SQL statements that are spelled in PHP

Source: Internet
Author: User
I'm in the PHP spelling of the SQL statement, after the input is this

SELECT * from ' zx_solutions ' where s_id = 6?

Put this statement in the database to execute, reported the following error:
[SQL]
SELECT * from ' zx_solutions ' where s_id = 6?

[ERR] 1054-unknown column ' 6? ' in ' WHERE clause '

Please expert guidance:


Reply to discussion (solution)

SELECT * from ' zx_solutions ' where ' s_id ' = 6?
Such

@ #2, that doesn't work, it treats 6 as a column

Post your code snippet
Guess where the space was wrong.

function Getsolutionbyid ($SID) {
$sql = "SELECT * from zx_solutions where s_id = $sid";
Echo $sql;
$rs = $this->db->query ($sql);
return $rs;
}

Run the above code error?
What database do you use, what is the structure of the Zx_solutions table? It's best to list them all.

Try the 6 quotation marks.

6 don't have a space at the front

You change a tool to run a test, not yet, it is probably MySQL problem, it can only explain

It's very practical to learn.

Is ' zx_solutions ' sure it is ' this symbol?


SELECT * from ' Table name ' where field name = ' 6 '

It could be the wrong sign.

SELECT * from ' zx_solutions ' where ' s_id ' = ' 6 '?

First check whether the connection database and data table is successful, and then check whether the value of the query is malformed, step by step slowly

????

function Getsolutionbyid ($sid) {  $sql = "SELECT * from zx_solutions where s_id =". Intval ($SID);  echo $sql;  $rs = $this->db->query ($sql);  
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.