Ameslee Posted February 12, 2007 Share Posted February 12, 2007 <?php $hostname = localhost; $username = ; $password = ; $conn = mysql_connect($hostname, $username, $password) or die(mysql_error()); $connection = mysql_select_db("greenac_VORNExpo", $conn); $query = "SELECT * FROM news"; $mysql_result=mysql_query($query,$conn); $nothingInDatabase= true; $i=1; while($row = mysql_fetch_array($mysql_result) && ($i<=2)){ if ($nothingInDatabase) $nothingInDatabase = false; $row[1] = wordwrap($row[1], 80, '<br />', true); echo("<table width=100%>"); echo "<tr>"; echo "<td>$row[1]</td></tr>"; echo "<hr>"; $i++; } if ($nothingInDatabase == true) { echo "Please check back later for entries"; } ?> can anyone work out why i am getting this error: Warning: Cannot use a scalar value as an array in /home/greenac/public_html/events.php on line 255 hope someone can help, thanks. Link to comment https://forums.phpfreaks.com/topic/38114-error-with-code-plz-help/ Share on other sites More sharing options...
paul2463 Posted February 12, 2007 Share Posted February 12, 2007 Hi Ameslee This error means that you are using a variable as an array which actually is not an array. which leads me to believe that $row isnt being set properly try this while(($row = mysql_fetch_array($mysql_result)) && ($i<=2)){ just added a couple more braces to definatley separate out the two condition sin the while statement Link to comment https://forums.phpfreaks.com/topic/38114-error-with-code-plz-help/#findComment-182511 Share on other sites More sharing options...
Ameslee Posted February 12, 2007 Author Share Posted February 12, 2007 alright that did it thanks. Link to comment https://forums.phpfreaks.com/topic/38114-error-with-code-plz-help/#findComment-182528 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.