...it only prints the letter "m"

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

    ...it only prints the letter "m"

    does anyone know why this code:

    if ($query= "SELECT * FROM ryanBlog WHERE entryNum=5"){
    print "<p class=../style1>cool</p>";
    }else{
    print "<p class=../style1>not cool</p>";
    }

    if($run= mysql_query($qu ery)){
    $row= "mysql_fetch_ar ray($run)";

    print '<table width="50%" border="0" cellspacing="5"
    cellpadding="5" >';

    print "<p class=../style1>wonderfu l</p>";
    }else{ print "not wonderful";
    }

    print "
    <tr>
    <td bgcolor=#FF9966 ><font class=header>{$ row['title']} </font>
    &nbsp;&nbsp;&nb sp; <font class=entry> {$row['dateTime']} &nbsp;&nbsp;
    {$row['entryNum']} &nbsp;&nbsp; <a
    href=edit_entry .php?entryNum={ $row['entryNum']}>edit</a></font></td>
    </tr>
    <tr>
    <td><font class=entry>{$r ow['entry']}</font></td>
    </tr>";

    print '</table>'

    would result in the letter "m" taking the place of $row[''] ?? STRANGE!

  • Chris Hope

    #2
    Re: ...it only prints the letter &quot;m&quot ;

    kiqyou_vf wrote:
    [color=blue]
    > does anyone know why this code:
    >
    > if ($query= "SELECT * FROM ryanBlog WHERE entryNum=5"){
    > print "<p class=../style1>cool</p>";
    > }else{
    > print "<p class=../style1>not cool</p>";
    > }[/color]

    Note that the test above will always evaluate as true because you are
    assigning a value in the test, ie it will always print "cool"
    [color=blue]
    > if($run= mysql_query($qu ery)){
    > $row= "mysql_fetch_ar ray($run)";[/color]

    You are assigning the text string "mysql_fetch_ar ray($run)" to $row. The
    code should read:

    $row= mysql_fetch_arr ay($run);

    --
    Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

    Comment

    • Daniel Tryba

      #3
      Re: ...it only prints the letter &quot;m&quot ;

      kiqyou_vf <sorensong@gmai l.com> wrote:
      ....[color=blue]
      > $row= "mysql_fetch_ar ray($run)";[/color]
      ....[color=blue]
      > <td><font class=entry>{$r ow['entry']}</font></td>[/color]
      ....[color=blue]
      > would result in the letter "m" taking the place of $row[''] ?? STRANGE![/color]

      Not that strange. $row is a string containing "mysql...."
      $row['foo'] tries to get the numeric 'foo' index of $row (a string is an array
      of chars), (int)'foo' evalutates to 0 thus the first char of $row (which
      is 'm').

      fix: $row=mysql_fetc h_assoc($run);

      Comment

      • kiqyou_vf

        #4
        Re: ...it only prints the letter &quot;m&quot ;

        wonderful. thanks for the help when and when not to use quotes kind of
        throws me off... but i'll get used to it. thanks for the help.

        Comment

        • Geoff Berrow

          #5
          Re: ...it only prints the letter &quot;m&quot ;

          I noticed that Message-ID:
          <1109818567.957 635.307740@l41g 2000cwc.googleg roups.com> from kiqyou_vf
          contained the following:
          [color=blue]
          > <tr>
          > <td bgcolor=#FF9966 ><font class=header>{$ row['title']} </font>
          >&nbsp;&nbsp;&n bsp; <font class=entry> {$row['dateTime']} &nbsp;&nbsp;
          >{$row['entryNum']} &nbsp;&nbsp; <a
          >href=edit_entr y.php?entryNum= {$row['entryNum']}>edit</a></font></td>
          > </tr>
          > <tr>
          > <td><font class=entry>{$r ow['entry']}</font></td>
          > </tr>";
          >
          >print '</table>'[/color]

          Man, that's fuggly html...

          --
          Geoff Berrow (put thecat out to email)
          It's only Usenet, no one dies.
          My opinions, not the committee's, mine.
          Simple RFDs http://www.ckdog.co.uk/rfdmaker/

          Comment

          Working...