kyleldi Posted August 3, 2007 Share Posted August 3, 2007 I'm getting a free result error when trying to load my page. It loads, but this is as far as it goes. Any idea what's the cause or how to fix it? I'm not familiar with such an error. Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in department.php on line 226. Here's my page code. It's supposed to just be a database page that pulls information from the category called by the URL. <?php require_once('Connections/staff.php'); if (isset($_GET['dept'])) { $dept = $_GET['Department_Title']; } else if (isset($_POST['dept'])) { $dept = $_POST['Department_Title']; } function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if(!get_magic_quotes_gpc()) { $theValue = stripslashes($theValue); } $theValue = (function_exists("mysql_real_escape_string")) ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } mysql_select_db($database_staff, $staff); $query_rs_name = "SELECT id, Name FROM staffdirectory WHERE `dept` = '".$dept."'ORDER BY Name ASC"; if($rs_name = mysql_query($query_rs_name, $staff)) { $row_rs_name = mysql_fetch_assoc($rs_name); $totalRows_rs_name = mysql_num_rows($rs_name); } ?> Here is the code that the table/page is using to receive the information. <?php do { ?> <tr> <td><?php echo "<a href=\"viewstaff.php?id=".$row_rs_name['id']."\">".$row_rs_name['Name']."</a>"; ?></td> </tr> <?php } while ($row_rs_name = @mysql_fetch_assoc($rs_name)); ?> Any help would be appreciated. Searching the error on google seems to give more error results then answers. Quote Link to comment https://forums.phpfreaks.com/topic/63172-mysql-free-result-error/ Share on other sites More sharing options...
kyleldi Posted August 3, 2007 Author Share Posted August 3, 2007 I forgot the bottom of the page code... the reason for the error, of course. <?php mysql_free_result($rs_name); ?> Quote Link to comment https://forums.phpfreaks.com/topic/63172-mysql-free-result-error/#findComment-314870 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.