query error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wm

    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,coun try from artists WHERE
    email='$email'" ;
    $result=mysql_q uery($query) or die(mysql_error ("Could not execute
    query."));
    if (mysql_num_rows ($result) > 0){
    $alreadylisted = "1";
    echo "<CENTER>$e mail is already in our database. Are you listed
    below?</CENTER><BR>";
    while($row = mysql_fetch_arr ay($result)) {
    $artistID = $row['artistID'];
    $email = $row['email'];
    $city = $row['city'];
    $state = $row['state'];
    $country = $row['country'];
    echo "<CENTER><HR><F ONT size=\"2\" face=\"Arial, Helvetica,
    sans-serif\">
    <A HREF=\"javascri pt:;\"
    onClick=\"openP rofile('artist. php?artistID=". $artistID.

    "','Artist','re sizable=yes,wid th=600,height=3 00')\">".$first name."
    ".$lastname ."</A><BR>"
    .$city.", ".$state." ".$country. "</FONT><BR></CENTER>";
    }
    echo "<HR><CENTE R>If you are already listed above,
    congratulations !<BR>
    If needed, you may edit your listing using the link at
    left.</CENTER>";
    mysql_free_resu lt($result);
    }


    Thanx,
    Wm



  • DjDrakk

    #2
    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@hotm ail.com> wrote in message
    news:1haYa.1802 083$ZC.268155@n ews.easynews.co m...[color=blue]
    > 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[/color]
    wrong[color=blue]
    > here?
    >
    > $query="SELECT artistID,email, city,state,coun try from artists WHERE
    > email='$email'" ;
    > $result=mysql_q uery($query) or die(mysql_error ("Could not execute
    > query."));
    > if (mysql_num_rows ($result) > 0){
    > $alreadylisted = "1";
    > echo "<CENTER>$e mail is already in our database. Are you listed
    > below?</CENTER><BR>";
    > while($row = mysql_fetch_arr ay($result)) {
    > $artistID = $row['artistID'];
    > $email = $row['email'];
    > $city = $row['city'];
    > $state = $row['state'];
    > $country = $row['country'];
    > echo "<CENTER><HR><F ONT size=\"2\" face=\"Arial, Helvetica,
    > sans-serif\">
    > <A HREF=\"javascri pt:;\"
    > onClick=\"openP rofile('artist. php?artistID=". $artistID.
    >
    > "','Artist','re sizable=yes,wid th=600,height=3 00')\">".$first name."
    > ".$lastname ."</A><BR>"
    > .$city.", ".$state." ".$country. "</FONT><BR></CENTER>";
    > }
    > echo "<HR><CENTE R>If you are already listed above,
    > congratulations !<BR>
    > If needed, you may edit your listing using the link at
    > left.</CENTER>";
    > mysql_free_resu lt($result);
    > }
    >
    >
    > Thanx,
    > Wm
    >
    >
    >[/color]


    Comment

    • Wm

      #3
      Re: query error

      "DjDrakk" <DjDrakk@drakkr adio.servemp3.c om> wrote in message
      news:vj2dmnopl9 h08d@corp.super news.com...[color=blue]
      > try echoing your query to screen so you can read exactly what is being[/color]
      sent[color=blue]
      > to the database beforehand.
      >
      > Warren Butt
      > -- Custom web design, cheap like cheese
      >[/color]

      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


      [color=blue]
      >
      > "Wm" <LAshooter@hotm ail.com> wrote in message
      > news:1haYa.1802 083$ZC.268155@n ews.easynews.co m...[color=green]
      > > I have a query that I expect to return 3 or 4 entries -- but I seem to[/color][/color]
      be[color=blue][color=green]
      > > getting only the most recent entry, repeated 4 times. What am I doing[/color]
      > wrong[color=green]
      > > here?
      > >
      > > $query="SELECT artistID,email, city,state,coun try from artists WHERE
      > > email='$email'" ;
      > > $result=mysql_q uery($query) or die(mysql_error ("Could not execute
      > > query."));
      > > if (mysql_num_rows ($result) > 0){
      > > $alreadylisted = "1";
      > > echo "<CENTER>$e mail is already in our database. Are you listed
      > > below?</CENTER><BR>";
      > > while($row = mysql_fetch_arr ay($result)) {
      > > $artistID = $row['artistID'];
      > > $email = $row['email'];
      > > $city = $row['city'];
      > > $state = $row['state'];
      > > $country = $row['country'];
      > > echo "<CENTER><HR><F ONT size=\"2\" face=\"Arial, Helvetica,
      > > sans-serif\">
      > > <A HREF=\"javascri pt:;\"
      > > onClick=\"openP rofile('artist. php?artistID=". $artistID.
      > >
      > > "','Artist','re sizable=yes,wid th=600,height=3 00')\">".$first name."
      > > ".$lastname ."</A><BR>"
      > > .$city.", ".$state." ".$country. "</FONT><BR></CENTER>";
      > > }
      > > echo "<HR><CENTE R>If you are already listed above,
      > > congratulations !<BR>
      > > If needed, you may edit your listing using the link at
      > > left.</CENTER>";
      > > mysql_free_resu lt($result);
      > > }
      > >
      > >
      > > Thanx,
      > > Wm
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Wm

        #4
        Re: query error

        "Trent Stith" <trents@airmail .net> wrote in message
        news:bgribl$d9c @library2.airne ws.net...[color=blue]
        > 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.
        >[/color]

        I pasted the lines above in after the query and got this result output to
        the browser:

        "Array
        address@hotmail .com 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):
        *************** *************** *************** *************[color=blue]
        > "Wm" <LAshooter@hotm ail.com> wrote in message
        > news:oLaYa.1378 547$Ho4.9675373 @news.easynews. com...[color=green]
        > > "DjDrakk" <DjDrakk@drakkr adio.servemp3.c om> wrote in message
        > > news:vj2dmnopl9 h08d@corp.super news.com...[color=darkred]
        > > > try echoing your query to screen so you can read exactly what is being[/color]
        > > sent[color=darkred]
        > > > to the database beforehand.
        > > >
        > > > Warren Butt
        > > > -- Custom web design, cheap like cheese
        > > >[/color]
        > >
        > > 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[/color][/color]
        "Resource[color=blue][color=green]
        > > id #21" is.....????
        > >
        > > Wm
        > >
        > >
        > >[color=darkred]
        > > >
        > > > "Wm" <LAshooter@hotm ail.com> wrote in message
        > > > news:1haYa.1802 083$ZC.268155@n ews.easynews.co m...
        > > > > I have a query that I expect to return 3 or 4 entries -- but I seem[/color][/color][/color]
        to[color=blue][color=green]
        > > be[color=darkred]
        > > > > getting only the most recent entry, repeated 4 times. What am I[/color][/color][/color]
        doing[color=blue][color=green][color=darkred]
        > > > wrong
        > > > > here?
        > > > >
        > > > > $query="SELECT artistID,email, city,state,coun try from artists[/color][/color][/color]
        WHERE[color=blue][color=green][color=darkred]
        > > > > email='$email'" ;
        > > > > $result=mysql_q uery($query) or die(mysql_error ("Could not execute
        > > > > query."));
        > > > > if (mysql_num_rows ($result) > 0){
        > > > > $alreadylisted = "1";
        > > > > echo "<CENTER>$e mail is already in our database. Are you[/color][/color][/color]
        listed[color=blue][color=green][color=darkred]
        > > > > below?</CENTER><BR>";
        > > > > while($row = mysql_fetch_arr ay($result)) {
        > > > > $artistID = $row['artistID'];
        > > > > $email = $row['email'];
        > > > > $city = $row['city'];
        > > > > $state = $row['state'];
        > > > > $country = $row['country'];
        > > > > echo "<CENTER><HR><F ONT size=\"2\" face=\"Arial,[/color][/color][/color]
        Helvetica,[color=blue][color=green][color=darkred]
        > > > > sans-serif\">
        > > > > <A HREF=\"javascri pt:;\"
        > > > > onClick=\"openP rofile('artist. php?artistID=". $artistID.
        > > > >
        > > > > "','Artist','re sizable=yes,wid th=600,height=3 00')\">".$first name."
        > > > > ".$lastname ."</A><BR>"
        > > > > .$city.", ".$state." ".$country. "</FONT><BR></CENTER>";
        > > > > }
        > > > > echo "<HR><CENTE R>If you are already listed above,
        > > > > congratulations !<BR>
        > > > > If needed, you may edit your listing using the link at
        > > > > left.</CENTER>";
        > > > > mysql_free_resu lt($result);
        > > > > }
        > > > >
        > > > >
        > > > > Thanx,
        > > > > Wm
        > > > >
        > > > >
        > > > >
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • James Jiao

          #5
          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@hotm ail.com> wrote in message
          news:1haYa.1802 083$ZC.268155@n ews.easynews.co m...[color=blue]
          > 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[/color]
          wrong[color=blue]
          > here?
          >[/color]

          echo
          [color=blue]
          > $query="SELECT artistID,email, city,state,coun try from artists WHERE
          > email='$email'" ;[/color]

          echo
          [color=blue]
          > $result=mysql_q uery($query) or die(mysql_error ("Could not execute
          > query."));[/color]

          echo
          [color=blue]
          > if (mysql_num_rows ($result) > 0){
          > $alreadylisted = "1";
          > echo "<CENTER>$e mail is already in our database. Are you listed
          > below?</CENTER><BR>";
          > while($row = mysql_fetch_arr ay($result)) {
          > $artistID = $row['artistID'];
          > $email = $row['email'];
          > $city = $row['city'];
          > $state = $row['state'];
          > $country = $row['country'];
          > echo "<CENTER><HR><F ONT size=\"2\" face=\"Arial, Helvetica,
          > sans-serif\">
          > <A HREF=\"javascri pt:;\"
          > onClick=\"openP rofile('artist. php?artistID=". $artistID.
          >
          > "','Artist','re sizable=yes,wid th=600,height=3 00')\">".$first name."
          > ".$lastname ."</A><BR>"
          > .$city.", ".$state." ".$country. "</FONT><BR></CENTER>";
          > }
          > echo "<HR><CENTE R>If you are already listed above,
          > congratulations !<BR>
          > If needed, you may edit your listing using the link at
          > left.</CENTER>";
          > mysql_free_resu lt($result);
          > }
          >
          >
          > Thanx,
          > Wm
          >
          >
          >[/color]


          Comment

          Working...