error in my SQL query

Codes here !

Moderators: macek, egami, gesf

cho@
New php-forum User
New php-forum User
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

error in my SQL query

Postby cho@ » Tue Aug 06, 2002 9:12 am

:(



i wanna do this request on my table:

SELECT id from authuser where last like $last

the var $last exist and contain a value....
on phpmyadmin this request works
but in my php script i has this error....

Warning: Supplied argument is not a valid MySQL result resource

i knw that my var is a string and i wonder if its not my prob...cuz i knw that with a integer its ok no prob..i've done it and it wirks....

pls help me...

ps:php, apache and mysql are really good and seems to b soo powerfull i am learning everyday and its soo good.....

DoppyNL

Postby DoppyNL » Tue Aug 06, 2002 9:47 am

try placing " around you're string, like this:

Code: Select all

select id from authuser where last like "searchtext"


Greetz

cho@
New php-forum User
New php-forum User
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

Postby cho@ » Tue Aug 06, 2002 11:08 am

dvdbinternet wrote:try placing " around you're string, like this:

Code: Select all

select id from authuser where last like "searchtext"


Greetz


but i thought that the " were used when u have a define string....
but here its not..
the content of my string depend of the content of a texfield insite a form....
so i dont think dat i can use this trics...

thx for ur reply
tra

cho@
New php-forum User
New php-forum User
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

Postby cho@ » Tue Aug 06, 2002 11:27 am

:?........

i think i found the tric somewhere in this forum ......

thx guys.

tra

Jay

Postby Jay » Tue Aug 06, 2002 3:51 pm

cho@ wrote:but i thought that the " were used when u have a define string....
but here its not..
the content of my string depend of the content of a texfield insite a form....
so i dont think dat i can use this trics...

thx for ur reply
tra

Seems self-explanatory to me :D

You have to use quotes whenever you use a string. The only time you can get away without using them is just numbers (or reference to a table field).


Return to “mySQL & php coding”

Who is online

Users browsing this forum: Google [Bot] and 1 guest