"Jan Nordgreen" <room23111@hotmail.com> wrote in message
news:3488b88c.0403151712.5126495b@posting.google.c om...[color=blue]
> However, when I add the condition
> !(strpos(fdetails,'$fsearchstring')===false),
> $result is false.[/color]
You're feeding PHP code to the MySQL interpreter and it has absolutely no
clue what you're talking about.
[color=blue]
> $result = mysql_query("
> SELECT feventid, UNIX_TIMESTAMP(fdate) as fdate, ftitle, fpostedby,
> fdetails, factive, UNIX_TIMESTAMP(fpostdate) as fpostdate
> FROM events
> WHERE
> fdate between '$datefrom' and '$dateto'
> and factive
> and fpostdate <= curdate()
> and !(strpos(fdetails,'$fsearchstring')===false)
> ORDER BY fdate, fpostdate
> ");[/color]
SELECT feventid, UNIX_TIMESTAMP(fdate) as fdate, ftitle, fpostedby,
fedetails, factive, UNIX_TIMESTAMP(fpostdate) as fpostdate
FROM event
WHERE fdate between '$dateform' and $dateto'
AND factive
AND fpostdate <= curdate()
AND fdetails LIKE '%$fsearchstring%' // <-- LOOK HERE
ORDER BY fdate, fpostdate
[color=blue]
> Even simpler stuff like:
> 'and strpos('abc','c')>0'[/color]
More PHP code that MySQL doesn't understand.
[color=blue]
> '0=0', is an acceptable condition, while 'true' is not.[/color]
0=0 evalutes to 1 (which we humans interpret as true).
MySQL doesn't know what 'true' means. PHP does because it is defined as part
of the language.
[color=blue]
> For the first query, $result does not return true, but 'Resource id #3'.[/color]
For the first query (which is all valid MySQL), you get back a resource
which you then use to retrieve the returned data using something like
mysql_fetch_object or one of a half-dozen other commands.
[color=blue]
> I have just started with php. What am I doing wrong?[/color]
Feeding PHP to the MySQL interpreter.
It would probably be worth your while to put your queries through a
command-line MySQL session to make sure that they're valid. That way you
know that your queries are good and any problems that remain are a problem
with your PHP code.
Steve
--
Steven C. Gallafent - The Computer Guy, Inc.
steve@compguy.com -
http://www.compguy.com/