Results 1 to 5 of 5

SQL Query in coldfusion?

This is a discussion on SQL Query in coldfusion? within the Programming forums, part of the Web Designing & Development category; Ok, Basically in my .cfm page that handles the processing of a registration from I have the code to send ...

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Posts
    2

    Default SQL Query in coldfusion?

    Ok, Basically in my .cfm page that handles the processing of a registration from I have the code to send an email, But I need to pull the users email from the database which means I need to use a variable in the where clause to get it. Here is an example of what I mean

    <cfquery name="rs4" datasource="foliobox">

    SELECT EMAIL FROM SITE_USER
    WHERE userid = #newID#

    </cfquery>

    This however does not work. newID is the id that gets put in the database for the user when they sign up. Any ideas?
    After some more debugging the error that is coming up is not to do with newID. The error reads simply

    "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 ' SELECT EMAIL FR' at line 1"


    newID is coming from earlier in the page
    <cfset newID = (#rs.userid# + 1)>

    To debug newId I printed it out and it came out fine, one number higher than the last entry in the database

  2. #2
    Junior Member U Can't Handle The Truth's Avatar
    Join Date
    Feb 2008
    Posts
    1

    Default

    Where are you getting your #newID# variable from?

    Session
    QueryString
    Cookie
    Object

    Double check it!

    Test your query?
    Make Sure your dataconnection is not lost?

    Really need more infor then this to trouble shoot. Post the entire code.

  3. #3
    Senior Member akash's Avatar
    Join Date
    Oct 2008
    Location
    Heaven (Earth)
    Posts
    504

    Default Re: SQL Query in coldfusion?

    you can solve your problems form here..........
    http://livedocs.adobe.com/coldfusion..._CFML/sql3.htm

  4. #4
    Senior Member
    Join Date
    Mar 2011
    Posts
    194

    Default Re: SQL Query in coldfusion?

    You can follow the below link for a basic idea:
    http://www.garyrgilbert.com/tutorial...nner/sqlcf.cfm

  5. #5
    Senior Member
    Join Date
    Jul 2010
    Location
    India
    Posts
    146

    Default Re: SQL Query in coldfusion?

    Sql quesry in Cold fusion..
    <cfquery name="myquery" datasource="northwind">
    SELECT EmployeeID, LastName, FirstName, Title, TitleOfCourtesy, BirthDate, HireDate, Address
    FROM Employees
    </cfquery>