Professional Web Applications Themes

whats wrong with my sql? - Coldfusion Database Access

ok, is what i'm doing here is insert a few fields into a table, which works fine. then i'm trying to query the table using the same email address that i used to make the new row to get the quto number made in that row "userid" now its not giving my any errors but when i pass the variable "id" through the url its ending up with nothing being in it "id= " that must meen that nothing is being found in the query..... why? Thank you for taking a look, Tommy <cfif not isdefined("form.email")> <cflocation url="login.cfm"> </cfif> <cfinsert ...

  1. #1

    Default whats wrong with my sql?

    ok, is what i'm doing here is insert a few fields into a table, which works
    fine. then i'm trying to query the table using the same email address that i
    used to make the new row to get the quto number made in that row "userid"
    now its not giving my any errors but when i pass the variable "id" through the
    url its ending up with nothing being in it "id= "
    that must meen that nothing is being found in the query..... why?
    Thank you for taking a look,
    Tommy

    <cfif not isdefined("form.email")>
    <cflocation url="login.cfm">
    </cfif>
    <cfinsert datasource="c8k" tablename="useraccounts">
    <cfquery name="getid" datasource="c8k">

    select userid
    from useraccounts
    where '%#form.email#%' = email

    </cfquery>
    <cflocation url="setupcomplete.cfm?id=#getid.userid#">

    loofa Guest

  2. #2

    Default Re: whats wrong with my sql?

    Originally posted by: loofa
    select userid
    from useraccounts
    where '%#form.email#%' = email

    You shouldn't be using percent signs "%" here. In most databases the "%" sign
    is used as a wildcard to find partial matches on text fields. It is used in
    conjunction with the LIKE operator, not the equals "=" operator. For example,
    you might use a wildcard to find records in a table where the last name begins
    with the letters "MAL", like ....

    SELECT FirstName,LastName FROM myTable WHERE LastName LIKE 'MAL%'

    Since you want to retrieve the record where the email matches exactly, you
    should use the equals operator "=" (without the percent signs). Note:
    Typically, the comparison value is placed on the right hand side of the
    operator not the left.

    select userid
    from useraccounts
    where email = '#form.email#'

    Originally posted by: loofa
    ok, is what i'm doing here is insert a few fields into a table, which works
    fine. then i'm trying to query the table using the same email address that i
    used to make the new row to get the quto number made in that row "userid"
    now its not giving my any errors but when i pass the variable "id" through the
    url its ending up with nothing being in it "id= "
    that must meen that nothing is being found in the query


    You should probably add some validation/error handling to your page to ensure
    that A) the email address is not added more than once and B) an error message
    is displayed if the "getid" query returns no information.

    Good Luck




    mxstu Guest

  3. #3

    Default Re: whats wrong with my sql?

    thanks
    loofa Guest

  4. #4

    Default Re: whats wrong with my sql?

    your a genious
    loofa Guest

Similar Threads

  1. hmm whats wrong ??
    By mak999 in forum Macromedia Flash Flashcom
    Replies: 0
    Last Post: February 16th, 10:05 PM
  2. Anyone know whats wrong with this?
    By Mike M in forum ASP Database
    Replies: 5
    Last Post: February 17th, 11:56 PM
  3. [PHP] Whats wrong with my code?
    By Brad Pauly in forum PHP Development
    Replies: 9
    Last Post: September 20th, 10:42 PM
  4. [PHP] Whats wrong?
    By Ryan A in forum PHP Development
    Replies: 0
    Last Post: September 13th, 01:07 PM
  5. whats wrong with this querry
    By Sundial Services in forum PHP Development
    Replies: 1
    Last Post: August 31st, 12:55 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139