usage of functions in mysql (n00b)

Discussion in 'MySQL' started by ycc, Apr 3, 2010.

  1. #1
    I want to compute one variable from another variable in the same table
    original variable is ip (varchar 50)
    variable to be computed is ip_aton (bigint)

    I seem to have opened the database correctly, the following statement executes OK (it is just a test without real meaning, it bumps counters for all ip).

    mysql_query("UPDATE $table_name SET visits=visits+1 WHERE 1=1;");
    Code (markup):
    However, when I try to compute the variable ip_aton, using the function INET_ATON I only get 0 in the column for ip_aton. I think I must have misunderstood how to use the function INET_ATON?

    mysql_query("UPDATE $table_name SET ip_aton=INET_ATON('ip') WHERE 1=1;") or die(mysql_error());
    Code (markup):
    Thanks
     
    Last edited: Apr 3, 2010
    ycc, Apr 3, 2010 IP
  2. ycc

    ycc Peon

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I apologise for beginner's mistake. I should not have single quotes around ip when calling the function.
    Thread solved

    Sorry.

    EDIT:
    mysql_query("UPDATE $table_name SET ip_aton=INET_ATON(ip) WHERE 1=1;") or die(mysql_error());
    Code (markup):
     
    ycc, Apr 4, 2010 IP