TechSpot

sql query error on phpmyadmin

By zfarooq
Nov 14, 2005
Topic Status:
Not open for further replies.
  1. Hi,

    I am trying to run the following query in phpmyadmin.

    SELECT * from tblregistration WHERE password = SHA1('a')

    The exact same query runs without any issues in the mysql console (with the semi colon, ofcourse)

    The error message is
    "MySQL said: Documentation #1305 - FUNCTION test.sha1 does not exist"

    Any suggestions/ideas?

    Versions of apps running
    phpMyAdmin 2.6.4-pl3
    MySQL 5.0.15
    PHP 5.0.5

    Zeeshan Farooq
    http://www.SilentDragons.com
    [SD]www.dal.ca
  2. RealBlackStuff

    RealBlackStuff TS Rookie Posts: 8,165

    Is that ('a') part of the password? then make it password = "SHA1('a')"
  3. zfarooq

    zfarooq TS Rookie Topic Starter

    Tried the suggestions. sorry did not work

    Hi,

    Thanks for the reply. I tried what you have suggested but unfortunately the sql excuted but did not give the desired result back.

    If I do the same sql in mysql console it works just fine

    mySql console

    mysql> select * from tblregistration where password = SHA1('a');
    +-------------+------------+-----------+------------------------------------------+
    | email | first_name | last_name | password |
    +-------------+------------+-----------+------------------------------------------+
    | abc@abc.com | z | f | 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 |
    +-------------+------------+-----------+------------------------------------------+
    1 row in set (0.00 sec)
  4. gary_hendricks

    gary_hendricks TS Rookie Posts: 138

    Definitely the 'SHA1('a')' portion of the SQL statement is giving you problems.

    Have you tried an escape character, like

    select * from tblregistration where password = SHA1(''a'');
  5. RealBlackStuff

    RealBlackStuff TS Rookie Posts: 8,165

    Alternatively, get a more 'common' password. I've never seen anything as crazy as that!
  6. zfarooq

    zfarooq TS Rookie Topic Starter

    Tried Gary's suggestion as well

    Hi,

    Tried your sql statement and got the error
    MySQL said: Documentation
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' ) LIMIT 0, 30' at line 1

    if i try

    SELECT * from tblregistration WHERE password = sha1('a') in phpmyadmin i get the following error

    #1305 - FUNCTION test.sha1 does not exist

    Somehow PHP is thinking that the function SHA1 is a function of the "test" database.
    ========================
    RealBlaclStuff

    if you mean i should choose a "simple" password *smile* then I think you might have misunderstood me. what you see in the password field is the SHA1 of the letter "a" SHA1 hashes "a" into a 40 HEX digit string and returns that value.

    I am still hopeful someone will come up with a solution and thanks to everyone who is trying to help I really appreciate it.
  7. Nodsu

    Nodsu TS Rookie Posts: 9,431

    The current phpMyAdmin doesn't support the SHA1 MySQL fuction. The current CVS version has it though. You might want to upgrade - there's lots of other candy in there too.
  8. zfarooq

    zfarooq TS Rookie Topic Starter

    Thanks a lot Nodsu

    Hi Nodsu,

    Thanks for the info. much appreciated.

    So that in the future I don't repeat the same mistake how did you find out that the current version does not support SHA1. Is there any documentation? What part of the documentation would this be in?

    Thanks again to everyone who helped.
  9. Nodsu

    Nodsu TS Rookie Posts: 9,431

    I went to the phpMyAmin site and tried a query with SHA1() in the stable version demo getting the same error as you did. Then I did the same in the CVS demo and it worked. Then I looked at the phpMyAdmin changelogs and saw that SQL functions are features that are implemented one by one in phpMyAdmin and need to be specifically supported.
  10. RealBlackStuff

    RealBlackStuff TS Rookie Posts: 8,165

Topic Status:
Not open for further replies.


Add New Comment

TechSpot Members
Login or sign up for free,
it takes about 30 seconds.
You may also...


Get complete access to the TechSpot community. Join thousands of technology enthusiasts that contribute and share knowledge in our forum. Get a private inbox, upload your own photo gallery and more.