Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Mysql not pulling data?



9:37 am on May 5, 2009 (gmt 0)

5+ Year Member

i have a php page that should display results of a mysql query inside a table ... however no matter how many entries i have in the table it wont display any results
i have checked and verified the login data several times over it is all correct

i have also verified that all fields are correct and matching.

and i am getting 1 error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in index.php on line 10

please help

$connection = mysql_connect("$hostname" , "$user" , "$pass")
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");


ini_set('display_errors', 'On');


$query = "SELECT * FROM join";
$result = mysql_query($query);
$num = mysql_num_rows ($result);

if ($num > 0 ) {
while ($i < $num) {
$id = mysql_result($result,$i,"ID");
$tagid = mysql_result($result,$i,"tagid");
$tsname = mysql_result($result,$i,"tsname");
$boatname = mysql_result($result,$i,"boatname");
$blevel = mysql_result($result,$i,"blevel");
$plevel = mysql_result($result,$i,"plevel");
$ep = mysql_result($result,$i,"ep");
$firstname = mysql_result($result,$i,"firstname");
$lastname = mysql_result($result,$i,"lastname");
$country = mysql_result($result,$i,"country");
$email = mysql_result($result,$i,"email");
$age = mysql_result($result,$i,"age");
$guild = mysql_result($result,$i,"guild");
$otherboats = mysql_result($result,$i,"otherboats");
$comments = mysql_result($result,$i,"comments");
$ip = mysql_result($result,$i,"ip");
$rank = mysql_result($result,$i,"rank");

echo "<b>ID:</b> $id<br>";
echo "<b>Boat ID:</b> $tagid<br>";
echo "<b>TS Name:</b> $tsname<br>";
echo "<b>Boat Name:</b> $boatname<br>";
echo "<b>Boat Level:</b> $blevel<br>";
echo "<b>Pirate Level:</b> $plevel<br>";
echo "<b>EP:</b> $ep<br>";
echo "<b>First Name:</b> $firstname<br>";
echo "<b>Last Name:</b> $lastname<br>";
echo "<b>Country:</b> $country<br>";
echo "<b>Email:</b> $email<br>";
echo "<b>Age:</b> $age<br>";
echo "<b>Guild:</b> $guild<br>";
echo "<b>Other Boats:</b> $otherboats<br>";
echo "<b>Comments:</b> $comments<br>";
echo "<b>IP:</b> $ip<br>";
echo "<b>Rank:</b> $rank<br>";
echo "<a href=\"update.php?id=$id\">Update</a> - <a href=\"delete.php?id=$id\">Delete</a>";
echo "<br><br>";

++$i; } } else { echo "The database is empty"; }
<a href="add.php">Add entry</a>

i even tried to simplify it using


$query = "SELECT * FROM join";
$result = mysql_query($query);
$num = mysql_num_rows ($result);

echo $query;
echo $result;

and still no display of results ... puzzuling


11:40 am on May 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

The word 'join' is a reserved word for mysql. Try renaming the table and editing your script.


3:52 pm on May 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

also what happens if you have this?

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


Featured Threads

Hot Threads This Week

Hot Threads This Month