Are you actually putting the double quotes in the string, like: $query = '"SELECT * FROM table WHERE col = value"'; echo $query; //output is exactly: "SELECT * FROM table WHERE col = value If so, you need to remove the s from inside the string, mysql_query or whatever takes a normal string like: $query = "SELECT * FROM table WHERE col = value"; echo $query; //output is exactly: SELECT * FROM table WHERE col = value In much the same way, you don't end an SQL query with in the string like: $query = "SELECT * FROM table WHERE col = value.
Are you actually putting the double quotes in the string, like: $query = '"SELECT * FROM table WHERE col = value"'; echo $query; //output is exactly: "SELECT * FROM table WHERE col = value" If so, you need to remove the "s from inside the string, mysql_query or whatever takes a normal string like: $query = "SELECT * FROM table WHERE col = value"; echo $query; //output is exactly: SELECT * FROM table WHERE col = value In much the same way, you don't end an SQL query with ; in the string like: $query = "SELECT * FROM table WHERE col = value.
1 for the "don't end with ;" hint. Mysql_query doesn't support multi-querying – gd1 Apr 11 at 21:05 @Giacomo: more like the underlying driver doesn't. Mysql_query() just passes the query string directly onwards, it couldn't care less if there's invalid syntax, one query, or 500 queries in there.
– Marc B Apr 12 at 19:59 @Marc: I was just discussing the effect, from the point of view of the client, no matter the implementation. Thanks for your clarification. – gd1 Apr 12 at 20:36.
Example of concat for query $query = "select * from tablename "; $query. = "WHERE id=1"; $query. = " and item_id= 'foo.
Code SELECT * FROM fdatav1 JOIN ddatav1 ON ddatav1. ID = fdatav1. ID WHERE (acc1 = '1') – Mario111 Apr 11 at 20:57 is fdatav1 a php variable?
– mcgrailm Apr 11 at 21:00 Sorry about that comment, new to this site. The concat part is fine, works like a charm, when I echo $query I get: SELECT * FROM fdatav1 JOIN ddatav1 ON ddatav1. ID = fdatav1.ID WHERE (acc1 = '1') which works in phpmyadmin but, putting it in $result = mysql_query($query) I get a syntax error near '' – Mario111 Apr 11 at 21:00 try this: WHERE (`acc1` = '1' ) – Stewie Apr 11 at 21:04 no, it's a table.
So is ddatav1 – Mario111 Apr 11 at 21:04.
Try adding an else block to this bit of the code, as per below. Otherwise $filterQuery will never get set unless isset($_POSTtestType1). If (isset($_POSTtestType1)) { $filterQuery .
= $orTrigger . "(testType1 = '1'"; setOrTrigger(); $addTestFilterQuery = getTestFilterQuery("testType1"); if ($addTestFilterQuery! = NULL) { $filterQuery .
= "AND " . $addTestFilterQuery; } $filterQuery . = ") "; } else { $filterQuery = $query; }.
This question ended up evolving into a completely different one. The problem was with the POST method and Google Chrome. For more details feel free to check out the revised question and answer here.
Problem with $_POST, if isset() and mysql_fetch_assoc(): echo returns correct value, page source always returns else value.
I use the IF function to check isset() for a checkbox, which works fine. If the checkbox is checked it concatenates a string made of two parts. When I use mysql_fetch_assoc and echo the info in the $rows it works.
I have tried casting $filterQuery to a string as well. I still have a problem, it wasn't a typo. It works fine.
I get a syntax error one near ''. Does anyone know how to resolve this?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.