Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. howto insert ip address into mysql database

howto insert ip address into mysql database

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
databasehelpmysqlsysadminannouncement
3 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Parinay Bansal
    wrote on last edited by
    #1

    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

    J J 2 Replies Last reply
    0
    • P Parinay Bansal

      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

      J Offline
      J Offline
      jceresini
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • P Parinay Bansal

        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

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        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)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups