Question : mysql_fetch_array error

This code works fine locally but as soon as I upload it to the server I get an error when running it. The error is:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource  on line 195

line 195 is: while  ($row = mysql_fetch_array($result)) {

I have checked the query against the database table. It is definaly the correct casing and the table does exist so not sure what else the problem could be. Thanks.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
<?php if (isset($_POST['Submit'])) {
foreach ($_POST['todelete'] as $delete_id) {
$query = "DELETE FROM news WHERE NewsID = $delete_id";
mysql_query($query, $som) ;
}
echo 'News removed.<br />';
}
$query = "SELECT * FROM news";
$result = mysql_query($query, $som);
while  ($row = mysql_fetch_array($result)) {
echo '<input type="checkbox" value="' . $row['NewsID'] . '" name="todelete[]" />';
echo $row['Headline'];
echo '<br />';
} ?>

Answer : mysql_fetch_array error

try to check if the select has rows
and to get more specific error change this:

$result = mysql_query($query, $som);

for this

$result = mysql_query($query, $som) or die(mysql_error());
Random Solutions  
 
programming4us programming4us