having problems with MYSQL

A

Anonymous

Guest
i am unable to do a mysql_num_rows()

the full code works on my other website which is hosted on another server.

the mysqldatabase is empty as it should be, the following should get all info from the database into $res from the votes made, and then count the number of rows that the IP = the current $ip being used to view the page at that time.
it would then add 1 to the number of time that IP was used to vote.

The other servers mysql version is MySQL 5.0.27-community-nt
the version that this code is needed in is version MySQL 4.1.21-standard

is this why the code is not working?

thanks in advance for your help.



$res = mysql_query("SELECT * FROM votes WHERE ip = '$ip'") or die("error");

if (mysql_num_rows($res) > 0) {
$votedate = mysql_result($res, 0, "datetime");
$attempts = mysql_result($res, 0, "attempts")+1;
$res = mysql_query("UPDATE votes SET attempts='$attempts' WHERE ip = '$ip' LIMIT 1");
include("alreadyvoted.php");
mysql_close;
exit;
}
 
Create this file as connection.php

Code:
<?
function connection($conn, $username, $pass, $dbmame)
{
	global $link, $db;
	$link = mysql_connect($conn,$username, $pass);
	if(!$link)
		die("Invalid Connection");
	$db = mysql_select_db($dbmame,$link);
	if(!$db)
		die("Invalid Database Selection");
}

function select($query)
{
	global $link;
	global $result;
	
	$result = mysql_query($query,$link);
	
	while ($row = mysql_fetch_array($result, MYSQL_BOTH)) 
	{
		$rows[] = $row;
	}
	return $rows;
}

function edit($query)
{
	global $link;
	global $result;
	
	$result = mysql_query($query,$link);
	return $result;
}


function totalrows()
{
	global $result;
	return mysql_num_rows($result);
}
?>

create this file as config.php

Code:
<?
	ob_start();
	session_start();
	//Date: 18 January 2006 Time: 9:46 PM

	include "connection.php";

	$conn = "host_name";
	$username ="database_user_name";
	$pass = "database_password";
	$dbmame = "database_name";

	connection($conn, $username, $pass, $dbmame);
?>


http://mukeshvariya.blogspot.com
 
Back
Top