Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




MYSQL Date Entry Shows 0000-00-00


i want the user to type in the date. Everything works fine and the form submits. When i open the database and query the results, the date field shows only 0000-00-00. It doesn't show the date entered (ex 05/23/07). What am i doing wrong?

I'm thinking it has to do something with converting the string to a date? If so, how do i do that in PHP.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Date Field In Database Shows 0000-00-00 00:00:00
i have the following in my list of variables (partial list):

$id = $_POST['id'];
$name = $_POST['name'];
$date = date("D, d M yyyy, h:ia T");

and my connection includes:
$sqlquery = "INSERT INTO $table VALUES('$id','$name','$date')";

all other values are posting except the date.

in the mysql database, the date field is set up as follows:

Field Type Null Default
date timestamp Yes CURRENT_TIMESTAMP

my objective is simply to add a date field with the current date and time. i want mysql to insert the date for me in the format resulting in this type of output:

Fri, 19 Aug 2005, 10:23am CST. i just wasn't sure whether i was supposed to
include the date variable or not.

'datetime' Shows Only '0000-00-00 00:00:00'
I currently have a form set up on a site to send data entered into a database.
Now, the form submits correctly, the data is stored in the database correctly,
but the 'datetime' shows up as '0000-00-00 00:00:00' in each record.

I set the datetime variable to 'not null' and when I update the table, it sets the
default value to '0000-00-00 00:00:00'. Am I forgetting to set something or
where and how does the form get that date and time info?

Curdate() Is 0000-00-00 For New Entry
I have a web form that users submit information through and it gets stored in a MySQL table. I wanted to capture the "creation date" of the record. So, I do the following:

1) I connect to the database and ask for the curdate() assigning it to a variable.
2) Then I turn around and store the user input into the table along with the curdate() variable that I first retrieved.

However, I just noticed something while still testing this. If I drop/add the table, the first entry always retrieves a curdate() of 0000-00-00. And this is a issue as I later allow users to retrieve these records based upon their creation dates. So, the first one will be lost.

Why is the first record recording 0000-00-00? The table exists even without any data in it. And, how do I get around this?

Problem With 0000-00-00 In 'Date' Field ?
I have a field in a table called 'ShipDate'. This particular field has allow null set to no. So by default this sets all the records to show 00/00/0000 in the field for each record that has no data entered.

In my .asp pages I am trying to test against this empty field.

i.e.

If RS("ShipDate") = 0000-00-00
or
If RS("ShipDate") = 00/00/0000

The only thing that seems to work is if I am testing for records with
a date in that field,

If RS("ShipDate") > 0000-00-00

How can I test if that field is empty ?, nothing seems to work ?

Date Field Saved As 0000-00-00
I have a table with a field type date and null is set to yes. How can I insert a blank value without it being save as 0000-00-00.

Problem With 0000-00-00 In 'Date' Field ?
I have a field in a table called 'ShipDate'. This particular field has allow null set to no. So by default this sets all the records to show 00/00/0000 in the field for each record that has no data entered.

In my .asp pages I am trying to test against this empty field.

i.e.

If RS("ShipDate") = 0000-00-00
or
If RS("ShipDate") = 00/00/0000

The only thing that seems to work is if I am testing for records with
a date in that field,

If RS("ShipDate") > 0000-00-00

How can I test if that field is empty ?, nothing seems to work ?

Latest Date Entry + Future Date
My requirement is data to be added to database depending on dates. Like If the user wants to add data for the next 10 days,the data should be added with a corresponding column containing the next 10 days' dates.

Then if he logs in tomorrow and wishes to add data for another 100 days,it should find the last date added and then add data with the next 100 dates starting from that date.

Also I would want to display these dates to the user.So can you suggest which type to be used for database field and also the date functions(mysql as well as php) to be achieved.

Let me put it more clearly.

"select the last date(which might be future dates) entered in the database";

If the date is Oct10 and the user wants to add entries for Oct 11,12 13

"insert into table values('data','oct11')"
......
......
likewise for Oct12 and 13

The format I need is just year,month and day.No time is required.

Auto Date Entry
Is there a way to have a date automatically entered into a form, so the user does not always have to add it manually? What table Type do I use? I see a TIMESTAMP, but no DATESTAMP.

Selecting The Latest Date Entry
Basically I have a table containing these 4 fields
selection_ID - user_ID - visit_date (date field) - period_of_day

All I want to do is select one row - the one with the most recent visit_date for a particular user_ID.

I am using mySql 4.0.22 (so NESTED SELECT doesn't work).

I understand that there is a MAX function for getting the latest date but this seems to require GROUP BY, and I don't require a group of results.

I have vainly been trying things like this:

SELECT selection_ID, user_ID, visit_date, period_of_day FROM visits WHERE visit_date = visits.MAX(visit_date)

Selecting A Entry Within A Date Range
I have a MySQL database with 5 columns called Name, Model, Colour, Date_From, Date_To.
Basically I want the user to specify the name and a date and want it to return the corresponding entry whose matches the name and within Date_From and Date_To.

I wanted to use the date format dd-mm-yy so ive used VARCHAR. This is what ive done of which the date range doesnt work.

SELECT Name, Model, Colour, Date, Date_From, Date_To FROM Cars WHERE Name='$Name' AND '$Date BETWEEN Date_To AND Date_From'

Grouping Entries By Entry Date And Parent ID
With tables:

'Category' comprised of (and containing e.g.)
----------------------------------
categoryId | title | description
----------------------------------
1 | Animals | Different kinds of animals.
2 | Cars | I love cars.

and
'Subject' comprised of (and containing e.g.)
-----------------------------------------------
subjectId | categoryId | title | description
-----------------------------------------------
1 | 1 | Welfare | Something about animal welfare.
2 | 2 | Engine | Something about the engines of cars.

and
'Issue' comprised of (and containing e.g.)
-------------------------------------------------------------------
issueId | subjectId | parentId | status | entryDate | text
-------------------------------------------------------------------
1 | 1 | 1 | Not done | 2007-01-12 10:00 | Feed my dog.
2 | 1 | 1 | Done | 2007-01-12 10:05 | Feed my dog Alex.
3 | 1 | 3 | Done | 2007-01-13 11:00 | Feed my cat.
4 | 2 | 4 | Done | 2007-01-14 12:00 | Get new engine.


I would like to do a SELECT which will join these three tables, and give me the following result.
-------------------------------------------------------------
catTitle | subjTitle | issueText | status | entryDate
-------------------------------------------------------------
Animals | Welfare | Feed my dog Alex. | Done | 2007-01-12 10:05
Animals | Welfare | Feed my cat. | Done | 2007-01-13 11:00
Cars | Engine | Get new engine. | Done | 2007-01-14 12:00

Note how the newest entry of issues with the same parentId overwrites the ealier entries with the same parentId.
This is because I would like to keep some log of what has happened in the database, when I for example updates the dog-feeding situation from "not done" to "done".

What does my SELECT look like to accomplish this?

NB: Copy/paste this into a word editor and use a monospace font for optimal rendition.

MySQL Only Shows Homepage
I have a problem concerning MySQL and Apache. I host a Fedora server with Apache, MySQL and PHP installed. A customer has a webpage that uses MySQL but for some reason I can't get any other pages than the homepage up when I click on other links, I just come back to the homepage. The URL displays the other link but it still stays the same. Code:

0000 Turns To 0 With INT
Okay I need an id that is 4 (four) digit id but when I put 0000 its turns to 0 how to I avoid this.

How Do You Enter An Entry With A Newline Inside The Entry?
I'm trying to enter an entry into the table. However, my entries must have newlines inside each entry. Further more, i'm trying to do this from an excel file(ie. first by saving it to a text file and then using LOAD DATA INFILE..).

Automatically Record Date Of Record Entry
I have my database table set up and I have an HTML form that is PHP driven that will add the information entered into the form into to my database table.

I have a local buy-sell-trade Website. The way it has worked is that people fill out a form and the results emailed to me. I then take the information and enter it into a Web page. I only want the ads to be displayed for 30 days. I keep the ad for a total of 6 weeks (displays for 30 days and sits in limbo for 2 weeks afterwords) and if not renewed within that 2 week limbo period - I delete it.

Entering all the ads and keeping up with the dates manually has become a burden. I've only recently began looking into databases. My hosting company provides me with phpmyadmin and mysql 5.0. I'm new to all of this but I have managed to set up a database table and a HTML form that is PHP driven that allows ads to be automatically added to the database table.

There is a lot I need to do to make this ideal, but one step at a time.

First, I need to know the date (March 02, 2006) the ad was created or added to the database table. I know that I need to add some piece of code to my php form to record this information, but what code and where do I put it? I know I will need to create an extra field in my database table to house the date - I can handle this.

I've read the date and time information here http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

but there's a lot there and I don't know which is right for my needs. Plus, it doesn't tell me how or where to insert it into my php form (or does it?).

0000-00-00 00:00:00 Format Related Question ...
I am trying to count number of rows by month and year. In the mysql db, I am recording data as NOW(), means 0000-00-00 00:00:00 format.

7e2 Shows Up As 7.00E+02
I have value that I'm adding to a table via an insert statement. The value is "7e2", but for some reason is being converted to scientific notation on the insert "7.00E+02". I have quotes around the field as well. If you look at the insert statement below, it's "question" field. Anyone know of a way to force it to be a string?


$sql = "INSERT INTO ICI_ANSWERS (session_id, scale_id, question, answer, date_stamp) VALUES ('" . $piece . $data[0] . "', " . $data[1] . ", '" . $data[2] . "', '" . $data[3] . "', '" . $data[4] . "')";

Opened_tables Always Shows Zero
When I log into any of our db servers, go into mysql on the command line, and do a 'show status', the value of Opened_tables is always showing 0.

However, when I log into mysql via the MySQL Administrator and look under Health-->Status Variables it shows a value.

Any idea why it's always showing zero when I do it from within mysql on the command line? It's happening on multiple servers.

Querying Only Shows 3 Columns
I have a mysql database set up with 20 columns but when querying the database only get 3 columns listed. The code i am using is as follows.
// connect to server, database, table.
include ("db_connect.inc");
SQL-query:
$sql = 'SELECT * FROM `signups` ORDER BY `title` ASC LIMIT 0, 30';

Is there a problem with my coding or the database itself? and what are the fixes for this problem?

Error Shows The E-mail @ Sign..?
I am gettin an error msg when trying to enter my newsletter registration details to the database.

function process_nl($id) {
$name=$_POST['txtname'];
$email=$_POST['txtemail'];
$SQL = "INSERT INTO nletter (name, email) VALUES ($name, $email)";
if(mysql_query($SQL,$id)) {
return true;
exit;
}
else
return false;
}

error:
You have an error in your SQL syntax near '@yahoo.com)' at line 1

Phpmyadmin Shows ???? Of Korean Data
My machine is windows xp sp2 with Apache HTTPD 2.2.0, MySQL 5.0.18, PHP 4.4.1 pl1 phpMyAdmin 2.7.0-pl1.

And the settings of apm is;

1) httpd.conf
DefaultLanguage ko

2) php.ini
default_mimetype = "text/html"
;default_charset = "iso-8859-1"
;default_charset ="utf-8"
;efault_charset = "euc-kr"

3) my.inf
[mysqld]
character-set-server = utf8
collation-server = utf8_general_ci

On my test site, I can see right Korean data.
But on phpmyadmin I can see only ???? for Korean data.

Musql Dump Shows Error
I am trying to backing up a databse .

I open the command promt form start > run;
i wrote the command "mysqldump --opt kimberly > backup.sql"
kimberly = database name;

the error comes out :

mysqldump: Got error: 1045: Access denied for user 'ODBC'@'localhost' (using password: NO) when trying to connect

Arabic Character Encoding Problem (shows Just ????????)
i have a problem and i did not found a solution untill now and i hope i found it here.
when i try to enter the arabic characters throw the browser to the mysql DB using phpmyadmin it does not enter the arabic characters but strange characters
but when i fetch the data to the browsers it shows the characters in arabic.
(the is the first problem)

the other problem is ...
when i write directly to the phpmyadmin in arabic it shows me the arabic characters inside phpmyadmin and when i fetch dhe data to the browsers it shows to me only question marks ??????????????????.
#########################
inserting throw browsers = displaying ok in browsers but not ok in phpmyadmin
inserting throw phpmyadmin = displaying ok in phpmyadmin but ???????? in browsers
##########################


Query Log Shows 12+ Attempts To Connect Every Minute
I have mysql-4.0.20a-nt running on windows 2000. I had trouble connecting from a different computer in my home network so I set the following in my.ini:

set-variable=log=mysql.log

At startup I get the mysql.log file in the data directory. Upon inspection it shows a lot of connect commands, at least 12 every minute, with some 10 seconds in between, they come in pairs, first as ODBC@localhost with no password, and second as user@localhost with a password set. Access seems to be denied every time. Here's a snippet from the file:

MySql, Version: 4.0.20a-nt-log, started with:
TCP Port: 3306, Named Pipe: MySQL
Time Id Command Argument
050320 20:38:08 1 Connect Access denied for user: 'user@localhost' (Using password: YES) ....

Command SHOW SLAVE STATUS G, Shows That SLAVE_IO_RUNNING
I am trying to set up a master/slave replication.. I followed the instructions in the mysql manual.. I am using mysql 4.0.12 installed in windows xp... I have found out that the replication is not working ...

when i make the command SHOW SLAVE STATUS G, it shows that SLAVE_IO_RUNNING : No.
How can I make this run? What could have I done wrong?

Mysqld Shows High Cpu Usage Over Extended Time, Restart = Normal
Occasionally in checking one of the servers, I noticed that mysql shows 85% + of
cpu usage essentially leaving the server at 0% idle. After monitoring it for a
few hours, the status did not change. After a stop and start of mysql, things
progessed normally. Checking back a few days later I noticed it was once again
sitting up there at 95% (or thereabouts) and doing nothing of value from what i
could tell.

Have restarted MySQL during peak usage times for that server and its database,
and it has showed normal loads and CPU usage (approx 20% CPU with .1 to .3
load). Is there a known issue (running on FreeBSD 4.8, MySQL 3.23.55 MyISAM)?
Is there something I should check when next I notice the high CPU usage?

Mysql, 2nd Highest Entry
how to pick 2nd highest entry from any table in mysql database??
for highest entry i can go by order by desc clause
well limit 0,2 can give me 2 highest entries
but what if i want only 2nd highest entry
any help would be gr8ly appreciated



Retrieve MySQL Entry &
does anyone know a way how to do the following:
Use PHP maybe to retrieve a database entry from MySQL (Song Name) and set MSN Messenger's Personal Message (Or Display Name) to the Song Name?

Getting A '> Sign While Creating A Mysql Entry..
While trying to enter data into a table with mysql the continue on next line prompt changed from a -> to a '> which a semicolon will not seem to escape from.... Is there a simple solution?...

MySQL Question: Duplicate Entry '*****' For Key
I'm trying to make a backup copy of some table, but I keep getting the following error:

Data Entry Client For MySQL
I need a terminal (client) to connect to the server to enter data and view tables (as customised reports). ie this is not for administrating the database, this will be for an end-user.

I dont want to use a web browser, I want to use something like a terminal. It can be of simple blue screen DOS, AS400 like nature.

MySQL SELECT Table From $_POST Entry?
Is it possible to use the results of $_POST['selectTable'] from a dynamically populated drop down menu to specify the table in a MySQL SELECT query?

I want to get the user of my webpage to select which database table to use from a menu before I make a connection to the database table and retrieve the information I need. I'm assuming this is best done over two pages or using an IF ELSE routine?

MySQL Entry Level Server Hardware Configuration
We have a web site statistics database running on a dedicated PC (P4 1GB RAM, 1xSATA, Windows Xp 32 bit). It's updated daily and used by a single user to get some reports. While it's mostly SELECTs, some temporary tables can be built.

As the database get bigger and bigger (few gigabytes), it works slower and slower. Currently the HDD is the bottleneck, but the PC is not upgradeable, so I'll have to build a new server. Reliability is NOT #1 in my list, while the speed is - it'd be easier (and chipper) for me to copy the data across rather than to build a 4+ dsik monsters.

What would be the suggestions for hardware and OS? Or may be a URL to detailed review?

Passing Date Via Form For Mysql Date Type
I've created a database for tracking our paper inventory. Basically when an individual takes paper, or envelopes the quantity is entered into the database, along with some other items. This all works great.

I also have two fields that use the "Date" and "Time" types for holding the date and time of the initial transaction.

I've created a seperate php script that we will use for our "end of month" reports. The script goes through and adds up the cost of each "purchase" between a specified time frame (1 may thru 31 may for example).

This script works for me as long as I perform my query with my condition formated as such:

INSERT Non-MySQL Date Into MySQL Date Field
I have a non-MySQL database that has a date value that is an integer value (4 byte unsigned integer representing the number of days since 1904, ie 01/01/2000 = 35063)

Do I need to re-format this to use in an SQL to INSERT it into a MySQL table?

If I do need to reformat it, what is the best format to use.

Last Entry
When i view tables and rows in phpmyadmin, the latest entry (albeit the higher ID number) is on top. Does it work that way inthe internals of mysql? If I select 10 rows with a limit of 10, will i get the latest inserts (assuming the last row id was 49, 49 48 47 46 45... instead of 1,2,3... )?

Duplicate Entry For Key 1
This has me completely stumped, and I've never see anything like it.

Here's my query:

SELECT mus_searchsynonyms.good_term
, mus_searchsynonyms.alt_term
FROM s01_MUS_SearchSynonyms AS mus_searchsynonyms
WHERE mus_searchsynonyms.active = 1
AND mus_searchsynonyms.alt_term = ".quote_smart($search_query)."
AND mus_searchsynonyms.auto_replace = 0
When I use PHP to execute the query, I get the following error message (mysql_error()): (obviously <<$search_query>> is whatever the value of the variable is)

Quote:

Duplicate entry ?-<<$search_query>>' for key 1

When I run the query in phpmyadmin, the query is fine...

First, I don't know why I'd get a key error on a select query, 2nd, there aren't any duplicates in my table...

Most Popular Entry?
I have a quite simple question which I hope can be answered.

Whenever someone downloads a video from my site, a database entry is made with the time and name of the video. I run a php script everyday which discards entries older than 7 days. So I have all that figured out.

What I want to know is, how do I work out what the 10 most popular entries are in the database (by name)?

For example, 8 entries may have the name Video1.wmv, 4 entries may have the name Video4.wmv.etc.

I'm not sure if this can be done via a mysql query, or if php will somehow have to select the most popular entries.

Can't Get Newest Entry
I am trying to select two entries from two databases with one query:

$query = "SELECT ibf_members.id,ibf_members.members_display_name,ibf_member_extra.interests,ibf_member_extra.website,ibf_member_extra.avatar_location,ibf_members.joined FROM ibf_members,ibf_member_extra ORDER BY `joined`,`id` DESC LIMIT 1";
However, it won't show the latest member. It always shows member #1 which is the earliest member. I'm probably doing this wrong. Please help if you can.

Deleting An Entry?
I am using v4.0.20, and I need to figure out how to delete an entry. The database is for a game server I run. It is private, and so I have to add and remove members manually. Here is what I enter to add a person;

INSERT INTO Permissions VALUES ('Sue', 'PRIVATE');

I have never had to remove a player until now! How would I go about removing this entry?

If Entry Not Found
I want to query my data base for a certain user and id and I want to display a message user not found if the entry isn't there or display the entry if it is.

GUI For Data Entry
I am new to MySQL. 10 years ago I was into filemaker development. FileMaker has very nice built-in tools for creating user interface forms for data entry, retreival, editing, etc. So, what tools (preferable for Mac OS X) are available do this with MySQL?

Anyone know of any good apps for taking a MySQL database and automatically creating the PHP code to interact with the database? I've seen one or two for Mac OS X but the Mac OS X solutions seem to be somewhat half-baked compared to the Windows solutions.

Selecting Last Entry
All I need some help i have been trying to write this program for a friend that owns a internet cafe. The DB he uses is in sql he wants people to be able to see their time on his website i almost have it all written except for one problem when it selects there time it brings up all the changes to their account as in if he bought a hour yesterday it would so it i want it to show the current or last entry in the columns heres the code

SELECT userid, username, usertime, datetime
FROM users a, log b
where username = 'Their UserName'
order by datetime;

Is there any command so it shows only the last entry?

Double Entry
Howe can i prevent a double entry in a database.
Users can input their data into table.
But how to prevent a double entry.

Users can enter name and date
So users can enter their names only on one date.

Data Entry Via GUI
Is there a tool for MySQL for creating data-input forms, similar to the FORM VIEW in MS Access, that do not require programming to simply insert data into existing cells or to add rows for new data (and then insert the data)? I looked at the MySQL Browser GUI tool, but didn't see anything about data entry.

Only Allowing One Entry
I am trying to create a simple guetbook. I have it working, but the thing is, it only lets me enter one entry and can't work out why.

This is the insert code i have:


PHP Code:





 $insert="Insert into visitordata (name,email, location) values('$name','$email, '$location')";
mysql_query($insert) or die("Could not insert your entry");

Duplicate Entry
I'm currently developing a shopping cart for a local business using php and mysql. I was testing the registration form on the site when all of a sudden I got this error: "Duplicate entry 'tom@thisi.com' for key 1" (that's just a random test email by the way).

I worked out that I only get this error when I use an email that I've used before to signup. Even though I had deleted the previously used email address, it returns an error that it's a duplicate entry. Another strange thing is that the 'email' field is just an ordinary field so a duplicate entry shouldn't cause a problem anyway. If I truncate the table, it's all fixed of course - that's until I use that email address, then delete that account and try and use that email address again.

Match An Entry
Software receives alerts and feeds them into a database table. I need a stored procedure that takes each entry before it enters the table and compares it with the entries already in the table. If the entry about to be added matching one that is already in the table...I need it to cancel each other out and be removed from the database table. If the entry about to be added DOESN'T have a match then it should be added to the table. Is this possible?

Update Entry
Below is the code that I am using. It does the updating for me which is perfect but I cannot get the date part right. It updates all entries. I want it to update any entry that is one day older than presentday.
so update entry if curdat = yesterday.. Please help!

result = mysql_query("UPDATE `shows` SET status=81 WHERE date <= (CURDATE() - INTERVAL 1 DAY)");


Copyright © 2005-08 www.BigResource.com, All rights reserved