[thelist] SQL question

Tom Dell'Aringa pixelmech at yahoo.com
Wed Jan 22 15:51:01 CST 2003


--- Joshua Olson <joshua at waetech.com> wrote:
> > 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


> 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
> +.

I don't think so. I have never done that with any SQL statement in
PHP. In fact, the SQL that runs with only one parameter is the same
way and works fine:

// Works:
"SELECT	groom, bride, date, reguserID FROM reguser WHERE $byname LIKE
'$searchname'"

Rudy wrote:
------------
> OR  bridef LIKE '$searchname'");
> looks like an extra quote at the end there

Actually that's the ENDING quote of the whole sql statement (see
above).

Tom


=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the thelist mailing list