1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Convert date value to string and merge it with another string

Discussion in 'PHP' started by eefh01, Aug 24, 2010.

  1. #1
    Hi,

    I have been breaking my head to solve this. May be this is very simple.

    I am trying to convert date value to string and to merge with another string.

    
    
    $dt=$_POST['formdate']; //$dt is in format of Y-m-d
    $msg = "The date entered is ".$dt;
    
    echo $msg;
    
    Code (markup):
    But it is printing $dt as blank. Please help me.

    Thanks in advance.

    Kiran
     
    Last edited: Aug 24, 2010
    eefh01, Aug 24, 2010 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    What does print_r($_POST) give you?
     
    nico_swd, Aug 24, 2010 IP
  3. eefh01

    eefh01 Member

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Thanks for responding. It prints normally as date format

    Array ( [formdate] => 2010-08-24 ...)


    //$dt is in format of Y-m-d (also edited in first post)

    Kiran
     
    eefh01, Aug 24, 2010 IP
  4. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #4
    This shouldn't happen. Either $_POST['formdate'] isn't passed correctly (check spelling of variable names) or you are changing it someplace (probably used an assignment state = instead of a checker ==).
     
    ThePHPMaster, Aug 24, 2010 IP
  5. eefh01

    eefh01 Member

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    Yes!! You are right ThePHPMaster. It's my mistake on using different variable. The problem arose as I use two forms on the same page. A quick check on the script resolved the issue.

    Thanks much

    Kiran
     
    eefh01, Aug 24, 2010 IP
  6. dfsweb

    dfsweb Active Member

    Messages:
    1,587
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    88
    #6
    This seems absolutely fine to me ... you don't need to convert numeric variables in PHP to a string in this case ... when you merge it, this is automatically done. Maybe the name of the cell "formdate" is not correct??
     
    dfsweb, Aug 24, 2010 IP
  7. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #7
    Look above.. the problem has been outlined and solved already.
     
    danx10, Aug 24, 2010 IP