Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
error 1054 when executing mysql query
Old 01-08-2009, 09:27 AM error 1054 when executing mysql query
Average Talker

Posts: 27
Trades: 0
hi there,

im currently using some code from the website http://blog.ninedays.org/2008/03/04/...tions-library/ which writes functions for mysql queries. However I am having problems with a function in that a sql query has problems with the WHERE statement where i use a string rather than a number.

I have omitted a lot of code from this but this is function statement within the class called Query :

PHP Code:
        function Query($query,$sql) {
            
$this->action mysql_query($query,$sql);
            
$this->connect $sql;
        } 
and this is where I execute that in the page (again some code omitted) :

PHP Code:
    $selectQuery 'SELECT * FROM `admin` WHERE `admin_password` = `freddy123`';

    
$result = new Query($selectQuery,$sql); 
when executed i get the error "Error #1054: Unknown column 'gav' in 'where clause'" but if I chance the query to a number instead of a string so it reads :

PHP Code:
    $selectQuery 'SELECT * FROM `admin` WHERE `admin_password` = 123'
then it executes fine without problems. However, I want to be able to use a string in my 'where' clause as needed, not a number!

Any suggestions why this is working with a number and not any other value such as a string?

Thanks
gavrd1 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-08-2009, 09:51 AM Re: error 1054 when executing mysql query
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
I don't see any reason for this error with what you gave us.
I've downloaded the class from the site, and looked at it, but a
PHP Code:
new Query() 
goes directly in a mysql_query(), no escaping nor replacement is done...
So, logically, it should be a problem of your query.
Or maybe the mysql table could be damaged, I don't know...
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 01-08-2009 at 09:56 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 01-08-2009, 10:44 AM Re: error 1054 when executing mysql query
Average Talker

Posts: 27
Trades: 0
i did think that too about a problem with the tables as i can't see a problem with the query either.

i shall try looking into the table problem and even maybe try it on another database too to see what that results in.

thanks
gavrd1 is offline
Reply With Quote
View Public Profile
 
Old 01-09-2009, 10:16 AM Re: error 1054 when executing mysql query
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
strings HAVE to be enclosed in single quotes.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-12-2009, 02:47 PM Re: error 1054 when executing mysql query
Average Talker

Posts: 27
Trades: 0
have just changed it to single quotes and it now works fine.

many thanks to every one for the help
gavrd1 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to error 1054 when executing mysql query
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.65180 seconds with 12 queries