[PHP] Re: I am probably dumb but why isn't this inserting stuff into my DB?

2002-07-05 Thread JJ Harrison

Here it is then:

?
function tececo_stat_cookie(){
setcookie ('tececo_stats', '1');
}
// Browser Detection
 if( eregi((opera)
([0-9]{1,2}.[0-9]{1,3}){0,1},$_SERVER['HTTP_USER_AGENT'],$regs) ||
eregi((opera/)([0-9]{1,2}.[0-9]{1,3}){0,1},$_SERVER['HTTP_USER_AGENT'],$re
gs)){$browser = Opera $regs[2];}
 elseif(
eregi((konqueror)/([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$reg
s) ){$browser = Konqueror $regs[2];}
 elseif(
eregi((omniweb/)([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs)
 ){$browser = OmniWeb $regs[2];}
 elseif(
eregi((webtv/)([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs) )
{$browser = WebTV $regs[2];}
 elseif(
eregi((lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}),$_SERVER['HTTP_USER_AGENT'
],$regs) ){$browser = Lynx $regs[2];}
 elseif( eregi((links)
\(([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs) ){$browser =
Links $regs[2];}
 elseif( eregi((msie)
([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs) ){$browser =
MSIE $regs[2];}
 elseif(
eregi((netscape6)/(6.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs) ){$bro
wser = Netscape $regs[2];}
 elseif( eregi(mozilla/5,$_SERVER['HTTP_USER_AGENT']) ){$browser =
Netscape;}
 elseif(
eregi((mozilla)/([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs)
 ){$browser = Netscape $regs[2];}
 elseif( eregi(w3m,$_SERVER['HTTP_USER_AGENT']) ){$browser = w3m;}
 else{$browser = Unknown;}

// OS Detection
if(eregi(linux,$_SERVER['HTTP_USER_AGENT'])){$system = Linux;}
 elseif(eregi(win32,$_SERVER['HTTP_USER_AGENT'])){$system = Windows;}
 elseif(eregi(Win 9x 4.90,$_SERVER['HTTP_USER_AGENT'])){$system = Windows
Me;}
  elseif(eregi(windows 2000,$_SERVER['HTTP_USER_AGENT']) ||
eregi((windows nt)( ){0,1}(5.0),$_SERVER['HTTP_USER_AGENT']) ){$system =
Windows 2000;}
  elseif(eregi((windows
nt)( ){0,1}(5.1),$_SERVER['HTTP_USER_AGENT']) ){$system = Windows XP;}
 elseif( (eregi((win)([0-9]{2}),$_SERVER['HTTP_USER_AGENT'],$regs)) ||
(eregi((windows) ([0-9]{2}),$_SERVER['HTTP_USER_AGENT'],$regs)) ){$system
= Windows $regs[2];}

elseif(eregi((winnt)([0-9]{1,2}.[0-9]{1,2}){0,1},$_SERVER['HTTP_USER_AGENT
'],$regs) ){$system = Windows NT $regs[2];}
 elseif(eregi((windows
nt)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1},$_SERVER['HTTP_USER_AGENT'],$regs)
){$system = Windows NT $regs[3];}
 elseif(eregi(mac,$_SERVER['HTTP_USER_AGENT'])){$system = Macintosh;}
 elseif(eregi((sunos)
([0-9]{1,2}.[0-9]{1,2}){0,1},$_SERVER['HTTP_USER_AGENT'],$regs)){$system =
SunOS $regs[2];}
 elseif(eregi((beos)
r([0-9]{1,2}.[0-9]{1,2}){0,1},$_SERVER['HTTP_USER_AGENT'],$regs)){$system =
BeOS $regs[2];}
 elseif(eregi(freebsd,$_SERVER['HTTP_USER_AGENT'])){$system = FreeBSD;}
 elseif(eregi(openbsd,$_SERVER['HTTP_USER_AGENT'])){$system = OpenBSD;}
 elseif(eregi(irix,$_SERVER['HTTP_USER_AGENT'])){$system = IRIX;}
 elseif(eregi(os/2,$_SERVER['HTTP_USER_AGENT'])){$system = OS/2;}
 elseif(eregi(plan9,$_SERVER['HTTP_USER_AGENT'])){$system = Plan9;}
 elseif(eregi(unix,$_SERVER['HTTP_USER_AGENT']) ||
eregi(hp-ux,$_SERVER['HTTP_USER_AGENT']) ||
eregi(X11,$_SERVER['HTTP_USER_AGENT']) ){$system = Unix;}
 elseif(eregi(osf,$_SERVER['HTTP_USER_AGENT'])){$system = OSF;}
 else{$system = Unknown;}

// Referer Detection.
if(isset($_SERVER['HTTP_REFERER'])){
$referer = $_SERVER['HTTP_REFERER'];
} else {
$referer = $_SERVER['PHP_SELF'];
}

// Remote DNS name
$remote_dns = gethostbyaddr($_SERVER['REMOTE_HOST']);
$remote_ip  = $_SERVER['REMOTE_HOST'];
// Sets Current time
$time = time();

// Weather it is a person's first visit within session
if(isset($_COOKIE['tececo_stats'])){
$visited = '1';
} else {
$visited = '0';
tececo_stat_cookie();
}

$query = INSERT INTO tececo_stats values ('', $id, $visited, $time,
$remote_dns, $remote_ip, $referer, $browser, $system);
mysql_query($query);
?

JJ Harrison
[EMAIL PROTECTED]
www.tececo.com



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: I am probably dumb but why isn't this inserting stuff into my DB?

2002-07-05 Thread Jason Wong

On Saturday 06 July 2002 11:12, JJ Harrison wrote:
 Here it is then:

[snip]


 $query = INSERT INTO tececo_stats values ('', $id, $visited, $time,
 $remote_dns, $remote_ip, $referer, $browser, $system);

echo $query;

 mysql_query($query);

echo mysql_error();

And RFTM for examples on how to incorporate error checking in your db 
operations.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Any sufficiently advanced technology is indistinguishable from magic.
-- Arthur C. Clarke
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: I am probably dumb but why isn't this inserting stuff into my DB?

2002-07-05 Thread JJ Harrison

OK,

I have magic_quotes on though so useless lecture thanks for the advice


--
JJ Harrison
[EMAIL PROTECTED]
www.tececo.com

Miguel Cruz [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Sat, 6 Jul 2002, JJ Harrison wrote:
  $query = INSERT INTO tececo_stats values ('', $id, $visited, $time,
  $remote_dns, $remote_ip, $referer, $browser, $system);
  mysql_query($query);

 You should always do the following if you are having trouble:

 1) print out $query and try it yourself at the mysql command line.

 2) print mysql_error().

 In this case I think the problem is that you've failed to quote the
 strings in your INSERT. Try something like

   INSERT INTO tececo_stats values ('', '$id', '$visited', '$time' ...

 Also note that as it stands, I could potentially make big trouble for you
 by putting clever values into HTTP_REFERER (which is totally under my
 control as a visitor to your site). So make sure you mysql_escape_string
 or addslashes those values (unless you have magic_quotes turned on, in
 which case you can ignore this lecture).

 miguel





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: Re[2]: [PHP] Re: I am probably dumb but why isn't this inserting stuff into my DB?

2002-07-05 Thread JJ Harrison

I followed that part.

I just have magic_quotes on so I don't need to use addslashes/stripslashes



--
JJ Harrison
[EMAIL PROTECTED]
www.tececo.com

Julie Meloni [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 JH I have magic_quotes on though so useless lecture thanks for the advice

 Having magic_quotes on doesn't preclude your query from being invalid.
  You should still:

 JH Miguel Cruz [EMAIL PROTECTED] wrote in message:
  1) print out $query and try it yourself at the mysql command line.
 
  2) print mysql_error().

 Any time a query fails.


 - Julie

 -- Julie Meloni
 -- [EMAIL PROTECTED]
 -- www.thickbook.com

 Find Sams Teach Yourself MySQL in 24 Hours at
 http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php