Jump to content

[SOLVED] mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource


r-it

Recommended Posts

can anyone tell me why this error is appearing, here is my code:

session_start();
require("connex.php");

$conn = new dbConnector();

$sql = $conn->query("SELECT * FROM roles WHERE roleID != '1'");

while($rec = $conn->fetchArray($sql))
{
$rid = $rec['roleID'];
$role = $rec['role'];

$text .= "<h2>$role</h2>";

$qry = $conn->query("SELECT users.name AS naam, users.surname AS van, users.descr as desc FROM users, user_roles WHERE users.userID = user_roles.userID  AND user_roles.roleID = '$rid' ORDER BY users.surname");

if(mysql_affected_rows($qry) < 1)
{
	$text .= "(No records)<br>";
}
else
{
	while($rek = $conn->fetchArray($qry))
	{
		$name = $rek['naam'];
		$surname = $rek['van'];
		$desc = $rek['desc'];

		$text .= "<b>$name $surname</b><br>$desc<br><br>";
	}
}

}

mysql_affected_rows

(PHP 3, PHP 4, PHP 5)

 

mysql_affected_rows -- Get number of affected rows in previous MySQL operation

Description

int mysql_affected_rows ( [resource link_identifier] )

 

 

Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query associated with link_identifier.

 

heres the connex.php

<?php 
require_once 'sysComp.php';

class dbConnector extends Conn
{
var $theQuery;
var $link;

//constructor function: connect to db
function dbConnector()
{
	$settings = Conn::getSettings();

	$host = $settings['dbhost'];
	$db = $settings['dbname'];
	$user = $settings['dbusername'];
	$pass = $settings['dbpass'];

	//connect to the database
	$this->link = mysql_connect($host, $user, $pass);
	mysql_select_db($db);

}

//query function: execute a db query
function query($query)
{
	$this->theQuery = $query;
	return mysql_query($query, $this->link);
}

//fetchArray function: get array of query results
function fetchArray($result)
{
	return mysql_fetch_array($result);
}

//close function: close the connection
function close()
{
	mysql_close($this->link);
}
}
?>

$qry = $conn->query("SELECT users.name AS naam, users.surname AS van, users.descr as `desc` FROM users, user_roles WHERE users.userID = user_roles.userID  AND user_roles.roleID = '$rid' ORDER BY users.surname");

 

if(isset($qry) and mysql_num_rows($qry)){

         ...........found data.........

}else{

       ........Prb with query or zero records found...........

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.