I am these 2 errors come up in my database and I cant figure out the problem with my code....can someone help please? here is the code.

<body>
<?php

include("../misc.inc");
mysql_connect($host,$user,$pass);
mysql_select_db($database);
if($HTTP_GET_VARS['id'])
{
$query = "SELECT * FROM guestlist WHERE eventID = '".$HTTP_GET_VARS['id']."'";
$result = mysql_query($query);
$nrows = mysql_num_rows($result);
if($nrows > 0){
$i = 0;
$myGuests = array();
while($row = mysql_fetch_array($result))
{
extract($row);
$totalGuests += $guests;
$myGuests[$i] = "<tr><td>".($i+1)."</td><td>$guestName</td><td>$guests</td><td>$email</td></tr>";
$i++;
}
echo "<p>$nrows on guestlist, ".($nrows+$totalGuests)." expected for event.</p>";
echo "<table width =\"600\" border=\"1\">";
echo "<tr><th>&nbsp;</th><th>Name</th><th width=\"50\">Guests</th><th>Email</th></tr>";
for($i=0;$i<sizeof($myGuests);$i++)
{
echo $myGuests[$i];
}
echo "</table>";
}
else
{
echo "<p>No guests.</p>";
}
}
else
{
$currentDate = date("Y-m-d",time());
$query = "SELECT * FROM events_entries WHERE eventDate >= '$currentDate' ORDER by eventDate";
$result = mysql_query($query);
$nrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{
extract($row);
echo "<p>-<a href=\"getguests.php?id=$id\">$eventDate: $eventName @ $eventLocation</a></p>";
}
}

?>
<p>-<a href="index.php?<?php echo session_id(); ?>">Back To Main</a><br />
-<a href="logout.php?<?php echo session_id(); ?>">Logout</a></p>
</body>

I am getting these 2 error messages:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Please advise....thanks a lot guys!!

hi
this is because $result doesnot contain resource.
after $result = mysql_query($query);
put following code

if (!$result) {
    die('Invalid query: ' . mysql_error());
}

it will not allow further execution if $result is null.
if it is so check you $query string by echoing it.

OK I tried that and the result is the same....should it look like this?

$query = "SELECT * FROM guestlist WHERE eventID = '".$HTTP_GET_VARS."'";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
$nrows = mysql_num_rows($result);
if($nrows > 0){
$i = 0;
$myGuests = array();
while($row = mysql_fetch_array($result))
{
extract($row);


hi
this is because $result doesnot contain resource.
after $result = mysql_query($query);
put following code

if (!$result) {
    die('Invalid query: ' . mysql_error());
}

it will not allow further execution if $result is null.
if it is so check you $query string by echoing it.

hey
try this...

<?php

include("../misc.inc");
$variable = $HTTP_GET_VARS['id'];
mysql_connect($host,$user,$pass);
mysql_select_db($database);
if($HTTP_GET_VARS['id'])
{
$query = "SELECT * FROM guestlist WHERE eventID = '$variable'";
$result = mysql_query($query);
$nrows = mysql_num_rows($result);
if($nrows > 0){
$i = 0;
$myGuests = array();
while($row = mysql_fetch_array($result))
{
extract($row);
$totalGuests += $guests;
$myGuests[$i] = "<tr><td>".($i+1)."</td><td>$guestName</td><td>$guests</td><td>$email</td></tr>";
$i++;
}
echo "<p>$nrows on guestlist, ".($nrows+$totalGuests)." expected for event.</p>";
echo "<table width =\"600\" border=\"1\">";
echo "<tr><th>&nbsp;</th><th>Name</th><th width=\"50\">Guests</th><th>Email</th></tr>";
for($i=0;$i<sizeof($myGuests);$i++)
{
echo $myGuests[$i];
}
echo "</table>";
}
else
{
echo "<p>No guests.</p>";
}
}
else
{
$currentDate = date("Y-m-d",time());
$query = "SELECT * FROM events_entries WHERE eventDate >= '$currentDate' ORDER by eventDate";
$result = mysql_query($query);
$nrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{
extract($row);
echo "<p>-<a href=\'getguests.php?id=$id\'>$eventDate: $eventName @ $eventLocation</a></p>";
}
}

?>

I tried that code and I now have errors on different lines....to see what im talking about go to this link http://www.scorpionentertainment.com/getguests.php

I really appreciate your help guys it worked fine before im not sure what happened to make it no longer work.

it wont show me the errors in my browser?
can you copy in the full code, and the error messages please.
see if i can help :D

This is the error message


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/scorpio/public_html/getguests.php on line 57

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/scorpio/public_html/getguests.php on line 58

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.