Hello
I amm designing a website for my mom the site is to advertise her book. it has a message board in it. the message board works great locally but when i upload it t a server i get a:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/areyoube/public_html/PeapleSay/display_message.php on line 11

Now i am pretty new to php and mysql and i do not have a clue what to do. I did create a new database on the host but i did make all neccesary changes to both the scripts and the database.

Any help would be great Thank-you.

Dani AI

Generated

Diagnosis: that fetch error means the row-fetch function was handed something other than a successful query result — in short, the query returned false. As recommended, capture the database API error at the query step instead of proceeding to fetch rows; made a similar point. When code runs locally but fails on the host the usual culprits are incorrect connection credentials, an un-imported or differently named table, shared-hosting DB name prefixes, Linux case-sensitivity on table/column names (Windows dev vs Linux host), insufficient DB user privileges, or SQL/PHP-version incompatibilities.

Practical checklist:

  • Verify connection parameters (host, username, password, database) and that the database import actually created the expected tables and rows.
  • Run the exact SELECT in phpMyAdmin or the MySQL client to see the server error.
  • Check table and column name case: a table called Messages will be different from messages on most hosts.
  • Confirm the DB user has SELECT privileges on the target tables.
  • Turn on detailed error reporting temporarily and inspect PHP/MySQL error logs rather than leaving display_errors enabled in production.
  • Confirm the server PHP version and extension support — legacy mysql_* functions are removed in recent PHP; consider migrating to mysqli or PDO.

Example (safe, modern approach using MySQLi; use this pattern to log the actual DB error rather than attempting to fetch a bad result):

$mysqli = new mysqli('host','user','pass','dbname');
if ($mysqli->connect_error) {
    error_log('DB connect error: '.$mysqli->connect_error);
    exit;
}
$result = $mysqli->query('SELECT id, message FROM messages');
if ($result === false) {
    error_log('Query error: '.$mysqli->error);
    exit;
}
while ($row = $result->fetch_assoc()) {
    // render message
}

For migration notes and API choices, see the PHP manual on MySQLi and PDO.

Recommended Answers

All 7 Replies

It sounds like you are executing:

$res = mysql_query("some query here");
while($row = mysql_fetch_assoc($res) )
{
 //...code here
}

what you need to do is add " or die( mysql_error() );" so that you get details about the error.

$res = mysql_query("some query here") or die( mysql_error() );
while($row = mysql_fetch_assoc($res) )
{
 //...code here
}
Member Avatar for Member #823006

Paste your code in here.

paste your code here....

Paste your code so that we could help or mail it to vaibhavranglani[at]raveportal<dot>com

i'm agree with 'hielo' use or die("Mysql Error " .mysql_error());

I will post the code on here as soon as i can thank you everyone for you responses i really appreciate it.

Thank you for your replies. but i have put this project on hold for awhile. And thank-you again for your replies.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.