Stumping Sql query...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter H. Coffin

    #16
    Re: Stumping Sql query...

    On Wed, 23 Apr 2008 22:20:52 +0200, Rik Wasmus wrote:
    On Wed, 23 Apr 2008 22:04:54 +0200, Guillaume Dargaud
    ><USE_MY_WEB_FO RM@gdargaud.net wrote:
    >
    >> $query="SELECT * FROM ImageList WHERE Name='$value[0]'";
    >> $result=mysql_q uery($query, $DB) or die(mysql_error ());
    >> if ($result) {
    >> $InContext=mysq l_fetch_assoc($ result);
    >> echo $query;
    >>
    >The query gets printed here and it's (for instance):
    >SELECT * FROM ImageList WHERE Name='MaceTrave rse'
    >which when fed straight into PhpMyAdmin returns:
    >Showing rows 0 - 0 (1 total, Query took 0.0004 sec)
    >MaceTraverse Climbing/Arizona/MaceTraverse.jp g Arizona
    >>
    >For reference the table is defined as
    >CREATE TABLE ImageList (
    > Name VARCHAR(100) NOT NULL,
    > Path VARCHAR(255) NOT NULL,
    > Source TEXT,
    >PRIMARY KEY (Name))
    >>
    >I just tried again after resetting Apache, and still no go.
    >>
    >If I add the following code to print everything:
    >>
    >$query="SELE CT * FROM ImageList";
    >echo $query."|<BR>";
    >$result=mysql_ query($query) or die(mysql_error ());
    >while ($InContext=mys ql_fetch_assoc( $result)) { print_r($InCont ext); echo
    >"<BR>"; }
    >mysql_free_res ult($result);
    >>
    >Then among the output I DO get a line containing:
    >Array ( [Name] =MaceTraverse [Path] =>
    >Climbing/Arizona/MaceTraverse.jp g
    >[Source] =Arizona )
    >
    Which is NOT the formatting print_r will deliver if you view it in the
    source. It will have newlines.
    It'll looks like that if the output is being viewed in a browser. The
    whole "<BR>" thing is a bit of a hint that this is the case.
    Just, humor me, what happens if you do a $value[0] = trim($value[0]);
    before making the $query string? And if that still doesn't work, examine
    the _source_ of a possibly html browser you're using to check the query,
    and maybe check in a hex editor what the ascii values are.

    --
    Either way, it'll remind the clued that there's only one letter
    difference between 'turkey' and 'turnkey'.
    -- Mike Andrews

    Comment

    • sheldonlg

      #17
      Re: Stumping Sql query...

      Guillaume Dargaud wrote:
      > $query="SELECT * FROM ImageList WHERE Name='$value[0]'";
      > $result=mysql_q uery($query, $DB) or die(mysql_error ());
      > if ($result) {
      > $InContext=mysq l_fetch_assoc($ result);
      > echo $query;
      >
      The query gets printed here and it's (for instance):
      SELECT * FROM ImageList WHERE Name='MaceTrave rse'
      which when fed straight into PhpMyAdmin returns:
      Showing rows 0 - 0 (1 total, Query took 0.0004 sec)
      MaceTraverse Climbing/Arizona/MaceTraverse.jp g Arizona
      >
      For reference the table is defined as
      CREATE TABLE ImageList (
      Name VARCHAR(100) NOT NULL,
      Path VARCHAR(255) NOT NULL,
      Source TEXT,
      PRIMARY KEY (Name))
      >
      I just tried again after resetting Apache, and still no go.
      >
      If I add the following code to print everything:
      >
      $query="SELECT * FROM ImageList";
      echo $query."|<BR>";
      $result=mysql_q uery($query) or die(mysql_error ());
      while ($InContext=mys ql_fetch_assoc( $result)) { print_r($InCont ext); echo
      "<BR>"; }
      mysql_free_resu lt($result);
      >
      Then among the output I DO get a line containing:
      Array ( [Name] =MaceTraverse [Path] =Climbing/Arizona/MaceTraverse.jp g
      [Source] =Arizona )
      >
      >
      > print_r($InCont ext);
      > }
      > mysql_free_resu lt($result);
      >>
      >No error but $InContext is always empty, although the $query as displayed
      >runs fine from PhpMyAdmin...
      >Something escapes me here.
      >--
      I told you this before as the first reply to your post.
      Try echoing $InContext['Path'] and $InContext['Source'] instead of
      $InContext and see what happens.

      $InContext is a ROW.

      Comment

      • Rik Wasmus

        #18
        Re: Stumping Sql query...

        On Thu, 24 Apr 2008 02:23:45 +0200, sheldonlg <sheldonlgwrote :
        >> print_r($InCont ext);
        I told you this before as the first reply to your post.
        Try echoing $InContext['Path'] and $InContext['Source'] instead of
        $InContext and see what happens.
        Please don't confuse the issue more because you don't know what print_r()
        is.
        --
        Rik Wasmus

        Comment

        • sheldonlg

          #19
          Re: Stumping Sql query...

          Rik Wasmus wrote:
          On Thu, 24 Apr 2008 02:23:45 +0200, sheldonlg <sheldonlgwrote :
          >>> print_r($InCont ext);
          >
          >I told you this before as the first reply to your post.
          >Try echoing $InContext['Path'] and $InContext['Source'] instead of
          >$InContext and see what happens.
          >
          Please don't confuse the issue more because you don't know what
          print_r() is.
          I missed that. His original had "echo".

          Comment

          • Rik Wasmus

            #20
            Re: Stumping Sql query...

            On Thu, 24 Apr 2008 13:09:50 +0200, sheldonlg <sheldonlgwrote :
            Rik Wasmus wrote:
            >On Thu, 24 Apr 2008 02:23:45 +0200, sheldonlg <sheldonlgwrote :
            >>>> print_r($InCont ext);
            >>
            >>I told you this before as the first reply to your post.
            >>Try echoing $InContext['Path'] and $InContext['Source'] instead of
            >>$InContext and see what happens.
            > Please don't confuse the issue more because you don't know what
            >print_r() is.
            >
            I missed that. His original had "echo".
            No, it didn't. His original echo'ed the query, and print_r'ed the result
            of mysql_fetch_ass oc:

            Message-ID: <aEsPj.3517$bf3 .3281@news1.pds .libertysurf.fr >:
            I must be tired tonight:

            $query="SELECT * FROM ImageList WHERE Name='$value[0]'";
            $result=mysql_q uery($query, $DB) or die(mysql_error ());
            if ($result) {
            $InContext=mysq l_fetch_assoc($ result);
            echo $query;
            print_r($InCont ext);
            }
            mysql_free_resu lt($result);
            --
            Rik Wasmus

            Comment

            • sheldonlg

              #21
              Re: Stumping Sql query...

              Rik Wasmus wrote:
              On Thu, 24 Apr 2008 13:09:50 +0200, sheldonlg <sheldonlgwrote :
              >
              >Rik Wasmus wrote:
              >>On Thu, 24 Apr 2008 02:23:45 +0200, sheldonlg <sheldonlgwrote :
              >>>>> print_r($InCont ext);
              >>>
              >>>I told you this before as the first reply to your post.
              >>>Try echoing $InContext['Path'] and $InContext['Source'] instead of
              >>>$InContext and see what happens.
              >> Please don't confuse the issue more because you don't know what
              >>print_r() is.
              >>
              >I missed that. His original had "echo".
              >
              No, it didn't. His original echo'ed the query, and print_r'ed the result
              of mysql_fetch_ass oc:
              >
              Message-ID: <aEsPj.3517$bf3 .3281@news1.pds .libertysurf.fr >:
              I must be tired tonight:
              >
              $query="SELECT * FROM ImageList WHERE Name='$value[0]'";
              $result=mysql_q uery($query, $DB) or die(mysql_error ());
              if ($result) {
              $InContext=mysq l_fetch_assoc($ result);
              echo $query;
              print_r($InCont ext);
              }
              mysql_free_resu lt($result);
              You are correct. I read it too quickly and remembered correctly what I
              had incorrectly read.

              Comment

              Working...