says user doesnt exist. SQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

says user doesnt exist. SQL

Post 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>';
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

where's "hit" coming from?
jrd
Forum Commoner
Posts: 53
Joined: Tue Mar 14, 2006 1:30 am

Post by jrd »

I'm curious, what output do you get?
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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;

?>
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post 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
jrd
Forum Commoner
Posts: 53
Joined: Tue Mar 14, 2006 1:30 am

Post 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'?
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post by psychotomus »

is this time - 24 hours?

$timeout = time() - 86400; //24 hours
jrd
Forum Commoner
Posts: 53
Joined: Tue Mar 14, 2006 1:30 am

Post 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:
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post 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()
jrd
Forum Commoner
Posts: 53
Joined: Tue Mar 14, 2006 1:30 am

Post by jrd »

have you fixed it?
Post Reply