Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/63172-mysql-free-result-error/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.