PHP返回错误[重复]

Here is my code:

include('functions.php');

//open connection to the server
$host="localhost"; // Host name
$username="timeout7_admin"; // Mysql username
$password="cazz11"; // Mysql password
$db_name="timeout7_timeout"; // Database name

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql = "SELECT * FROM jobs WHERE status='past' AND date LIKE '2013-10%'";
$result = mysql_query($sql);
    if($result == false) {
        echo mysql_error();
    }

while($row = mysql_fetch_array($result)) {
}

Its returning this error:

PHP Warning:  mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home4/timeout7/public_html/backend/test.php on line 16

But I'm not getting why... The value of $result should be a resource :/

</div>

Try this:

$sql = "SELECT * FROM jobs WHERE status='past' AND date LIKE '2013-10%'";
$result = mysql_query($sql) or die(mysql_error());

NOTE: don't use mysql_* functions as its depreciated, rather use PDO or MySQLi

Change your $result = mysql_query($sql); to $result = mysql_query($sql) or die(mysql_error()); If there is any errors it will be displayed. It looks like you have an error in your sql too.

$sql = "SELECT * FROM jobs WHERE status='past' AND date LIKE '2013-10%';"; 

needs to be

$sql = "SELECT * FROM jobs WHERE status='past' AND renamed_date_column LIKE '2013-10%'";

And also, as the guys HankyPanky and Pekka suggest you need to change your column name to something else other than date since it is a reserved word.

Try this

if( mysql_num_rows( $result ) > 0 ) {
   while($row = mysql_fetch_array($result)) {
   }
}