User Control Panel
Advertisements

HELP US, HELP YOU!

how to select data in database with valid of romote_addr

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl
View unanswered posts
Author Message
littlestar
Newbie
Newbie


Joined: 23 Aug 2005
Posts: 4

Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7

PostPosted: Wed Aug 24, 2005 2:29 am    Post subject: how to select data in database with valid of romote_addr Reply with quote

I'm learning Perl. and I have a question, hope you can support for me

I get ip address of my computer. It has valid.
But I can't select query from database with this valid. It has error.
There is some thing which I want to say

#-------------------------------------------------------------------

my use strict;
use lib ".";
require "CGI.pl";

use vars qw(
$vars
);

# Check whether or not the user is logged in and, if so, set the $::userid
use Test::Constants;
Test->login(LOGIN_OPTIONAL);

my $ipaddr = $ENV{'REMOTE_ADDR'};
# print $ipaddr; --> output: 192.168.5.113

SendSQL("SELECT * FROM language WHERE ippaddr = '$ipaddr'");
#this query can't select, it has error :

#Insecure dependency in parameter 1 of DBI::db=HASH(0x91bbd4c)
#->prepare method call while running with -T switch at Bugzilla/DB.pm line 60

#-----------------------------------------------------
#if I use this how, it's OK.

#$ipaddr = '192.168.5.113';
#SendSQL("SELECT * FROM language WHERE ippaddr = '$ipaddr'");
#------------------------------------------------------

# Return the appropriate HTTP response headers.
my $cgi = Test->cgi;
print $cgi->header();

# Generate and return the UI (HTML page) from the appropriate template.
my $template = Test->template;

$template->process("index.html.tmpl", $vars)
|| ThrowTemplateError($template->error());

#-------------------------------------------------------

I can't understand why, please help me
Back to top
eric256
The Keymaker
The Keymaker


Joined: 03 May 2006
Posts: 2292
Location: Colorado
Reputation: 47Reputation: 47Reputation: 47Reputation: 47Reputation: 47

PostPosted: Wed Aug 24, 2005 4:01 am    Post subject: Reply with quote

First line should be
use strict;
not
my use strict;


Since I have no idea what SendSQL does it is hard to say what your problem is. Generaly it is a bad idea to embed a variable in a query. Instead you should use place holders. If you where using DBI then it would look like

Code:
my $sql = $dbh->prepare("SELECT * FROM language WHERE ippaddr = ?");
$sql->execute($ipaddr);


The error you are getting suggests that Taint mode is on. This means that any variable obtained from outside need to be untainted before they can be used. I am no expert at untainting so it would probably be best if you talk to whoever wrote your CGI.pl.... I'm assuming that is where SendSQL originates from.

_________________
Eric256
Proud previous owner and current admin of Bot-depot.com
Back to top
littlestar
Newbie
Newbie


Joined: 23 Aug 2005
Posts: 4

Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7Reputation: 8.7

PostPosted: Wed Aug 24, 2005 7:33 am    Post subject: Reply with quote

Thanks eric256, but... I can't still do it with your way. It's here:

Code:

my $ipaddr = $ENV{'REMOTE_ADDR'};
#print $ipaddr ->output sucessful (example:"192.168.5.100")
my $sql = $dbh->prepare("SELECT * FROM language WHERE ipaddr = ?");
$sql->execute($ipaddr);


but, it have error:
Insecure dependency in parameter 1 of DBI::st=HASH(0x887df28)->execute method call while running with -T switch at /var/www/html/test/index.cgi line 67.


if I use this way, it's ok
Code:

my $ipaddr = '192.168.5.100';
my $sql = $dbh->prepare("SELECT * FROM language WHERE ipaddr = ?");
$sql->execute($ipaddr);


hiz hiz.... I'm helpless
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group