PHP Date problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg

    PHP Date problem

    On our companies website have have several pages that submit to a
    database that php provides the date automatically. One page, however,
    will not. This page is generated by a database search and have 5 fields
    that are added and then updated in the database. One of these fields is
    the date.

    <INPUT NAME="daterepai red" TYPE="text" VALUE="<?php echo date("M d,
    Y")" ?>; SIZE="15">

    This doesn't work. It displays a box with <?php echo date( in it. I
    have tried replacing " with ' with no difference. I'm beginning to
    think that it is because the page this is on is generated from a php
    search script. This code works for me on the other pages. Anyone have
    any suggestions or alternatives?

    Thanks for your help,

    Greg

  • Ewoud Dronkert

    #2
    Re: PHP Date problem

    Greg wrote:[color=blue]
    > <INPUT NAME="daterepai red" TYPE="text" VALUE="<?php echo date("M d,
    > Y")" ?>; SIZE="15">[/color]

    Switch the semi-colon with the double-quote before it.

    --
    Firefox Web Browser - Rediscover the web - http://getffox.com/
    Thunderbird E-mail and Newsgroups - http://gettbird.com/

    Comment

    • John Dunlop

      #3
      Re: PHP Date problem

      Greg wrote:
      [color=blue]
      > <INPUT NAME="daterepai red" TYPE="text" VALUE="<?php echo date("M d,
      > Y")" ?>; SIZE="15">
      >
      > This doesn't work. It displays a box with <?php echo date( in it.[/color]

      sounds like the file isn't PHP parsed.

      --
      Jock

      Comment

      • Greg

        #4
        Re: PHP Date problem

        Sorry, typo on my part. Below is how it is on the site.

        <input name="daterepai red" type="text" value="<?php echo date("M d,
        Y");?>" size="15">

        Would the fact that the page this is on being generated by a script
        have any effect on it?

        Thanks,

        Greg

        Comment

        • Ewoud Dronkert

          #5
          Re: PHP Date problem

          On 2 Jun 2005 16:36:48 -0700, Greg wrote:[color=blue]
          > Would the fact that the page this is on being generated by a script
          > have any effect on it?[/color]

          Sure. The script generates output, which is sent to the browser. The
          output is not magically scanned for php tags first. Instead of
          outputting php code from the script, output what the php code would.


          --
          Firefox Web Browser - Rediscover the web - http://getffox.com/
          Thunderbird E-mail and Newsgroups - http://gettbird.com/

          Comment

          • chotiwallah

            #6
            Re: PHP Date problem

            if your html line is actually generated by php (as you hint) than it
            should look like this

            print '<input name="daterepai red" type="text" value="'.date(" M d,
            Y").'" size="15">';

            result in the browser:
            <input name="daterepai red" type="text" value="Jun 03, 2005" size="15">

            micha

            Comment

            • Greg

              #7
              Re: PHP Date problem

              This did the trick. Thanks for your help.

              Comment

              Working...