[thelist] SQL question

Joshua Olson joshua at waetech.com
Wed Jan 22 15:18:07 CST 2003


----- Original Message -----
From: "Tom Dell'Aringa" <pixelmech at yahoo.com>
Sent: Wednesday, January 22, 2003 4:10 PM


> Works like a charm. However, in my page where I have this: (this
> block is in an else clause where it runs if there is no field
> specified by the user [ie, groom, groomf etc])
>
> $result = @mysql_query(
> "SELECT
> groom, groomf, bridef, bride, date, reguserID
> FROM
> reguser
> WHERE
> groom LIKE '$searchname'
> OR groomf LIKE '$searchname'
> OR  bride LIKE '$searchname'
> OR  bridef LIKE '$searchname'");
>
> I get the following error:
>
> You have an error in your SQL syntax near 'LIKE 'george'' at line 6
>
> Which makes no sense. I copy that exact code, replace $searchname
> with george and it works..any ideas?

Tom,

The variables you've specified need to be concatenated with the SQL String.
For example:

... OR groomf LIKE '" + $searchname + "'"

(I'm not really sure with the PHP concatenation operator is, so I'm assuming
+.

-joshua




More information about the thelist mailing list