Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    sql string comparison problem

    Hello everybody.

    I have a little problem with a sql string comparison.

    I tried to use the following code to compare two different rows by a variable to
    get a result..

    The code works fine if the variable is a number like: 12345
    But if I use letters and numbers like: AZ1234 It doesn't work.

    Code:

    Code:
    $database->setQuery( 'SELECT task_id FROM #_projects WHERE title = '.$jid );
    What am I missing..??

    Hope you can help me..

    Best regards
    Allan.

  • #2
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    try
    PHP Code:
    $database->setQuery("SELECT task_id FROM #_projects WHERE title = '".$jid."'"); 

  • Users who have thanked poyzn for this post:

    allanb7 (11-08-2010)

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you so much poyzn..

    That did the trick!!!

    Best regards
    Allan

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,530
    Thanks
    45
    Thanked 259 Times in 256 Posts
    More specifically, always remember you have to quote strings, just like in any other language.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •