On my localhost this works fine $result= mysql_query("SELECT date_format(date, '%d/%m/%Y') as date, title,
id, display FROM NEWS"); while ($row = mysql_fetch_assoc($result)) { but on my remote i get a mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Can someone expalin the problem? PHP version problem?
Check your connection resource, as I think it's referring to the optional second variable for mysql_query($sql, $resource). How are you connecting? I assume if you're on your local machine, you're probably connecting to a locally-hosted mysql installation. Are you using the same connection string when you upload? Are you even providing one (even a background, default connection)? You should also always try to pass the resource to the mysql_query function (in most but not all cases). By not passing it, you're telling PHP to use any valid open connection it currently has associated with the script that is running: // Let's first get a connection to the database $link_identifier = mysql_connect('localhost', 'mysql_user', 'mysql_password'); // Next, look at the second, *optional* $link_identifier // This tells PHP which connection to use to perform the query // And also tells it what connection to use to get the result resource mysql_query ( string $query [, resource $link_identifier] ) If you don't provide the $link_identifier as a valid connection resource, and there's none in the background already connected, you get an invalid resource response like you received. To test, you can <code> $result= mysql_query("SELECT date_format(date, '%d/%m/%Y') as date, title, id, display FROM NEWS"); echo '<p>Test: before query</p>' while ($row = mysql_fetch_assoc($result)) { // Do stuff } </code> Where you get the error output will clue you in to which function is causing the error (_query() or _fetch())? To check if a resource has connected, you can check the resource by type: if (is_resource($link_identifier) === true) { // Do database stuff that needs a connection } IMPORTANT: Do not use mysql_pconnect() without first reading about it: - http://us2.php.net/manual/en/features.persistent-connections.php - http://us2.php.net/manual/en/function.mysql-connect.php - http://us2.php.net/manual/en/function.mysql-query.php - http://us2.php.net/manual/en/function.is-resource.php -- Jared Farrish Intermediate Web Developer Denton, Tx Abraham Maslow: "If the only tool you have is a hammer, you tend to see every problem as a nail." $$