I think you want to remove the single quotes around the field names.
SELECT * FROM my_table WHERE (field_1 LIKE '%$keyword%' OR
field_2 LIKE '%$keyword%' OR field_3 LIKE '%$keyword%') AND
status = 'active';
I STFW and RTFM and I still can't figure out why this returns a 1064
parse error:
The parenthesis are OK. The query might take a long time to run with 3 LIKE
statements.
Backticks, single quotes, or nothing at all makes no difference. I
believe the parsing error is due to my parentheses or AND/OR structure.
Any thoughts on that?
On Apr 23, 2004, at 8:32 AM, John W.
I STFW and RTFM and I still can't figure out why this returns a 1064
parse error:
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
'status' = 'active';
Anyone? TIA!
- B1ff Lamer
--
PHP General Mailing List
why are the table and field names surrounded by single quotes?
-Original Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 11:19 AM
To: [EMAIL PROTECTED]
Subject: [PHP] OK SQL experts...
I STFW and RTFM and I still can't figure out why this returns
?
-Original Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 11:19 AM
To: [EMAIL PROTECTED]
Subject: [PHP] OK SQL experts...
I STFW and RTFM and I still can't figure out why this returns a 1064
parse error:
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword
[snip]
I tried it both ways - didn't make any difference (phpmyadmin adds the
single quotes when I was trying to use its sql function to debug, so I
figured what the hell)...
[/snip]
Those aren't single quotes it adds to table and column names...those are
back tics (on the same key as the
does it just return the error when running in the php page? If you pull it
out can you run it in mysql without errors?
-Original Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 11:23 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] OK SQL experts...
I
]
Sent: Friday, April 23, 2004 11:23 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] OK SQL experts...
I tried it both ways - didn't make any difference (phpmyadmin adds the
single quotes when I was trying to use its sql function to debug, so I
figured what the hell)...
On Apr 23, 2004, at 8:27 AM
the hell)...
On Apr 23, 2004, at 8:27 AM, Edward Peloke wrote:
why are the table and field names surrounded by single quotes?
-Original Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 11:19 AM
To: [EMAIL PROTECTED]
Subject: [PHP] OK SQL experts...
I
From: Brian Dunning [EMAIL PROTECTED]
I STFW and RTFM and I still can't figure out why this returns a 1064
parse error:
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
'status' = 'active';
Use backticks
Backticks, single quotes, or nothing at all makes no difference. I
believe the parsing error is due to my parentheses or AND/OR structure.
Any thoughts on that?
On Apr 23, 2004, at 8:32 AM, John W. Holmes wrote:
From: Brian Dunning [EMAIL PROTECTED]
I STFW and RTFM and I still can't figure
[mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 11:23 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] OK SQL experts...
I tried it both ways - didn't make any difference
(phpmyadmin adds the
single quotes when I was trying to use its sql function to
debug, so I
figured what
[snip]
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
'status' = 'active';
[/snip]
How about this?
SELECT * FROM my_table WHERE (field_1 LIKE '%$keyword%' OR
field_2 LIKE '%$keyword%' OR field_3 LIKE '%$keyword%')
what value is being put in the $keyword variable? You are sure all these
columns exist?
-Original Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 11:36 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] OK SQL experts...
Backticks, single quotes, or nothing
if you echo out the query..what is the output?
-Original Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 11:36 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] OK SQL experts...
Backticks, single quotes, or nothing at all makes no difference. I
believe
Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 11:36 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] OK SQL experts...
Backticks, single quotes, or nothing at all makes no difference. I
believe the parsing error is due to my parentheses or AND/OR structure.
Any
PROTECTED]
Subject: Re: [PHP] OK SQL experts...
Backticks, single quotes, or nothing at all makes no difference. I
believe the parsing error is due to my parentheses or AND/OR structure.
Any thoughts on that?
On Apr 23, 2004, at 8:32 AM, John W. Holmes wrote:
From: Brian Dunning [EMAIL PROTECTED
[mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 11:36 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] OK SQL experts...
Backticks, single quotes, or nothing at all makes no difference.
I
believe the parsing error is due to my parentheses or AND/OR
structure.
Any thoughts
I STFW and RTFM and I still can't figure out why this returns a 1064
parse error:
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
'status' = 'active';
Why don't you try rebuilding the query. I mean go into
[snip]
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
'status' = 'active';
[/snip]
*slaps forehead*
SELECT * FROM my_table WHERE (field_1 LIKE '% . $keyword . %' OR
field_2 LIKE '% . $keyword . %' OR field_3 LIKE
? You are sure
all
these
columns exist?
-Original Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 11:36 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] OK SQL experts...
Backticks, single quotes, or nothing at all makes no difference.
I
believe the parsing
Brian Dunning mailto:[EMAIL PROTECTED]
on Friday, April 23, 2004 8:19 AM said:
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
'status' = 'active';
have you tried simply:
SELECT * FROM my_table WHERE status =
[snip]
SELECT * FROM my_table WHERE (field_1 LIKE '%$keyword%') AND status =
'active';
if that works continue until you get an error.
[/snip]
That'll give you an error right there. That old single quoted variable
will get you every time. :)
WHERE (field_1 LIKE '%$keyword%')
WHERE (field_1
Hi,
Saturday, April 24, 2004, 1:55:36 AM, you wrote:
JB [snip]
JB SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
JB 'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
JB 'status' = 'active';
JB [/snip]
JB *slaps forehead*
JB SELECT * FROM my_table WHERE (field_1
if that works move up into:
SELECT * FROM my_table WHERE (field_1 LIKE '%$keyword%') AND status =
'active';
Yes, I actually did exactly that. Everything works until I have more
than one statement inside the (x LIKE x OR x LIKE x) parens. That's why
I figured there has to be something wrong with
[snip]
They do if they are themselves inside double quotes :)
echo '$var'; will get parsed ok
[/snip]
I know, but since I saw no double quotes I had to go for the obvious. :)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Hi,
Saturday, April 24, 2004, 2:03:36 AM, you wrote:
JB [snip]
JB They do if they are themselves inside double quotes :)
JB echo '$var'; will get parsed ok
JB [/snip]
JB I know, but since I saw no double quotes I had to go for the obvious. :)
Yes I would like to see the whole truth as well :)
Hello Brian,
Friday, April 23, 2004, 5:02:00 PM, you wrote:
BD Yes, I actually did exactly that. Everything works until I have more
BD than one statement inside the (x LIKE x OR x LIKE x) parens. That's why
BD I figured there has to be something wrong with my paren structure. When
BD I RTFM I
How are you manipulating the whole SQL string??
$sql = SELECT...; ???
or
$sql = 'SELECT...'; ???
In this case you will have to use double quotes because PHP won't parse
single quote strings for searching embedded PHP variables.
May be this is the problem.
-William
El vie, 23-04-2004 a
* Thus wrote Brian Dunning ([EMAIL PROTECTED]):
I STFW and RTFM and I still can't figure out why this returns a 1064
parse error:
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
'status' = 'active';
You might
Brian Dunning wrote:
I STFW and RTFM and I still can't figure out why this returns a 1064
parse error:
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR 'field_2'
LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND 'status' = 'active';
Anyone? TIA!
- B1ff Lamer
What does
On Apr 23, 2004, at 10:13 AM, John Nichel wrote:
Brian Dunning wrote:
I STFW and RTFM and I still can't figure out why this returns a 1064
parse error:
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
'status' =
doesn't look like your $keyword value contains anything.
-Original Message-
From: Brian Dunning [mailto:[EMAIL PROTECTED]
Sent: Friday, April 23, 2004 1:19 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] OK SQL experts...
On Apr 23, 2004, at 10:13 AM, John Nichel wrote:
Brian Dunning
On Apr 23, 2004, at 10:27 AM, Edward Peloke wrote:
doesn't look like your $keyword value contains anything.
My error. Here is the actual return:
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
''my_table'
* Thus wrote Brian Dunning ([EMAIL PROTECTED]):
On Apr 23, 2004, at 10:13 AM, John Nichel wrote:
Brian Dunning wrote:
I STFW and RTFM and I still can't figure out why this returns a 1064
parse error:
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
'field_2' LIKE
Hello Brian,
Friday, April 23, 2004, 6:18:43 PM, you wrote:
BD You have an error in your SQL syntax. Check the manual that corresponds
BD to your MySQL server version for the right syntax to use near
BD ''my_table' WHERE ('field_1' LIKE '%%' OR 'field2'
my_table should NOT be quoted in this
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
''my_table' WHERE ('field_1' LIKE '%%' OR 'field2'
Because you are using a single quotes around your table/field
names. Remove them or use ` (back tick). As
From: Brian Dunning [EMAIL PROTECTED]
My error. Here is the actual return:
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
''my_table' WHERE ('field_1' LIKE '%custom%' OR 'field_
I am searching for the
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
''my_table' WHERE ('field_1' LIKE '%%' OR 'field2'
Because you are using a single quotes around your table/field
names. Remove them or use ` (back tick). As
Brian Dunning wrote:
On Apr 23, 2004, at 10:13 AM, John Nichel wrote:
Brian Dunning wrote:
I STFW and RTFM and I still can't figure out why this returns a 1064
parse error:
SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
'field_2' LIKE '%$keyword%' OR 'field_3' LIKE
40 matches
Mail list logo