...it only prints the letter "m"

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

does anyone know why this code:

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

if($run= mysql_query($query)){
$row= "mysql_fetch_array($run)";

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

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

print "
        <td bgcolor=#FF9966><font class=header> </font>
&nbsp;&nbsp;&nbsp; <font class=entry> &nbsp;&nbsp;
&nbsp;&nbsp;  <a
        <td><font class=entry></font></td>

print '</table>'

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

Re: ...it only prints the letter "m"

Quoted text here. Click to load it

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_fetch_assoc($run);

Re: ...it only prints the letter "m"

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.

Re: ...it only prints the letter "m"

kiqyou_vf wrote:

Quoted text here. Click to load it

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"
Quoted text here. Click to load it

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

$row= mysql_fetch_array($run);

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

Re: ...it only prints the letter "m"

I noticed that Message-ID:
contained the following:

Quoted text here. Click to load it

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 /

Site Timeline