Im having trouble returning the amount of rows in a mysql table? Any ideas why resource id 6 is appearing?
<?php
session_start();
$page = array();
$page['title'] = 'OpenTheBox | DuffLotto';
$slot = $_SESSION['slot'];
$name = 'duffrynmad';
if (!$slot) {
echo 'No slot chosen! '; echo "<a href=otb.php>Click here go back and play again.</a>";
die();
exit();
}
include('header.php');
require_once('/home/davespri/hidden/dbcon.php');
$connect = mysql_connect($host, $user, $pass);
if (!$connect) {
echo 'Failure to connect to Database';
die();
exit();
}
mysql_select_db('davespri_Gamerecords', $connect);
$val = mysql_query("SELECT * FROM OpenTheBox2 WHERE Slot = '$slot' ");
$val2 = mysql_fetch_array($val);
if (!$val) {
echo 'Spot not validated';
echo $val2['Nickname'];
exit();
die();
}
if (!$val2['Nickname'] == null) {
echo 'Slot already purchased, please go back and choose another slot';
echo '<a href=otb.php><button>Click here to go back to the selction menu</button></a>';
die();
}
$update = mysql_query("UPDATE OpenTheBox2 SET Nickname = '$name' WHERE Slot = '$slot' ");
if ($update) {
echo 'Transaction successful!';
echo 'You have been given slot '; echo $slot; echo '<br />';
echo '<a href=otb.php><button>Click here to go back to the selection menu</button></a>';
}
$sql = "SELECT * FROM OpenTheBox2 WHERE Nickname IS null";
$result = mysql_query($sql,$connect);
if ($result == 0) {
mysql_query("UPDATE OpenTheBox2 SET Nickname = NULL ");
}
echo '<br />';
echo $result;
include('footer.php');
?>
Its the thats causing the problems
$sql = "SELECT * FROM OpenTheBox2 WHERE Nickname IS null";
$result = mysql_query($sql,$connect);