Page 1 of 1

says user doesnt exist. SQL

Posted: Sun Mar 26, 2006 9:15 pm
by psychotomus
first im deleting records that expire past 24 hours. is

86400

the correct number for 24 hours?

second $hit = 1 and looking at my sql tools it shows the record there with an id of 1

Code: Select all

$result = mysql_query( "SELECT * FROM whh_members WHERE id='$hit'" );//
	$row=mysql_fetch_array($result);	//Store Record Of Data in $row 
	
	print $row['id'];

the full code

Code: Select all

$hostname = $_SERVER['REMOTE_ADDR'];
$timeout = time() - 86400; //24 hours
$thetime = time();


//delete people that havnt visited in 24 hours.
mysql_query("DELETE FROM whh_last_click WHERE Whenn < $timeout"); 


//find out if user allready visited users link within 24 hours
$result = mysql_query( "SELECT * FROM whh_last_click WHERE ip='$hostname' AND member_id='$hit'" );//
$row=mysql_fetch_array($result);	//Store Record Of Data in $row 


//if user hasnt visited within 24 hours add to database
if ($row['id'] == "")
{

	$result = mysql_query( "SELECT * FROM whh_members WHERE id='$hit'" );//
	$row=mysql_fetch_array($result);	//Store Record Of Data in $row 
	
	print $row['id'];
	if ($row['id'] <> "")
	{
		//add when user got last click from member id
		mysql_query ("INSERT INTO whh_last_click(ip,member_id,whenn) VALUES ('$hostname','$hit','$thetime')") or die(mysql_error());
		$wh = $row['wh'] + 10;
		
		//update wh
		mysql_query ("UPDATE whh_members SET wh='$wh' WHERE id='$hit'") or die(mysql_error());
		print '<br><p align="center"><strong>You have given this user 10$WH. </strong></p>';
	}
	else
	{
		print '<br><p align="center"><strong>User does not exist. </strong></p>';
	}
}
else
{
	print '<br><p align="center"><strong>You have allready given this user 10$WH within the last 24 hours.</strong></p>';
}

Posted: Sun Mar 26, 2006 9:21 pm
by feyd
where's "hit" coming from?

Posted: Sun Mar 26, 2006 9:32 pm
by jrd
I'm curious, what output do you get?

Posted: Sun Mar 26, 2006 9:42 pm
by psychotomus
hit is coming from $_GET['hit']

output.


http://www.high-poetry.com/whh/?hit=1


if i run the sql query through the "MyAdmin" the sql control panel. it works.

what makes it even weird is if im logged in and access that page. it will say the user exist.

Posted: Sun Mar 26, 2006 9:46 pm
by feyd
I would guess that "hit" doesn't exist.

Run the following in a new file and tell us the results please.

Code: Select all

<?php

$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
$rg = (in_array(strtolower(ini_get('register_globals')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$de = (in_array(strtolower(ini_get('display_errors')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$so = (in_array(strtolower(ini_get('short_open_tag')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$eol = (isset($_SERVER['HTTP_HOST']) ? "<br />\n" : "\n");

$ec = array(
   'E_STRICT' => 2048,
   'E_ALL' => 2047,
   'E_USER_NOTICE' => 1024,
   'E_USER_WARNING' => 512,
   'E_USER_ERROR' => 256,
   'E_COMPILE_WARNING' => 128,
   'E_COMPILE_ERROR' => 64,
   'E_CORE_WARNING' => 32,
   'E_CORE_ERROR' => 16,
   'E_NOTICE' => 8,
   'E_PARSE' => 4,
   'E_WARNING' => 2,
   'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
   if (($t & $v) == $v)
   {
      $e[] = $n;
      $t ^= $v;
   }
}
$er = $er . ' (' . implode(' | ', $e) . ')';

echo 'PHP Version: ' . $ve . $eol;
echo 'PHP OS: ' . $os . $eol;
echo 'Error Reporting: ' . $er . $eol;
echo 'Register Globals: ' . $rg . $eol;
echo 'Short Tags: ' . $so . $eol;
echo 'Display Errors: ' . $de . $eol;

?>

Posted: Sun Mar 26, 2006 9:50 pm
by psychotomus
hit does exist. i can print $hit and it will print "1" to the page.



PHP Version: 4.3.5
PHP OS: WINNT
Error Reporting: 341 (E_USER_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_PARSE | E_ERROR)
Register Globals: On
Short Tags: On
Display Errors: On

Posted: Sun Mar 26, 2006 10:24 pm
by jrd
what if its a syntax error?

Code: Select all

//delete people that havnt visited in 24 hours.
mysql_query("DELETE FROM whh_last_click WHERE Whenn < $timeout");
'$timeout'?

Posted: Sun Mar 26, 2006 10:25 pm
by psychotomus
is this time - 24 hours?

$timeout = time() - 86400; //24 hours

Posted: Sun Mar 26, 2006 10:47 pm
by jrd

Code: Select all

//delete people that havnt visited in 24 hours.
mysql_query("DELETE FROM whh_last_click WHERE Whenn < '$timeout' ");
86400 is time for 1 day. What kind of data do you keep in whenn? i'm just curios.

:wink:

Posted: Mon Mar 27, 2006 11:41 am
by psychotomus
jrd wrote:

Code: Select all

//delete people that havnt visited in 24 hours.
mysql_query("DELETE FROM whh_last_click WHERE Whenn < '$timeout' ");
86400 is time for 1 day. What kind of data do you keep in whenn? i'm just curios.

:wink:
time()

Posted: Fri Mar 31, 2006 7:31 am
by jrd
have you fixed it?