Very odd, page output going into sql statement

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

  1. #1

    Default Very odd, page output going into sql statement

    Hi,

    I have completely failed to come up with an explanation for this one. I have
    a sql statement near the top of my page. The SQL is well-formed. About one
    out of every 1000-2000 page views, I get this error in my logs:

    Syntax error or access violation: You have an error in your SQL syntax near
    '<html><head>'

    But the <html><head> part of my page is 100 lines below the sql statement, so
    I have no idea what it's doing in my sql statement. Somehow the page output is
    getting mixed up and finding its way into my sql statement.

    I repeat it's not a problem with the cfquery (at least not an obvious one),
    because it works almost every time. Some further details:

    Latest version of MX
    Mysql 3
    Linux
    Using cfqueryparam

    This happens in various queries on various pages, it seems random, however as
    far as I can tell it ONLY happens when I implement onRequest in my
    Application.cfc.

    Any ideas for a workaround or fix would be much appreciated. (Removing
    onRequest will be my last resort but it's legacy code so I'd rather not).


    ztom27 Guest

  2. Similar Questions and Discussions

    1. Output from different datasource in cfquery statement
      i've make 2 cfquery statements. one refers to datasource DatStudent and another one refers to datasource DatModul. in coldfusion admin, DatStudent...
    2. Repeating output with cfif statement
      I have a problem when multiple checkboxes are "turned on' when multiple values exist for a field in a database. For example: The following code...
    3. Getting page output
      Is there a tag or method I can use to grab the page output so that I can amend it prior to outputting.
    4. SQL statement working in SQL Server but not in .aspx.cs page
      I have written the following query with a subquery to add a counter to be added to a drop down list, which works in SQL Server, but when I transfer...
    5. Calling a html page from an asp page then returning to the next statement on the original asp page
      Hi! I have an ASP page that calls excel to create a report. This works fine. Now I need to call a html calendar page to filter what rows are...
  3. #2

    Default Re: Very odd, page output going into sql statement

    Does this query use any url, form, sesssion, etc variables? Unexpected values
    with those are often the source of intermittent problems.

    You could always wrap the query with cftry, and mail yourself some cfcatch
    details to help you figure it out.

    Dan Bracuk Guest

  4. #3

    Default Re: Very odd, page output going into sql statement

    Thanks for your response. It does use a url variable, but it's the same every
    time and it's validated to be an integer. I think this problem has something
    specifically to do with using onRequest because it never happened before. My
    error page saves all the cfcatch info -- here's an example of what I find in my
    exception.rootCause.sql in the error log:

    select items.name from items where itemID = (param 1) and deletedflag = 0
    <base href=" and paiduntil >= {ts '2006-04-08 12:22:17'}

    The code causing this looks like:
    <cfquery name="myquery" datasource="#request.dsn#">
    select items.name from items
    where
    itemID = <cfqueryparam cfSQLtype="CF_SQL_INTEGER" value="#itemid#">
    and deletedflag = 0
    and paiduntil >= #CreateODBCDateTime(now())#
    </cfquery>

    (#itemID# is the url parameter)

    Obviously the error is caused by the html code "base href" getting into my sql
    statement, the problem is I didn't put it there. The "base href" code is a
    hundred lines below the cfquery and is somehow sticking itself in the middle of
    my query.

    ztom27 Guest

  5. #4

    Default Re: Very odd, page output going into sql statement

    The plot thickens....

    It's not just sql statements. I just saw the "<html><head><base href=..."
    code show up at the top of a page that didn't have any sql or even any html
    tags. The only code in the file is:

    <cfset tracker = createObject("java","coldfusion.runtime.SessionTra cker")>
    <cfoutput><p>There are #tracker.getSessionCount()# active
    sessions</p></cfoutput>

    It happened a couple times, now I can't get it to repeat itself.

    ztom27 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