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

  1. #1

    Default query error

    I have a query that I expect to return 3 or 4 entries -- but I seem to be
    getting only the most recent entry, repeated 4 times. What am I doing wrong
    here?

    $query="SELECT artistID,email,city,state,country from artists WHERE
    email='$email'";
    $result=mysql_query($query) or die(mysql_error("Could not execute
    query."));
    if (mysql_num_rows($result) > 0){
    $alreadylisted = "1";
    echo "<CENTER>$email is already in our database. Are you listed
    below?</CENTER><BR>";
    while($row = mysql_fetch_array($result)) {
    $artistID = $row['artistID'];
    $email = $row['email'];
    $city = $row['city'];
    $state = $row['state'];
    $country = $row['country'];
    echo "<CENTER><HR><FONT size=\"2\" face=\"Arial, Helvetica,
    sans-serif\">
    <A HREF=\"javascript:;\"
    onClick=\"openProfile('artist.php?artistID=".$arti stID.

    "','Artist','resizable=yes,width=600,height=300')\ ">".$firstname."
    ".$lastname."</A><BR>"
    .$city.", ".$state." ".$country."</FONT><BR></CENTER>";
    }
    echo "<HR><CENTER>If you are already listed above,
    congratulations!<BR>
    If needed, you may edit your listing using the link at
    left.</CENTER>";
    mysql_free_result($result);
    }


    Thanx,
    Wm



    Wm Guest

  2. Similar Questions and Discussions

    1. [microsoft][odbc microsoft access driver] syntax error (missing operator) in query expression error
      I have a query I want to run using DBQwiksite siftware, which produces the syntax error (missing operator) in query expression error when...
    2. Query of Query Error
      This is the error I get - Query Of Queries syntax error. Encountered ". Query Of Queries runtime error. The Cold Fusion server is running MX...
    3. SQL Query error
      Hello, I have a simple query that i'm passing over to an Excel output page using a ValueList that contains categoryID's, when I pass these ID's...
    4. Another Query of Query cast error
      Just in case somebody else is getting this error I thought I'd leave this here. I have a shopping cart that is stored in a session variable. When at...
    5. Error Query
      Error Executing Database Query. Syntax error (missing operator) in query expression 'StatusNum = 10'. The Error Occurred in...
  3. #2

    Default Re: query error

    try echoing your query to screen so you can read exactly what is being sent
    to the database beforehand.

    --

    Warren Butt
    -- Custom web design, cheap like cheese


    "Wm" <LAshooter@hotmail.com> wrote in message
    news:1haYa.1802083$ZC.268155@news.easynews.com...
    > I have a query that I expect to return 3 or 4 entries -- but I seem to be
    > getting only the most recent entry, repeated 4 times. What am I doing
    wrong
    > here?
    >
    > $query="SELECT artistID,email,city,state,country from artists WHERE
    > email='$email'";
    > $result=mysql_query($query) or die(mysql_error("Could not execute
    > query."));
    > if (mysql_num_rows($result) > 0){
    > $alreadylisted = "1";
    > echo "<CENTER>$email is already in our database. Are you listed
    > below?</CENTER><BR>";
    > while($row = mysql_fetch_array($result)) {
    > $artistID = $row['artistID'];
    > $email = $row['email'];
    > $city = $row['city'];
    > $state = $row['state'];
    > $country = $row['country'];
    > echo "<CENTER><HR><FONT size=\"2\" face=\"Arial, Helvetica,
    > sans-serif\">
    > <A HREF=\"javascript:;\"
    > onClick=\"openProfile('artist.php?artistID=".$arti stID.
    >
    > "','Artist','resizable=yes,width=600,height=300')\ ">".$firstname."
    > ".$lastname."</A><BR>"
    > .$city.", ".$state." ".$country."</FONT><BR></CENTER>";
    > }
    > echo "<HR><CENTER>If you are already listed above,
    > congratulations!<BR>
    > If needed, you may edit your listing using the link at
    > left.</CENTER>";
    > mysql_free_result($result);
    > }
    >
    >
    > Thanx,
    > Wm
    >
    >
    >

    DjDrakk Guest

  4. #3

    Default Re: query error

    "DjDrakk" <DjDrakk@drakkradio.servemp3.com> wrote in message
    news:vj2dmnopl9h08d@corp.supernews.com...
    > try echoing your query to screen so you can read exactly what is being
    sent
    > to the database beforehand.
    >
    > Warren Butt
    > -- Custom web design, cheap like cheese
    >
    echo "Query result = ".$result;

    yields this output:

    ArrayQuery result = Resource id #21

    I'm not sure where the word "Array" is coming from, nor what the "Resource
    id #21" is.....????

    Wm


    >
    > "Wm" <LAshooter@hotmail.com> wrote in message
    > news:1haYa.1802083$ZC.268155@news.easynews.com...
    > > I have a query that I expect to return 3 or 4 entries -- but I seem to
    be
    > > getting only the most recent entry, repeated 4 times. What am I doing
    > wrong
    > > here?
    > >
    > > $query="SELECT artistID,email,city,state,country from artists WHERE
    > > email='$email'";
    > > $result=mysql_query($query) or die(mysql_error("Could not execute
    > > query."));
    > > if (mysql_num_rows($result) > 0){
    > > $alreadylisted = "1";
    > > echo "<CENTER>$email is already in our database. Are you listed
    > > below?</CENTER><BR>";
    > > while($row = mysql_fetch_array($result)) {
    > > $artistID = $row['artistID'];
    > > $email = $row['email'];
    > > $city = $row['city'];
    > > $state = $row['state'];
    > > $country = $row['country'];
    > > echo "<CENTER><HR><FONT size=\"2\" face=\"Arial, Helvetica,
    > > sans-serif\">
    > > <A HREF=\"javascript:;\"
    > > onClick=\"openProfile('artist.php?artistID=".$arti stID.
    > >
    > > "','Artist','resizable=yes,width=600,height=300')\ ">".$firstname."
    > > ".$lastname."</A><BR>"
    > > .$city.", ".$state." ".$country."</FONT><BR></CENTER>";
    > > }
    > > echo "<HR><CENTER>If you are already listed above,
    > > congratulations!<BR>
    > > If needed, you may edit your listing using the link at
    > > left.</CENTER>";
    > > mysql_free_result($result);
    > > }
    > >
    > >
    > > Thanx,
    > > Wm
    > >
    > >
    > >
    >
    >

    Wm Guest

  5. #4

    Default Re: query error

    "Trent Stith" <trents@airmail.net> wrote in message
    news:bgribl$d9c@library2.airnews.net...
    > You need to echo the query itself, not the result of the query.
    >
    > echo "<pre>";
    > echo $query;
    >
    > that will return what your query is actually doing it may shed some light.
    >
    I pasted the lines above in after the query and got this result output to
    the browser:

    "Array
    [email]address@hotmail.com[/email] is already in our database. Are you listed below?"

    I'm still not sure why I'm getting the word "Array" output, nor why I don't
    see the query that I'm trying to verify. And I'm still getting the same info
    output 4 times rather than 4 separate listings, but I'm sure that's a
    different problem... <groan>

    Thanx,
    Wm


    ************************************************** ********
    ORIGINAL MESSAGE(S):
    ************************************************** ********
    > "Wm" <LAshooter@hotmail.com> wrote in message
    > news:oLaYa.1378547$Ho4.9675373@news.easynews.com.. .
    > > "DjDrakk" <DjDrakk@drakkradio.servemp3.com> wrote in message
    > > news:vj2dmnopl9h08d@corp.supernews.com...
    > > > try echoing your query to screen so you can read exactly what is being
    > > sent
    > > > to the database beforehand.
    > > >
    > > > Warren Butt
    > > > -- Custom web design, cheap like cheese
    > > >
    > >
    > > echo "Query result = ".$result;
    > >
    > > yields this output:
    > >
    > > ArrayQuery result = Resource id #21
    > >
    > > I'm not sure where the word "Array" is coming from, nor what the
    "Resource
    > > id #21" is.....????
    > >
    > > Wm
    > >
    > >
    > >
    > > >
    > > > "Wm" <LAshooter@hotmail.com> wrote in message
    > > > news:1haYa.1802083$ZC.268155@news.easynews.com...
    > > > > I have a query that I expect to return 3 or 4 entries -- but I seem
    to
    > > be
    > > > > getting only the most recent entry, repeated 4 times. What am I
    doing
    > > > wrong
    > > > > here?
    > > > >
    > > > > $query="SELECT artistID,email,city,state,country from artists
    WHERE
    > > > > email='$email'";
    > > > > $result=mysql_query($query) or die(mysql_error("Could not execute
    > > > > query."));
    > > > > if (mysql_num_rows($result) > 0){
    > > > > $alreadylisted = "1";
    > > > > echo "<CENTER>$email is already in our database. Are you
    listed
    > > > > below?</CENTER><BR>";
    > > > > while($row = mysql_fetch_array($result)) {
    > > > > $artistID = $row['artistID'];
    > > > > $email = $row['email'];
    > > > > $city = $row['city'];
    > > > > $state = $row['state'];
    > > > > $country = $row['country'];
    > > > > echo "<CENTER><HR><FONT size=\"2\" face=\"Arial,
    Helvetica,
    > > > > sans-serif\">
    > > > > <A HREF=\"javascript:;\"
    > > > > onClick=\"openProfile('artist.php?artistID=".$arti stID.
    > > > >
    > > > > "','Artist','resizable=yes,width=600,height=300')\ ">".$firstname."
    > > > > ".$lastname."</A><BR>"
    > > > > .$city.", ".$state." ".$country."</FONT><BR></CENTER>";
    > > > > }
    > > > > echo "<HR><CENTER>If you are already listed above,
    > > > > congratulations!<BR>
    > > > > If needed, you may edit your listing using the link at
    > > > > left.</CENTER>";
    > > > > mysql_free_result($result);
    > > > > }
    > > > >
    > > > >
    > > > > Thanx,
    > > > > Wm
    > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Wm Guest

  6. #5

    Default Re: query error

    Ok insert the echo "$query" line in the following places where indicated
    with 'echo', that's how you should isolate the problem to one line of code:


    "Wm" <LAshooter@hotmail.com> wrote in message
    news:1haYa.1802083$ZC.268155@news.easynews.com...
    > I have a query that I expect to return 3 or 4 entries -- but I seem to be
    > getting only the most recent entry, repeated 4 times. What am I doing
    wrong
    > here?
    >
    echo
    > $query="SELECT artistID,email,city,state,country from artists WHERE
    > email='$email'";
    echo
    > $result=mysql_query($query) or die(mysql_error("Could not execute
    > query."));
    echo
    > if (mysql_num_rows($result) > 0){
    > $alreadylisted = "1";
    > echo "<CENTER>$email is already in our database. Are you listed
    > below?</CENTER><BR>";
    > while($row = mysql_fetch_array($result)) {
    > $artistID = $row['artistID'];
    > $email = $row['email'];
    > $city = $row['city'];
    > $state = $row['state'];
    > $country = $row['country'];
    > echo "<CENTER><HR><FONT size=\"2\" face=\"Arial, Helvetica,
    > sans-serif\">
    > <A HREF=\"javascript:;\"
    > onClick=\"openProfile('artist.php?artistID=".$arti stID.
    >
    > "','Artist','resizable=yes,width=600,height=300')\ ">".$firstname."
    > ".$lastname."</A><BR>"
    > .$city.", ".$state." ".$country."</FONT><BR></CENTER>";
    > }
    > echo "<HR><CENTER>If you are already listed above,
    > congratulations!<BR>
    > If needed, you may edit your listing using the link at
    > left.</CENTER>";
    > mysql_free_result($result);
    > }
    >
    >
    > Thanx,
    > Wm
    >
    >
    >

    James Jiao Guest

  7. #6

    Default query error

    I get an error when trying to insert a new row:
    query error- 5 - Duplicate entry '80.200.213.102 Mozilla/4.0 (compatible;
    MSIE 6.0; Windows NT 5.1; Avant Browser [avantbrowser.com]; MyIE2; .NET CLR
    1.0.' for key 1

    The table consist of timestamp, file, level, ip, naam , ID


    Where ID is an autoincrement, unique key.
    Someone has an idea what going wrong?

    kind regards
    Stijn



    Stijn Goris Guest

  8. #7

    Default Re: query error

    Stijn Goris wrote:
    > I get an error when trying to insert a new row:
    > query error- 5 - Duplicate entry '80.200.213.102 Mozilla/4.0 (compatible;
    > MSIE 6.0; Windows NT 5.1; Avant Browser [avantbrowser.com]; MyIE2; .NET
    > CLR 1.0.' for key 1
    >
    > The table consist of timestamp, file, level, ip, naam , ID
    >
    >
    > Where ID is an autoincrement, unique key.
    > Someone has an idea what going wrong?
    Yes, you made the column where this string is inserted in UNIQUE too, and it
    already contained that value.
    Check your tabledefinition, constraints and such.
    >
    > kind regards
    > Stijn

    Regards,
    Erwin
    Erwin Moller Guest

  9. #8

    Default Query Error

    I am having a problem with updating my database. I cant narrow down the
    problem. I'll take any advice thanks.

    I am sorting the data then updating it with the new order made by the sorting.

    Code:
    <cfquery name="get_menu" datasource="#db#">
    SELECT *
    FROM menu
    ORDER BY LVL1, LVL;
    </cfquery>


    <cfoutput query="get_menu" maxrows="1">
    <cfquery name="updt_menu1" datasource="#db#">
    UPDATE Menu
    SET Order = '#recordcount#'
    WHERE mid = #mid#;
    </cfquery>
    </cfoutput>

    Error:
    [MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access
    Driver] Syntax error in WHERE clause.

    The Error Occurred in D:\CFusionMX\wwwroot\Hambleton\menu.cfm: line 13
    Called from D:\CFusionMX\wwwroot\Hambleton\index.cfm: line 9
    Called from D:\CFusionMX\wwwroot\Hambleton\menu.cfm: line 13
    Called from D:\CFusionMX\wwwroot\Hambleton\index.cfm: line 9

    11 : SET LVL = '#recordcount#'
    12 : WHERE order = 3;
    13 : </cfquery>
    14 : #LVL# #mid# #value# #LVL1# #LVL2#<br>
    15 : </cfoutput>





    Jahcoldf Guest

  10. #9

    Default Re: Query Error

    Because you have maxrows in the cfoutput query, it will only ever do the one
    record.

    I am also assuming that the "Order" column is numeric and thus does not have
    single quotes

    <cfoutput query="get_menu">
    <cfquery name="updt_menu1" datasource="#db#">
    UPDATE Menu
    SET Order = #recordcount#
    WHERE mid = #mid#;
    </cfquery>
    </cfoutput>

    Ken

    The ScareCrow Guest

  11. #10

    Default Re: Query Error

    I fixed the where clause and i am still getting some trouble.

    I changed the code to this:
    <cfquery name="get_menu" datasource="#db#">
    SELECT *
    FROM menu
    ORDER BY LVL1, LVL;
    </cfquery>
    <cfinclude template="menu-order.cfm">

    <cfoutput query="get_menu" maxrows="1">
    <cfquery name="updt_menu1" datasource="#db#">
    UPDATE Menu
    SET Order = #recordcount#
    WHERE mid = #mid#
    </cfquery>
    #LVL# #mid# #value# #LVL1# #LVL2#<br>
    </cfoutput>

    I get this error:
    Error Executing Database Query.
    [MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access
    Driver] Syntax error in UPDATE statement.

    The Error Occurred in D:\CFusionMX\wwwroot\Hambleton\menu.cfm: line 13

    11 : SET Order = #recordcount#
    12 : WHERE mid = #mid#
    13 : </cfquery>
    14 : #LVL# #mid# #value# #LVL1# #LVL2#<br>
    15 : </cfoutput>




    --------------------------------------------------------------------------------

    SQL UPDATE Menu SET Order = 7 WHERE mid = 1001
    DATASOURCE hambleton
    VENDORERRORCODE -3503
    SQLSTATE 42000





    Jahcoldf Guest

  12. #11

    Default Re: Query Error

    Your query now appears to be correct. I would assume that you may have a
    problem with your table and column names, they may be reserved words, so

    <cfoutput query="get_menu" maxrows="1">
    <cfquery name="updt_menu1" datasource="#db#">
    UPDATE [Menu]
    SET [Order] = #recordcount#
    WHERE [mid] = #mid#
    </cfquery>
    #LVL# #mid# #value# #LVL1# #LVL2#<br>
    </cfoutput>

    The above should resolve this.

    Ken


    The ScareCrow Guest

  13. #12

    Default Re: Query Error

    Both mid and order are reserved words in SQL. the problem may be there.
    kyle969 Guest

  14. #13

    Default query error

    hi how can i fix this?

    Errore

    query SQL :

    CREATE TABLE `tags` (
    `tag_link_id` int(11) NOT NULL default '0',
    `tag_lang` varchar(4) NOT NULL default 'en',
    `tag_date` timestamp NOT NULL,
    `tag_words` varchar(64) NOT NULL default '',
    UNIQUE KEY `tag_link_id` (`tag_link_id`,`tag_lang`,`tag_words`),
    KEY `tag_lang` (`tag_lang`,`tag_date`)
    ) ENGINE=MyISAM

    Messaggio di MySQL:


    You have an error in your SQL syntax near 'ENGINE=MyISAM' at line 8


    maux Guest

  15. #14

    Default Re: query error

    maux wrote:
    > hi how can i fix this?
    >
    > Errore
    >
    > query SQL :
    >
    > CREATE TABLE `tags` (
    > `tag_link_id` int(11) NOT NULL default '0',
    > `tag_lang` varchar(4) NOT NULL default 'en',
    > `tag_date` timestamp NOT NULL,
    > `tag_words` varchar(64) NOT NULL default '',
    > UNIQUE KEY `tag_link_id` (`tag_link_id`,`tag_lang`,`tag_words`),
    > KEY `tag_lang` (`tag_lang`,`tag_date`)
    > ) ENGINE=MyISAM
    >
    > Messaggio di MySQL:
    >
    >
    > You have an error in your SQL syntax near 'ENGINE=MyISAM' at line 8

    Works for me.


    mysql> CREATE TABLE `tags` ( `tag_link_id` int(11) NOT NULL default '0',
    `tag_lang` varchar(4) NOT NULL default 'en', `tag_date` timestamp NOT
    NULL, `tag_words` varchar(64) NOT NULL default '', UNIQUE KEY
    `tag_link_id` (`tag_link_id`,`tag_lang`,`tag_words`), KEY `tag_lang`
    (`tag_lang`,`tag_date`) ) ENGINE=MyISAM;
    Query OK, 0 rows affected (0.01 sec)

    mysql>


    Perhaps you are using a pre-myisam version (<= 3.22 I think)?


    --
    Brian Wakem
    Email: [url]http://homepage.ntlworld.com/b.wakem/myemail.png[/url]
    Brian Wakem Guest

  16. #15

    Default Re: query error

    maux wrote:
    > hi how can i fix this?
    >
    > Errore
    >
    > query SQL :
    >
    > CREATE TABLE `tags` (
    > `tag_link_id` int(11) NOT NULL default '0',
    > `tag_lang` varchar(4) NOT NULL default 'en',
    > `tag_date` timestamp NOT NULL,
    > `tag_words` varchar(64) NOT NULL default '',
    > UNIQUE KEY `tag_link_id` (`tag_link_id`,`tag_lang`,`tag_words`),
    > KEY `tag_lang` (`tag_lang`,`tag_date`)
    > ) ENGINE=MyISAM
    >
    > Messaggio di MySQL:
    >
    >
    > You have an error in your SQL syntax near 'ENGINE=MyISAM' at line 8
    Use a MySQL version that supports ENGINE.
    All versions before 4.1 don't support ENGINE.

    Greetins
    Kai
    Kai Ruhnau Guest

  17. #16

    Default Re: query error

    Brian Wakem scriveva il 21/02/2006 :
    > maux wrote:
    >
    >> hi how can i fix this?
    >>
    >> Errore
    >>
    >> query SQL :
    >>
    >> CREATE TABLE `tags` (
    >> `tag_link_id` int(11) NOT NULL default '0',
    >> `tag_lang` varchar(4) NOT NULL default 'en',
    >> `tag_date` timestamp NOT NULL,
    >> `tag_words` varchar(64) NOT NULL default '',
    >> UNIQUE KEY `tag_link_id` (`tag_link_id`,`tag_lang`,`tag_words`),
    >> KEY `tag_lang` (`tag_lang`,`tag_date`)
    >> ) ENGINE=MyISAM
    >>
    >> Messaggio di MySQL:
    >>
    >>
    >> You have an error in your SQL syntax near 'ENGINE=MyISAM' at line 8
    >
    >
    > Works for me.
    >
    >
    > mysql> CREATE TABLE `tags` ( `tag_link_id` int(11) NOT NULL default '0',
    > `tag_lang` varchar(4) NOT NULL default 'en', `tag_date` timestamp NOT
    > NULL, `tag_words` varchar(64) NOT NULL default '', UNIQUE KEY
    > `tag_link_id` (`tag_link_id`,`tag_lang`,`tag_words`), KEY `tag_lang`
    > (`tag_lang`,`tag_date`) ) ENGINE=MyISAM;
    > Query OK, 0 rows affected (0.01 sec)
    >
    > mysql>
    >
    >
    > Perhaps you are using a pre-myisam version (<= 3.22 I think)?
    yes u have right! thanks


    maux Guest

  18. #17

    Default Re: query error

    Il 21/02/2006, Kai Ruhnau ha detto :
    > maux wrote:
    >> hi how can i fix this?
    >>
    >> Errore
    >>
    >> query SQL :
    >>
    >> CREATE TABLE `tags` (
    >> `tag_link_id` int(11) NOT NULL default '0',
    >> `tag_lang` varchar(4) NOT NULL default 'en',
    >> `tag_date` timestamp NOT NULL,
    >> `tag_words` varchar(64) NOT NULL default '',
    >> UNIQUE KEY `tag_link_id` (`tag_link_id`,`tag_lang`,`tag_words`),
    >> KEY `tag_lang` (`tag_lang`,`tag_date`)
    >> ) ENGINE=MyISAM
    >>
    >> Messaggio di MySQL:
    >>
    >>
    >> You have an error in your SQL syntax near 'ENGINE=MyISAM' at line 8
    >
    > Use a MySQL version that supports ENGINE.
    > All versions before 4.1 don't support ENGINE.
    >
    > Greetins
    > Kai
    ok thanks!


    maux 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