|
If you want to use a varible thats declared outside of a function, from within the function you will need to declare it in the function. For example, with the following code:
$var = "asdf";
function printVar1(){
echo $var;
}
function printVar2(){
global $var;
echo $var;
}
Joe Ceresini
Network Engineer
jceresini@hostmysite.com
Hostmysite.com
|
|
|
|
|
i am doing
$sth = $dbh->prepare("insert into loginout values ($ref->{'CARD_ID'}, '$name' , now(), NULL");
but keep getting the following error.
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at ./iothread.pl line 92, <gen1> line 1.
Client 10.168.1.2:3720 says: 11111::1100::login
please help me
|
|
|
|
|
You may want to try printing out the value of
"insert into loginout values ($ref->{'CARD_ID'}, '$name' , now(), NULL"
to see make sure the variables are set properly and that $ref->{'CARD_ID'} is not null, and not a string. Also check that $name does not contain any single quotes in it as that will screw up the query, unless you escaped the variable first. Finally the end of the values does not have a ending parenthesis. It should be:
"insert into loginout values ($ref->{'CARD_ID'}, '$name' , now(), NULL)"
Joe Ceresini
Network Engineer
jceresini@hostmysite.com
Hostmysite.com
|
|
|
|
|
Parinay Bansal wrote: $sth = $dbh->prepare("insert into loginout values ($ref->{'CARD_ID'}, '$name' , now(), NULL");
It is missing a closing paren. Could be something else wrong too.
As a note in my experience it has been considered a best practice to explicitly name fields. The advantage to that is that it allows the database itself to be changed without impacting code.
So rather than
insert into mytable values(x,y)
use
insert into mytable(col1, col2) values(x,y)
|
|
|
|
|
hi
i am getting error as:
Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, <gen1> line 1.
during runtime
and
the output looks like this:
Multiplex server running on port 4444...
Created thread 1 for new client 10.168.1.2:3233
Use of uninitialized value $_ in scalar chomp at ./iothread.pl line 66, <gen1> line 1.
1005874632400418
1234
login
Use of uninitialized value in concatenation (.) or string at ./iothread.pl line 86, <gen1> line 1.
10895
Thread 1 terminated abnormally: Not a CODE reference at ./iothread.pl line 87, <gen1> line 1.
#!/usr/bin/perl
# iothreadserv.pl
use warnings;
use strict;
use integer;
BEGIN
{
use Config;
die "No thread support!\n" unless $Config{'usethreads'};
}
use Thread;
use IO::Socket;
use DBI;
use DBD::mysql;
# Autoflushing on
$| = 1;
my $port = 4444;
my $server = IO::Socket->new(
Domain => PF_INET,
Proto => 'tcp',
LocalPort => $port,
Listen => SOMAXCONN,
Reuse => 1,
);
die "Bind failed: $!\n" unless $server;
print "Multiplex server running on port $port...\n";
while (my $connection = $server->accept)
{
my $name = $connection->peerhost;
my $port = $connection->peerport;
my $thread = new Thread(\&connection, $connection, $name, $port);
print "Created thread ",$thread->tid," for new client $name:$port\n";
$thread->detach;
}
exit;
# child thread - handle connection
sub connection
{
my ($connection, $name, $port) = @_;
$connection->autoflush(1);
#############################my sql connect###############################
my $platform = "mysql";
my $database = "project";
#my $host = "localhost";
#my $port = "3306";
my $user = "root";
my $pw = "";
# DATA SOURCE NAME
my $dsn = "dbi:mysql:$database";
# PERL DBI CONNECT
my $dbh = DBI->connect($dsn, $user, $pw) or die "cannot connect to database";
#######################################################################33
print $connection "You're connected to the server!\n";
my $client = <$connection>;
chomp; # ($client);
#while (<$connection>) {
if ($client =~ /::login/)
{
print $connection "Login Initiated\n";
my $rand = int(rand(100000));
print $connection "Your rand number : $rand";
#$client =~ s/([\$\@\\])/\\$1/mg; ##escape all $, @ and \
#$client = quotemeta $client;
my @recv_string = split /::/ , $client;
foreach (@recv_string)
{
print "$_ \n";
}
#next line injection possible !! REMOVE IT!!
my $sth = $dbh->prepare("select * from Temp_ID where TEMP_NO = $recv_string[0]");
$sth->execute();
#take only one output row
my $ref = $sth->fetchrow_hashref();
# $sth->finish();
print "$ref->{'Temp_ID'} $ref->{'CARD_ID'}\n";
$sth = $dbh->("select PIN from Cards where Card_ID = $ref->{CARD_ID}");
$sth->execute();
# $sth->finish();
my $ref2 = $sth->fetchrow_hashref();
if ($recv_string[1] eq $ref2->{PIN})
{
print $connection "PIN verified OK";
}
}
if ($client =~ /:logout/)
{
print $connection "You are being Logged OUT\n";
}
print "Client $name:$port says: $client \n";
print $connection "Message received OK\n";
# }
$dbh->disconnect;
$connection->shutdown(SHUT_RDWR);
}
|
|
|
|
|
|
Is this still open? It was posted a while ago.
If so, to get started, what are some of the other data points?
1. does "You're connected ...\n"; print?
2. have you tried to insert a print statement before the chomp to see what is in $_;
3. have you tried to put something in $_ to see if the error is suppressed.
4. is there anything in $ref before the print of its fields?
5. does a visual inspection of the MySQL database with your database admin tools show that row should exist?
6. what about some logic to catch this before it croaks?
5. have you tried the Perl debugger with -d on the script. As you know it has watch and break features. If it is web app you may still get enough from running it in console mode.
dpminusa
"Coding for fun and profit ... mostly fun"
|
|
|
|
|
Hi Friends,
I just saw a company from India, www.shrishtionline.com They can offer complete web solution to all.
Shrishti Informatics is a Professional Outsource Website Design & Development company based in
Cochin, India. They are experts in website design, dynamic web solutions, Multimedia and
Graphics Design, Search Engine Optimization ,offshore staffing and offshore outsourcing .
Also does customization of open source technologies such as osCommerce, Joomla, phpBB,CRE Loaded,
phpFoX, WordPress etc.make use of this great time and create your personal and business site now.
Will post more valuable news latter. Really would like to know your thoughts regarding this company.
Regards,
Mechele peters.
|
|
|
|
|
Fuck off, No one cares about your shit site.
|
|
|
|
|
You really want to know my thoughts? Do you really? Do you really want to take a look into my disturbing mind, or are you just a moronic troll who should be removed from the vicinity of a keyboard for the benefit of all involved? Look - do you really think we are so stupid that we wouldn't realise you had something to do with this company? Seriously, if you want to advertise the company then pay for a f***ing advert. The fact that you've treated people like idiots means that we will want nothing to do with your company because you are so unprofessional.
|
|
|
|
|
hello frens, i am doing project which related to apriori algorithm in php...
really need helps from u all.....
thanks
|
|
|
|
|
Amazing, not a single question. I reread it even to double check, and nothing. Caput. Finito. Zilch.
|
|
|
|
|
chin4186 wrote: really need helps from u all
With almost 6 million CodeProject members, when will you read all our replies?
Wouldn't it be more efficient to do a little Google search and visit and read say the first 10 links it comes up with?
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
|
Get your tabula rasa ready:
<html>
<body>
<?= echo "<h1>I compile, therefore I am</h1>" ?>
</body>
</html>
Hope I didn't blow any circuits
|
|
|
|
|
Hi all,
How to call by reference in python?
example:
def A(a):
a = 1
b = 3
A(b)
print b
=> 3
Anyway has any suggestion? or does python support call by reference?
Thanks
|
|
|
|
|
The general Python community frowns on this approach. They practice a more functional-programming style that leaves parameters unscathed. No side effects to methods, MorrisLin. So, no one would recommend that style of programming, opting for the following in its stead.
"color: rgba(0, 0, 255, 1)">return 1
b = 3
b = ReturnOne()
^__b style="color:blue">print b
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Thanks for your reply , Curtis.
|
|
|
|
|
|
Are you here only to advertise a site?
|
|
|
|
|
You have got a problem with that?
Aditya
|
|
|
|
|
|
Regarding the question that i had submitted, it was a serious problem that i was facing and could not find anything on internet!!
Ok, if you are admin of this website, delete me from your users list. i wont login here again.
Aditya
Aditya
|
|
|
|
|
hi....
is yahoo messenger is deeveloped with python......
??
|
|
|
|
|
Hi all
Using zend framework how to create multiple checkbox?
Can any one tell me
Thanks in advance,
rose
|
|
|
|