whats wrong with my sql?

Ask a Question related to Coldfusion Database Access, Design and Development.

  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. Similar Questions and Discussions

    1. hmm whats wrong ??
      I will try to explain from scratch: I use dreamweaver 8 I have installed the media server 2 in this directory: ...
    2. Anyone know whats wrong with this?
      hi all, I have a form with a text box and a checkbox. If the text box is empty the page retreives records based on this text and if the check box...
    3. im just about to give uo, whats wrong!!!
      yesterday i submitted a post about a pop up window, i got that fixed, dont no how, and ive gone to modify the pop up window, and did change nething,...
    4. [PHP] Whats wrong?
      Hey, Just touched it up a bit but its working: <title> <?php $senderemail = $_POST; print "Thank You, $senderemail"; ?> </title>
    5. Whats wrong with this code?
      Ray, This is the wrong syntax for the CASE expression. There are two valid kinds of CASE expression: CASE <expression> WHEN <value 1> THEN...
  3. #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

  4. #3

    Default Re: whats wrong with my sql?

    thanks
    loofa Guest

  5. #4

    Default Re: whats wrong with my sql?

    your a genious
    loofa Guest

Posting Permissions

  • You may not post new threads
  • You may 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