Ryan Schafer
Ryan Schafer

Reputation: 241

For some reason, PHP shows up in my textarea box

Here's my code:

<textarea>
<?
while ($row = mysql_fetch_array($result)) {
    echo $row[0], $row[1] . "\n";
    ?>
</textarea>

And it outputs this to the textarea box AND creates a second box:

<?
while ($row = mysql_fetch_array($result)) {
    echo $row[0], $row[1] . "\n";
    ?>

With long tags and the curly brace, I now get this! Haha:

<br />
<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\globaldetroit\index.php on line <i>23</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0006</td><td bgcolor='#eeeeec' align='right'>672248</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='C:\wamp\www\globaldetroit\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0037</td><td bgcolor='#eeeeec' align='right'>679240</td><td bgcolor='#eeeeec'><a href='http://www.php.net/mysql_fetch_array' target='_new'>mysql_fetch_array</a>
(  )</td><td title='C:\wamp\www\globaldetroit\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>23</td></tr>
</table></font>

When I removed my "ordered by" statement in my SQL code, this error disappeared.

Upvotes: 0

Views: 173

Answers (3)

Jake N
Jake N

Reputation: 10583

Try this, short tags might be disabled on your server:

<?php
while ($row = mysql_fetch_array($result)) {
echo $row[0], $row[1] . "\n";
?>

Edit:

Your missing a closing } for the while loop:

<?php
while ($row = mysql_fetch_array($result))
{
    echo $row[0], $row[1] . "\n";
}
?>

Upvotes: 7

icirellik
icirellik

Reputation: 766

Try:

<textarea>
<?php
while ($row = mysql_fetch_array($result)) {
    echo $row[0], $row[1] . "\n";
}
?>
</textarea>

Upvotes: 1

Your Common Sense
Your Common Sense

Reputation: 157880

either short_open_tag is set off or PHP is not running

Upvotes: 1

Related Questions