Select from table where field = string – PHP

  php

Q(Question):

How to select all lines containg a string (located in $pastmove) in the
moves column

I tried several ways, for example:

$requete="SELECT moves, opening_id FROM suitemove where moves like
‘%".$pastmove."%’";

but did not succeed;

Thqnks for your help

A(Answer):

> $requete="SELECT moves, opening_id FROM suitemove where moves like

‘%".$pastmove."%’";

try “ insted ”.

yours, dreamguard.

A(Answer):

what do you mean by "insted" ?

A(Answer):

I tried this

$requete="SELECT moves, opening_id FROM suitemove where moves like
‘%".$pastm."%’";

The whole table, i.e. all rows are selected, not only the ones with the
content of $pastm in moves column

A(Answer):

Michel wrote:

How to select all lines containg a string (located in $pastmove) in the
moves column

I tried several ways, for example:

$requete="SELECT moves, opening_id FROM suitemove where moves like
‘%".$pastmove."%’";

but did not succeed;

I can’t see anything at all wrong with this. If it is selecting _all_
records as your later post suggests, then check to see if there is a
value in $pastmove. If $pastmove is empty then:
…WHERE moves LIKE ‘%%’
will select everything.
Thqnks for your help


MeerKat

A(Answer):

On 24-Aug-2003, "Michel" <Mi**************@wanadoo.fr> wrote:

How to select all lines containg a string (located in $pastmove) in the
moves column

I tried several ways, for example:

$requete="SELECT moves, opening_id FROM suitemove where moves like
‘%".$pastmove."%’";

but did not succeed;

Your select statement looks correct.

Can you be more specific– how did it not succeed?

Did the query fail? What was the error message? (You are reporting the error
messages, right?)
If the query worked, did it return the wrong rows? too many rows, etc.

Are you sure your table definition is correct and the column names are
spelled correctly? Are you sure $pastmove contains a value?

Tom Thackrey
www.creative-light.com

A(Answer):

Michel wrote:

I tried this

$requete="SELECT moves, opening_id FROM suitemove where moves like
‘%".$pastm."%’";

$pastm or $pastmove?
The whole table, i.e. all rows are selected, not only the ones with the
content of $pastm in moves column


MeerKat

LEAVE A COMMENT