I have two files this is the file included:

<?php

if (@mysql_connect("localhost","****", "**************") || @mysql_select_db("a_database")) {
    echo "Connected";
} else {
    die("Not connected.");
}

?>

Then this is the main file:

<?php

require "connect.inc.php";

$query = "SELECT `food`, `calories` FROM `food` ORDER BY `id`";


if ($query_run = mysql_query($query)) {
    echo "Success.";
} else {
    echo "Query Failed.";
}



?>

However when the page loads it says "ConnectedQuery Failed."

Why could this be?

Add mysql_error() to your execution:

mysql_query($query) or die(mysql_query())

This will output the error, it should help you to solve the problem.

That doesn't seem to be outputting anything?

<?php

require "connect.inc.php";

$query = "SELECT `food`, `calories` FROM `food` ORDER BY `id`";


mysql_query($query) or die(mysql_query($query));

?>

Ah Don't worry I was bieng silly. Sorted it now:)

Anyway, I'm realizing I wrote a wrong example, sorry, I intended:

mysql_query($query) or die(mysql_error());

bye!