Results 1 to 4 of 4

Thread: problem using Now() in insert staetment

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    problem using Now() in insert staetment

    Hi all could any one tell me what is wrong with this sql statment it keeps giving error after i try to use Now function(No record entered).


    Fatal error: Call to undefined function: now() in /date2.php on line 49

    PHP Code:
    mysql_query("INSERT INTO visitor VALUES('$ID','$HTTP_X_FORWARDED_FOR',[B]'"NOW() ."'[/B],'$countryName','$country')"); 

    also i tried this and did not insert any records:

    PHP Code:
    mysql_query("INSERT INTO visitor VALUES('$ID','$HTTP_X_FORWARDED_FOR',[B]Now(),[/B]'$countryName','$country')"); 
    My intention is to record and output visitor information acording to date and time . I hope some one help me what i am doing wrong here .THanks


    PHP Code:
    SELECT FROM visitor ORDER BY date DESC 
    and date is stored in this format:
    PHP Code:
    date datetime NOT NULL default '0000-00-00 00:00:00'

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: problem using Now() in insert staetment

    now() is a SQL function, not a PHP one. Put it inside the quotes for the query.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: problem using Now() in insert staetment

    There's a whole bunch of MySql functions you can use to get the current date as well:

    http://dev.mysql.com/doc/refman/5.0/...functions.html

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: problem using Now() in insert staetment

    Use Time()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width