Im getting this error...

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/mlongcos/cosdonline.org/conferences/register_05.php on line 155

Cant figure out why this isnt working... somebody please help!

The file is attached

Attachments
<html>
<head>
	<title>COSD - Conferences</title>
	<!-- rollover script -->
	<script language="JavaScript" src="../scripts/roll_overs_sub.js" type="text/javascript"></script>
	<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
	//Main image roll overs for header
	
	// Top nav rollover images in the on position
	
	  image09on = new Image();  image09on.src = "../img/conferences/1_on.gif";
	  image10on = new Image();  image10on.src = "../img/conferences/2_on.gif";
	  image11on = new Image();  image11on.src = "../img/conferences/3_on.gif";
	 image12on = new Image();  image12on.src = "../img/conferences/4_on.gif";
	  	  	  		  
	  // Top Nav rollover images in the off position
	
	  image09off = new Image();  image09off.src = "../img/conferences/1_off.gif";
	  image10off = new Image();  image10off.src = "../img/conferences/2_off.gif";
	  image11off = new Image();  image11off.src = "../img/conferences/3_off.gif";
	  image12off = new Image();  image12off.src = "../img/conferences/4_off.gif";
	  
	
	function changeImages() {
		if (document.images) {
	    	for (var i=0; i<changeImages.arguments.length; i+=2) {
	      		document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
	    	}
		}
	}
	
	
	</SCRIPT>
	<LINK REL=STYLESHEET TYPE="text/css" HREF="../main.css">
</head>

<body leftmargin="1" topmargin="1" rightmargin="1" bottommargin="1" marginwidth="1" marginheight="1">
<table width="754" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td><img src="../img/top_left.gif" width="482" height="61" border="0" alt="COSD"></td>
	<td><img src="../img/top_conferences.gif" width="273" height="61" border="0" alt="Conferences"></td>
</tr>
</table>
<table width="754" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td><A href="../index.shtml" onmouseout="changeImages('image01', 'image01off')" onmouseover="changeImages('image01', 'image01on')" title="Home"><img src="../img/1_off.gif" width="45" height="28" border="0" alt="Home" name="image01"></a></td>
	<td><A href="../introduction/index.shtml" onmouseout="changeImages('image02', 'image02off')" onmouseover="changeImages('image02', 'image02on')" title="Training Modules"><img src="../img/2_off.gif" width="101" height="28" border="0" alt="Introduction" name="image02"></a></td>
	<td><A href="../news/index.shtml" onmouseout="changeImages('image03', 'image03off')" onmouseover="changeImages('image03', 'image03on')" title="News and Events"><img src="../img/3_off.gif" width="116" height="28" border="0" alt="News and Events" name="image03"></a></td>
	<td><A href="../profiles/index.shtml" onmouseout="changeImages('image04', 'image04off')" onmouseover="changeImages('image04', 'image04on')" title="Profiles"><img src="../img/4_off.gif" width="68" height="28" border="0" alt="Profiles" name="image04"></a></td>
	<td><A href="../directory/index.php" onmouseout="changeImages('image05', 'image05off')" onmouseover="changeImages('image05', 'image05on')" title="Membership Directory"><img src="../img/5_off.gif" width="150" height="28" border="0" alt="Membership Directory" name="image05"></a></td>
	<td><A href="../training/index.shtml" onmouseout="changeImages('image06', 'image06off')" onmouseover="changeImages('image06', 'image06on')" title="Training Modules"><img src="../img/6_off.gif" width="128" height="28" border="0" alt="Training Modules" name="image06"></a></td>
	<td><A href="../conferences/index.shtml" title="Conferences"><img src="../img/7_on.gif" width="97" height="28" border="0" alt="Conferences" name="image07"></a></td>
	<td><A href="../links/index.shtml" onmouseout="changeImages('image08', 'image08off')" onmouseover="changeImages('image08', 'image08on')" title="Links"><img src="../img/8_off.gif" width="49" height="28" border="0" alt="Links" name="image08"></a></td>
</tr>
</table>
<table width="754" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
	<td>
		<table width="168" border="0" cellspacing="0" cellpadding="0">
		<tr>
			
          <td><img src="../img/spacer.gif" width="168" height="20" border="0" alt="-"> 
            <table width="168" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td><A href="index.shtml" onmouseout="changeImages('image09', 'image09off')" onmouseover="changeImages('image09', 'image09on')" title="COSD Annual National Meeting"><IMG SRC="../img/conferences/1_on.gif" ALT="COSD Annual National Meeting" NAME="image09" ID="image09" WIDTH="168" HEIGHT="46" BORDER="0"></a></td>
			</tr>
			<!-- 2005 CONFERENCE SUBNAV -->
			<!--#include virtual="../includes/conferences_05_nav.inc" --> 
			<tr>
				<td><A href="past.shtml" onmouseout="changeImages('image11', 'image11off')" onmouseover="changeImages('image11', 'image11on')" title="Past COSD Conferences"><img src="../img/conferences/3_off.gif" alt="Past COSD Conferences" name="image11" id="image11" width="168" height="26" border="0"></a></td>
			</tr>
			<tr>
				<td><A href="related.shtml" onmouseout="changeImages('image10', 'image10off')" onmouseover="changeImages('image10', 'image10on')" title="Related Conferences"><IMG SRC="../img/conferences/2_off.gif" ALT="Related Conferences" NAME="image10" ID="image10" WIDTH="168" HEIGHT="26" BORDER="0"></a></td>
			</tr>
			<tr>
				<td><A href="videos.shtml" onmouseout="changeImages('image12', 'image12off')" onmouseover="changeImages('image12', 'image12on')" title="Conference Videos"><img src="../img/conferences/4_off.gif" alt="Conference Videos" name="image12" id="image12" width="168" height="26" border="0"></a></td>
			</tr>
			</table>
			</td>
		</tr>
		</table>
	</td>
	<td valign="top">
		<table width="555" border="0" cellspacing="0" cellpadding="0">
		<tr valign="top">
			<td width="10" background="../img/page_left.gif"><img src="../img/spacer.gif" width="5" height="1" border="0" alt="-"></td>
			<td width="535">
			<img src="../img/spacer.gif" width="5" height="5" border="0" alt="-"><br>
			<FONT FACE="ARIAL" SIZE="3" COLOR="#004DB6"><b>Online Registration - Confirmation Page</b></FONT>
			<!--
			<p>The COSD 4<sup>th</sup> Annual National Meeting Online Registration is now closed due to reaching our capacity for the Meeting space. If you are registered to attend, we look forward to seeing you in Seattle.
			<p>If you have questions regarding the meeting please email <a href="mailto:conferences@cosdonline.org" class="blue" title="conferences@cosdonline.org">conferences@cosdonline.org</a>.
			-->
			<p><font size="2" face="Arial"></font></b> 
            
			<TABLE WIDTH="100%" BACKGROUND="" CELLSPACING="0" CELLPADDING="0" BORDER="0">
			<TR>
				<TD VALIGN="TOP">
<?php
# Main script which processes the form, sends the e-mails and displays (redirects to) the confirmation page
include("cosdc0nf.php");	# Includes MySQL information

// Sanitize User Input
$message="\n";
$firstname=control("First Name",$HTTP_POST_VARS["firstname"]);
$lastname=control("Last Name",$HTTP_POST_VARS["lastname"]);
$organization=control("Organization",$HTTP_POST_VARS["organization"],1);
$department=control("Department",$HTTP_POST_VARS["department"],1);
$title=control("Title",$HTTP_POST_VARS["title"],1);
$email=control("E-Mail Address",$HTTP_POST_VARS["email"]);
$phone=control("Phone",$HTTP_POST_VARS["phone"],1);
$address=control("Address",$HTTP_POST_VARS["address"],1);
$city=control("City",$HTTP_POST_VARS["city"]);
$state=control("State",$HTTP_POST_VARS["state"]);
$zip=control("Zip",$HTTP_POST_VARS["zip"]);
$arrival_date=control("Arrival Date",$HTTP_POST_VARS["arrival_date"]);
$departure_date=control("Departure Date",$HTTP_POST_VARS["departure_date"]);
$checkbox1=control("",$HTTP_POST_VARS["checkbox1"],1);
$checkbox2=control("",$HTTP_POST_VARS["checkbox2"],1);
$checkbox3=control("",$HTTP_POST_VARS["checkbox3"],1);
$checkbox4=control("",$HTTP_POST_VARS["checkbox4"],1);
$checkbox5=control("",$HTTP_POST_VARS["checkbox5"],1);
$checkbox6=control("",$HTTP_POST_VARS["checkbox6"],1);
$checkbox7=control("",$HTTP_POST_VARS["checkbox7"],1);
$checkbox8=control("",$HTTP_POST_VARS["checkbox8"],1);
$checkbox9=control("",$HTTP_POST_VARS["checkbox9"],1);
$checkbox10=control("",$HTTP_POST_VARS["checkbox10"],1);
$checkbox11=control("",$HTTP_POST_VARS["checkbox11"],1);
$checkbox12=control("",$HTTP_POST_VARS["checkbox12"],1);
$checkbox13=control("",$HTTP_POST_VARS["checkbox13"],1);
$checkbox14=control("",$HTTP_POST_VARS["checkbox14"],1);
$checkbox15=control("",$HTTP_POST_VARS["checkbox15"],1);
$checkbox16=control("",$HTTP_POST_VARS["checkbox16"],1);
$checkbox17=control("",$HTTP_POST_VARS["checkbox17"],1);
$checkbox18=control("",$HTTP_POST_VARS["checkbox18"],1);
$checkbox22=control("",$HTTP_POST_VARS["checkbox22"],1);
$checkbox23=control("",$HTTP_POST_VARS["checkbox23"],1);
$checkbox24=control("",$HTTP_POST_VARS["checkbox24"],1);
$checkbox25=control("",$HTTP_POST_VARS["checkbox25"],1);
$checkbox26=control("",$HTTP_POST_VARS["checkbox26"],1);
$checkbox27=control("",$HTTP_POST_VARS["checkbox27"],1);
$othersign=control("",$HTTP_POST_VARS["othersign"],1);
$banquet=control("Attending to Banquet",$HTTP_POST_VARS["banquet"],1);
$parking=control("Parking at the Merck Research Lab",$HTTP_POST_VARS["parking"],1);
$boston=control("COSD Complimentary Transportation",$HTTP_POST_VARS["boston"],1);
$outdoor=control("Outdoor Explorations Sailing Experience",$HTTP_POST_VARS["outdoor"],1);

if ($email !== "") {	// if e-mail is not left empty
	if (! eregi("^.+@.+\\..+$", $email, $hodo)) {	// simple e-mail validation
		$message.="Your <b>E-Mail Address</b> is not correct.\n<br>";
	}
	$db=mysql_connect($db_loc, $db_usr, $db_pas) or die ("Unable to connect to the database.");
	mysql_select_db($db_db, $db);
	$echeck=mysql_query("SELECT * FROM $db_tab1 WHERE r_email LIKE '$email'",$db);
	if (mysql_num_rows($echeck)) {	// E-Mail address already registered
		$message.=">> The E-Mail address you have provided, already exists in our database.\n<br>";
	}
}

if ($message !== "\n") {	// Error in submitted form warn the user
	echo("<b>>>>>> Error: <u>Please go back and correct the following errors</u>;</b><br>\n$message\n<br><br><br><br><br><br>");
}
else {	// No error, continue no

Suggest you echo out your sql statement to verify that it is being built correctly from the supplied variables. In this case it looks like you are using a variable for the table name, but there is no local decalaration of that variable.

when you use mysql_num_rows, you need to specify the pointer you are usign, eg:

$result1 = mysql_query($query1);
$result2 = mysql_query($query2);
echo "There are ".mysql_num_rows($result1)." rows in the first query\n";
echo "There are ".mysql_num_rows($result2)." rows in the second query\n";

//most of the time you use mysql_num_rows in a for loop, eg:
for ($i=0; $i<mysql_num_rows($result1); $i++) {
     $row = mysql_fetch_row($result1);
     echo $row[0]."-".$row[1]."\n";
}

//but if you don't care how many rows there are, you could just do the following:
while ($row = mysql_fetch_row($result2))
     echo $row[0]."-".$row[1]."\n";
}

the for loop and the while loop will do the exact same thing, except one uses result1 and the other result2

oah my bad, I just realized that you had the php file attached and you didn't make the mistake I assumed you did...

try putting some more checks in there to see where your errors are, anywhere you see __LINE__ it will print out the exact line the error occured in the PHP file. Very helpful if you do a lot of copying and pasting of code and don't feel like making unique error messages

$db=mysql_connect($db_loc, $db_usr, $db_pas) or die ("Unable to connect to the database. (". __LINE__.")");
mysql_select_db($db_db, $db)  or die ("Unable to connect to the selected database. (". __LINE__.")");

$echeck=mysql_query("SELECT * FROM $db_tab1 WHERE r_email LIKE '$email'",$db);

if ($echeck == 0) {
	      echo("<b>Error (".__LINE__.")" . mysql_errno($echeck) . ": " . mysql_error($echeck) . "</b>");
}

if (mysql_num_rows($echeck)) {	// E-Mail address already registered
	$message.=">> The E-Mail address you have provided, already exists in our database.\n<br>";
}
This article has been dead for over six months. Start a new discussion instead.