Below is my code:
session_start();
include_once "config.inc.php";
$tbl_name="members";
$username=$_SESSION['username'];
$sql = "SELECT quiz1mark, quiz2mark, quiz3mark FROM $tbl_name WHERE username='$username'";
$query = mysql_query($sql);
$data = mysql_fetch_array($query, MYSQL_ASSOC);
Then, further down the page:
<p><?php echo $data; ?></p>
This generates a notice: Notice: Undefined variable: data in F:\xampp\htdocs\quiz_home.php on line 35
I've clearly defined the variable though, and am unsure as to what's causing this problem.
***Contents of config.inc.php***:
$host="localhost";
$username="root";
$password=""; //the default installation of xampp does not include a mysql password
$db_name="bda";
//connect to the database using the above information (variables)
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select database");