howto insert ip address into mysql database
-
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, line 1. Client 10.168.1.2:3720 says: 11111::1100::login please help me
-
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, 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
-
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, line 1. Client 10.168.1.2:3720 says: 11111::1100::login please help me
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)