|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need Help With DATE Function
I've created a MySQL table that I can preview on a webpage with PHP. It seems to be generally OK, but there are a few problems I need to fix. One regards the date.
The dates that are already logged in - like 1888-24-10 - work just fine. But if I try to add a row with an input form I created (with the help of a Codewalkers tutorial), the date field records 0000-00-00, regardless of what I type in. I can type in 1969-24-15 or MyName, and I get the same result. I can think of two possible problems. Until I get a better handle on this stuff, I have to use two programs to create my tables - phpMyAdmin and EMS MySQL Manager. More precisely, I create the table with EMS, then modify it in phpMyAdmin. I won't go into all the details. I described it more thoroughly at http://geowebworks.geobop.org/test/phpmyadmin/index.php (Scroll down to #3). But I thought that, whatever the problem is, I could probably fix it with phpMyAdmin. Any tips? Thanks. |
|
#2
|
|||
|
|||
|
RE: Need Help With DATE Function
what happens if you set it to not null?
|
|
#3
|
|||
|
|||
|
RE: RE: Need Help With DATE Function
Quote:
Aha - you nailed it! I just entered my first valid date. It looks like, there may have been two or three problems, as I suspected, because the input form still isn't working as it should. I still haven't really figured out the parameters, but it seems to choke on too many characters, and it gets "stuck" if one row gets screwed up. For example, I might be able to type some words and numbers into the fields and create a new row, but I can't create a second row unless I do something stupid - like type xx into every single cell. Then it works, with the date defaulting to 0000-00-00. I can sometimes create another row by typing a name into the first cell. The new row features the name and default date (0000-00-00), but every other cell is blank, of course. If I try typing words into the first TWO cells of another row, nothing happens. But I'm getting closer. Thanks for your help. |
|
#4
|
|||||
|
|||||
|
RE: Need Help With DATE Function
i had the same problem today...
if you can post your code we could help you more... php Code:
that is my basic input... make sure your time value is: NOW() and not: 'NOW()' not sure if thats right, but thats what i did to fix my error. |
|
#5
|
|||
|
|||
|
RE: Need Help With DATE Function
What he is trying to do is not a timestamp. He is inserting a birthday in the form of a mysql date, manually typing it in.
Edit: Try echoing the output of the query string without having it query the database, so we can check the query syntax. |
|
#6
|
|||||
|
|||||
|
RE: RE: Need Help With DATE Function
"Edit: Try echoing the output of the query string without having it query the database, so we can check the query syntax."
Hmmmm... This is still Greek to me; I don't know how to identify a "query string," echo its output or detaching it from the database. I've so far managed to create two input forms, one of which just yields a URL, like this: http://localhost/geowebworks/php/input.php?Name=South+Dakota&Capital=Pierre&Birthday=1888-13-12&Rank=37&Origin=Dakota+Territory&Code=SD&Country=U.S.&submit=+Enter+information But it sounds like you're asking me to do something with the other input form, presumably by changing the code: php Code:
|
|
#7
|
|||||
|
|||||
|
RE: Need Help With DATE Function
When we ask you to echo your query string this is what we mean:
You have built an SQL statement, in this case $sql It is this: $sql = "INSERT INTO states (Name, Capital, Birthday, Rank, Origin, Code, Country) VALUES ('".$_POST['Name']."', '".$_POST['Capital']."', '".$_POST['Birthday']."', '".$_POST['Rank']."', '".$_POST['Origin']."', '".$_POST['Code']."', '".$_POST['Country']."')"; When we say to echo the statement, we want you to place: echo $sql; after the variable to put it under test. Modify your code like this temporarily to make this happen: php Code:
This is part of the debugging process so we can see what the query looks like that is going into the database. Please post what the echo returns. |
|
#8
|
|||
|
|||
|
RE: Need Help With DATE Function
oh ok... i was confused.. but that helps me out too for future databases
|
|
#9
|
|||||
|
|||||
|
RE: Need Help With DATE Function
I probably butchered it, but this is what I ended up with:
php Code:
When I preview it, I get the error message " Parse error: parse error, unexpected $end in C:sitesgeowebworksphpinput.php on line 15" |
|
#10
|
|||
|
|||
|
RE: Need Help With DATE Function
just make those changes I showed you. Dont take anything off of the current script. This is exaclty what you should have: php Code:
|