otester Posted July 25, 2010 Share Posted July 25, 2010 I have two databases with different sets of code on the same page, first one doesn't work, second one does. There is no difference in the setup of either databases. When blocking out this section, the area it should show up in is blank, but I can still access my website (error 500 inhibited this): while($row = mysql_fetch_array($column1)) { echo $row['ColumnT1']; } First: <?php $con = mysql_connect("x","x","x"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("x", $con); $column1 = mysql_query("SELECT * FROM Main"); while($row = mysql_fetch_array($column1)) { echo $row['ColumnT1']; } mysql_close($con); ?> Second: <?php $con = mysql_connect("x","x","x"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("x", $con); $comments = mysql_query("SELECT * FROM Comments ORDER BY Date ASC"); while($row = mysql_fetch_array($comments)) { echo "> "; echo $row['Messages']; echo "<br />"; } mysql_close($con); ?> Any ideas? Thanks, otester Quote Link to comment https://forums.phpfreaks.com/topic/208874-mysql_fetch_array-error-line-15/ Share on other sites More sharing options...
FuThAr Posted July 25, 2010 Share Posted July 25, 2010 in the first section, please add this $column1 = mysql_query("SELECT * FROM Main") if ( !$column1 ) { die("error found: " . mysql_error() ); } please tell us the result Quote Link to comment https://forums.phpfreaks.com/topic/208874-mysql_fetch_array-error-line-15/#findComment-1091061 Share on other sites More sharing options...
otester Posted July 25, 2010 Author Share Posted July 25, 2010 in the first section, please add this $column1 = mysql_query("SELECT * FROM Main") if ( !$column1 ) { die("error found: " . mysql_error() ); } please tell us the result Result: error found: No database selected Quote Link to comment https://forums.phpfreaks.com/topic/208874-mysql_fetch_array-error-line-15/#findComment-1091062 Share on other sites More sharing options...
otester Posted July 26, 2010 Author Share Posted July 26, 2010 Seems I made a boo boo, forgot to add user to database list in hosting panel, just did that, error no longer displayed. Putting the original code back in results in it working. Thanks for your help and quick reply! Quote Link to comment https://forums.phpfreaks.com/topic/208874-mysql_fetch_array-error-line-15/#findComment-1091066 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.