Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP Date

  • 18-03-2004 9:58pm
    #1
    Closed Accounts Posts: 414 ✭✭


    Hey i am trying to get a date to write to my database from my form. In the form i am using drop down boxes so users can select their date of birth but all it is writing to my database is 0000-00-00, can anyone look at my code and tell me what im doing wrong.

    Thanks

    [PHP]
    <?php
    $hostname = "localhost";
    $username = "fitorfou_sleekfx"; // The username you created for this database.
    $password = "password1"; // The password you created for the username.
    $usertable = "date"; // The name of the table you made.
    $dbName = "fitorfou_fitorfoul"; // This is the name of the database you made.
    if ($submit):
    MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
    @mysql_select_db($dbName) or die( "Unable to select database");

    $sql = "INSERT INTO $usertable (date) VALUES ('$date')";

    if (mysql_query($sql)) { echo("<P>New Record Added</P>");
    } else {
    echo("<P>Error adding new record: " .
    mysql_error() . "</P>"); }
    ?>

    <P><A HREF="<?php echo($PHP_SELF); ?>">Add another record</A></P>
    <?php else: // Enter another record?>

    [/PHP]
    <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>


    <SELECT name=date> <OPTION value="" selected> <OPTION
    value=1>1<OPTION value=2>2<OPTION value=3>3<OPTION
    value=4>4<OPTION value=5>5<OPTION value=6>6<OPTION
    value=7>7<OPTION value=8>8<OPTION value=9>9<OPTION
    value=10>10<OPTION value=11>11<OPTION value=12>12</OPTION></SELECT>
    / <SELECT name=date> <OPTION value="" selected> <OPTION
    value=1>1<OPTION value=2>2<OPTION value=3>3<OPTION
    value=4>4<OPTION value=5>5<OPTION value=6>6<OPTION
    value=7>7<OPTION value=8>8<OPTION value=9>9<OPTION
    value=10>10<OPTION value=11>11<OPTION value=12>12<OPTION
    value=13>13<OPTION value=14>14<OPTION value=15>15<OPTION
    value=16>16<OPTION value=17>17<OPTION value=18>18<OPTION
    value=19>19<OPTION value=20>20<OPTION value=21>21<OPTION
    value=22>22<OPTION value=23>23<OPTION value=24>24<OPTION
    value=25>25<OPTION value=26>26<OPTION value=27>27<OPTION
    value=28>28<OPTION value=29>29<OPTION value=30>30<OPTION
    value=31>31</OPTION></SELECT> / <SELECT name=date> <OPTION
    value="" selected> <OPTION value=1985>1985<OPTION
    value=1984>1984<OPTION value=1983>1983<OPTION
    value=1982>1982<OPTION value=1981>1981<OPTION
    value=1980>1980<OPTION value=1979>1979<OPTION
    value=1978>1978<OPTION value=1977>1977<OPTION
    value=1976>1976<OPTION value=1975>1975<OPTION
    value=1974>1974<OPTION value=1973>1973<OPTION
    value=1972>1972<OPTION value=1971>1971<OPTION
    value=1970>1970<OPTION value=1969>1969<OPTION
    value=1968>1968<OPTION value=1967>1967<OPTION
    value=1966>1966<OPTION value=1965>1965<OPTION
    value=1964>1964<OPTION value=1963>1963<OPTION
    value=1962>1962<OPTION value=1961>1961<OPTION
    value=1960>1960<OPTION value=1959>1959<OPTION
    value=1958>1958<OPTION value=1957>1957<OPTION
    value=1956>1956<OPTION value=1955>1955<OPTION
    value=1954>1954<OPTION value=1953>1953<OPTION
    value=1952>1952<OPTION value=1951>1951<OPTION
    value=1950>1950<OPTION value=1949>1949<OPTION
    value=1948>1948<OPTION value=1947>1947<OPTION
    value=1946>1946<OPTION value=1945>1945<OPTION
    value=1944>1944<OPTION value=1943>1943<OPTION
    value=1942>1942<OPTION value=1941>1941<OPTION
    value=1940>1940<OPTION value=1939>1939<OPTION
    value=1938>1938<OPTION value=1937>1937<OPTION
    value=1936>1936<OPTION value=1935>1935<OPTION
    value=1934>1934<OPTION value=1933>1933<OPTION
    value=1932>1932<OPTION value=1931>1931<OPTION
    value=1930>1930<OPTION value=1929>1929<OPTION
    value=1928>1928<OPTION value=1927>1927<OPTION
    value=1926>1926<OPTION value=1925>1925<OPTION
    value=1924>1924<OPTION value=1923>1923<OPTION
    value=1922>1922<OPTION value=1921>1921<OPTION
    value=1920>1920<OPTION value=1919>1919<OPTION
    value=1918>1918<OPTION value=1917>1917<OPTION
    value=1916>1916<OPTION value=1915>1915<OPTION
    value=1914>1914<OPTION value=1913>1913<OPTION
    value=1912>1912<OPTION value=1911>1911<OPTION
    value=1910>1910<OPTION value=1909>1909<OPTION
    value=1908>1908<OPTION value=1907>1907<OPTION
    value=1906>1906<OPTION value=1905>1905<OPTION
    value=1904>1904<OPTION value=1903>1903<OPTION
    value=1902>1902<OPTION value=1901>1901<OPTION
    value=1900>1900</OPTION></SELECT>
    <br>


    <br>

    <INPUT TYPE=SUBMIT NAME="submit" VALUE="SUBMIT">
    </FORM>
    <?php endif; ?>


Comments

  • Registered Users, Registered Users 2 Posts: 944 ✭✭✭nahdoic


    you're calling the 3 fields date

    then passing a $date into the database.

    You need a month, day and year field and then pass '$year-$month-$day' into the database.


Advertisement