ramonred Posted April 12, 2008 Share Posted April 12, 2008 Hi, I am having trouble with a php script that I've used successfully before. I know it is getting as far as connecting to the database, but it won't display any records. Here is the code: <?php connectDB(); if (isset($reg)) { displayItems($reg); } else { //do nothing } function connectDB() { $dbcnx = @mysql_connect("localhost", "redfrogp_misa", "********"); if (!$dbcnx) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit(); } // Select the contacts database if (! @mysql_select_db("redfrogp_misa") ) { echo( "<P>Unable to locate the" . "database at this time.</P>" ); exit(); } return true; } function displayItems($r) { $result = mysql_query("select * from items"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } while ( $row = mysql_fetch_array($result) ) { $row["desc"]; } } ?> I've checked my bracketing very carefully. I don't see what the issue is, any help would be appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/100755-php-not-displaying-records-from-database-no-error-given/ Share on other sites More sharing options...
Gamic Posted April 12, 2008 Share Posted April 12, 2008 You are using the symbol '@' in front of mysql function calls which suppresses warnings. I'd suggest running the code again without that. Link to comment https://forums.phpfreaks.com/topic/100755-php-not-displaying-records-from-database-no-error-given/#findComment-515365 Share on other sites More sharing options...
bobinindia Posted April 12, 2008 Share Posted April 12, 2008 This may seem stupid but is 'desc' a column name in your table? Just in case!! $row["desc"]; Link to comment https://forums.phpfreaks.com/topic/100755-php-not-displaying-records-from-database-no-error-given/#findComment-515367 Share on other sites More sharing options...
Barand Posted April 12, 2008 Share Posted April 12, 2008 echo $row['desc']; DESC is a mySQL reserved word, so don't use as a column name. Change to something else. Link to comment https://forums.phpfreaks.com/topic/100755-php-not-displaying-records-from-database-no-error-given/#findComment-515378 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.