To clear up: the SQL standard requires strings to be inside single quotes: 'string'. It simply does not accept double quotes for this purpose.
Furthermore, in PHP, you can have a single quote inside double quotes: "select a from b where c = 'string'" without the need to escape.
add a note User Contributed Notes odbc_do - [5 notes]
6 years ago
5 years ago
I used the following code to run normal double quotes inside my SQL queries. Hopefully this will save someone else a headache or two-
* Query Function
* Allows quoted queries to be sent to SQL
function query($query, $conn)
odbc_do($conn, 'SET QUOTED_IDENTIFIER OFF');
return odbc_do($conn, $query);
yashkhopade at hotmail dot com ¶
9 years ago
i have use this function so many times. it works well for my requirements. ok well done...
$sqlstr="SELECT bill_no FROM SCROL";
// if we want to access the records
// then we have to write the following code
the out put for this will:
which is actullay first record of resultset.
6 years ago
$sql = INSERT INTO table (field1,field2,field3,field4) VALUES ("text value 1", "text 2",3,"text 4")";
of cos u will get an error fro php due to double quotes inside double quotes. The correct way of doing that is
$sql = "INSERT INTO table (field1, field2, field3, field4) VALUES
(\"text1\", \"text2\", \"text3\", \"text4\")";
Dont forget the backslash when u want to insert a " within double quotes.
nmaskell at livingchurch dot net ¶
7 years ago
Some of you may be having problems with Access SQL.
I got "Too few parameters" many times before I figured this out.
MS Access does not like double quotes in a SQL string like this:
$sql = 'INSERT INTO table (field1,field2,field3,field4) VALUES ("text value 1", "text 2",3,"text 4")';
This resulted in an obscure error: Too few parameters.
So - The following should work much better:
$sql = "INSERT INTO table (field1,field2,field3,field4) VALUES ('text value 1', 'text 2',3,'text 4')";