hi there i am having a prob with the date format i have an inventory application in which i have to make a SALES BILL ENTRY FORM i ma using php & mysql for storing the fields and for the back-end programming
i am using the following code for the date with the format "month-date-year" -
<?
-
$date=date("m-j-Y");
-
?>
-
[html]
<tr>
<td class="add">Sal e Date:</td>
<td valign="middle" ><input name="sel_date" id="sel_date" readonly="true" type="text" size="25" value="<?=$date ?>" class="addinp"> </td>
</tr>
[/html]
but the problem is that when i try to vie the details in the sale detail page it shows the folllowing values
thanks for any any help in this regard
Omer.
7 1894
I cannot see any MySQL in the code you show. So this is NOT a MySQL problem, but a PHP one. Thread will be moved to PHP forum.
I cannot see any problem with the code you show (unless it is not all the code involved). One reason I can think of is that your server does not accept the abbreviation <? to start PHP code. Use <?php instead.
Ronald
nathj 938
Recognized Expert Contributor
hi there i am having a prob with the date format i have an inventory application in which i have to make a SALES BILL ENTRY FORM i ma using php & mysql for storing the fields and for the back-end programming
i am using the following code for the date with the format "month-date-year" -
<?
-
$date=date("m-j-Y");
-
?>
-
[html]
<tr>
<td class="add">Sal e Date:</td>
<td valign="middle" ><input name="sel_date" id="sel_date" readonly="true" type="text" size="25" value="<?=$date ?>" class="addinp"> </td>
</tr>
[/html]
but the problem is that when i try to vie the details in the sale detail page it shows the folllowing values
thanks for any any help in this regard
Omer.
Hi Omer,
You said that you were getting data from a MySQL database. however, the code snippet showews no such thing so I'm not sure where the data is coming from. The definition of $date you supply should simply give the current date in the format of month number with leading zeroes, day number without leading zeroes and a four digit year.
If you want to get the data out of the database in the correct format then take a look at date_format.
You can use this when you retreive the data from the table in question.
The only thing I can see 'wrong' with your code is your inline PHP, change;
[html]
value="<?=$date ?>"
[/html]
to
[html]
value="<?php $date ?>"
[/html]
That should sort you out I think.
Personally I don't like mixed code like that and would do it all in php:
[php]
<?php
$date=date("m-j-Y");
echo '<tr>
<td class="add">Sal e Date:</td>
<td valign="middle" ><input name="sel_date" id="sel_date" readonly="true" type="text" size="25" value="' . $date . '" class="addinp"> </td>
</tr>';
?>
[/php]
I hope that helps you out.
Cheers
nathj
You said that you were getting data from a MySQL database. however, the code snippet showews no such thing so I'm not sure where the data is coming from. The definition of $date you supply should simply give the current date in the format of month number with leading zeroes, day number without leading zeroes and a four digit year.
nathj actually if i try to write
[html]
$date=date()
[/html]
it gives me error regarding the missing parameters in date -
-
Warning: date() expects at least 1 parameter, 0 given in D:\Server\htdocs\ASHAR\ad_sale_frm.php on line 10
-
The only thing I can see 'wrong' with your code is your inline PHP, change;
[html]
value="<?=$date ?>"
[/html]
to
[html]
value="<?php $date ?>"
[/html]
well these are all the different ways to write its not a mistake you can even write it like
but you are not getting the problem its not with displaying the date in the form field its my mistake to not elaborate the problem OK NOW
i have the prob in the inserting part the page where i am inserting the values into the MySQL i think so because the date isnt saved into the data base in the format i want to save it here is the code for that page -
$hostname="localhost";
-
$username="root";
-
$password="66456";
-
$database="db1";
-
-
$conn_stk = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
-
mysql_select_db($database, $conn_stk);
-
-
$billno=$_POST["bill_no"];
-
$seldate=$_POST["sel_date"];
-
$cname=$_POST["cust_name"];
-
$mop=$_POST["m_o_p"];
-
$cper=$_POST["con_per"];
-
$cno=$_POST["con_no"];
-
$prd=$_POST["prd"];
-
$codeno=$_POST["code_no"];
-
$prt=$_POST["part"];
-
$stkavl=$_POST["stk_avl"];
-
$uprc=$_POST["u_prc"];
-
$stkreq=$_POST["stk_req"];
-
$tprc=$_POST["t_prc"];
-
-
$sqlAS="insert into sale_rec(Bill_no,Bill_date,Cust_name,Mop,Con_per,Con_no,Code_no,Prt_no,Stk_avl,Stk_req,U_prc,T_prc,Prd)
-
values('$billno','$seldate','$cname','$mop','$cper','$cno','$codeno','$prt','$stkavl','$stkreq','$uprc','$tprc','$prd')";
-
$resAS=mysql_query($sqlAS) or die(mysql_error().'<br />'.$sqlAS);
-
echo "The Bill Has been successfully added ";
-
i hope i elaborated my problem this time sorry to annoy you people if did [:)]
thanks for any help in advance,
regards,
Omer.
hi there i am having a prob with the date format i have an inventory application in which i have to make a SALES BILL ENTRY FORM i ma using php & mysql for storing the fields and for the back-end programming
i am using the following code for the date with the format "month-date-year" -
<?
-
$date=date("m-j-Y");
-
?>
-
[html]
<tr>
<td class="add">Sal e Date:</td>
<td valign="middle" ><input name="sel_date" id="sel_date" readonly="true" type="text" size="25" value="<?=$date ?>" class="addinp"> </td>
</tr>
[/html]
but the problem is that when i try to vie the details in the sale detail page it shows the folllowing values
thanks for any any help in this regard
Omer.
The problem is only this much omerbutt that in mysql date format is yyyy-mm-dd and you have to supply in same format otherwise any other format data will not be accepted by mysql and hence you see "0000-00-00" this value in the database . Just be strict about format will typing in html and you will get it. If you need any further help please feel free to contact .
The problem is only this much omerbutt that in mysql date format is yyyy-mm-dd and you have to supply in same format otherwise any other format data will not be accepted by mysql and hence you see "0000-00-00" this value in the database . Just be strict about format will typing in html and you will get it. If you need any further help please feel free to contact .
yeah nehas you are write about it but i want it to be stored in the format d-m-y
i have used this query too but it still not working and giving me error -
$sqlAS="insert into sale_rec(Bill_no,Bill_date,Cust_name,Mop,Con_per,Con_no,Code_no,Prt_no,Stk_avl,Stk_req,U_prc,T_prc,Prd)
-
values('$billno',DATE_FORMAT('$seldate','USA'),'$cname','$mop','$cper','$cno','$codeno','$prt','$stkavl','$stkreq','$uprc','$tprc','$prd')";
-
have swapped he statement DATE_FORMAT('$s eldate','USA') to DATE_FORMAT('US A','$seldate') also but it still gives me the same error the date i am posting the date from a form and it is properly posted into this page and is showing the value in the variable $seldate
but i am recieving the following error -
Column 'Bill_date' cannot be null
-
insert into sale_rec(Bill_no,Bill_date,Cust_name,Mop,Con_per,C on_no,Code_no,Prt_no,Stk_avl,Stk_req,U_prc,T_prc,P rd) values('1007',DATE_FORMAT('02-23-2008','USA'),'sameeer','CHEQUE','oemr','0321','100 0','CSV-4456','13','1','500','500','WATER_FILTER')
-
Markus 6,050
Recognized Expert Expert
Do you have to use DATE_FORMAT?
Can't you just insert it as you do with any other string..?
Do you have to use DATE_FORMAT?
Can't you just insert it as you do with any other string..?
of course i could if i had the format for the field of VarChar in the mysql database :)
but i have it the date format so wot u think now how sholu i be doing it
thanks for any help in advance,
Omer.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Simon Brooke |
last post by:
I'm investigating a bug a customer has reported in our database
abstraction layer, and it's making me very unhappy.
Brief summary:
I have a database abstraction layer which is intended to mediate
between webapps and arbitrary database backends using JDBC. I am very
unwilling indeed to write special-case code for particular
databases. Our code has worked satisfactorily with many databases,
including many instances MS SQLServer 2000...
|
by: amith |
last post by:
hi
I have written javascript for comparing two dates in US format and
finding out whether the start date is greater than the end date and
vice versa.
In this attempt i have instantiated the date object with the date
string which the user inputs from a pop up calendar.
somewhat like this..........
|
by: Richard Hollenbeck |
last post by:
I'm trying to write some code that will convert any of the most popular
standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan
1908) and compare the first with the second and calculate days, months, and
years. This is not for a college course. It's for my own personal
genealogy website. I'm stumped about the code. I'm working on it but not
making much progress. Is there any free code available anywhere? I know it...
|
by: Lyn |
last post by:
Hi,
I am developing a project in which I am checking for records with
overlapping start/end dates. Record dates must not overlap date of birth,
date of death, be in the future, and must not overlap existing records from
the same table.
I had this all working some time ago, but recently when I have gone back to
do more testing, part of these validations no longer work. While there have
been changes to the code in the meantime, I cannot...
|
by: Macca |
last post by:
Hi,
I have a table which has a date/time field. I am storing them as follows :-
01/01/2005 11:25
01/01/2005 19:44
02/01/2005 05:04
| |
by: Assimalyst |
last post by:
Hi,
I have a working script that converts a dd/mm/yyyy text box date entry
to yyyy/mm/dd and compares it to the current date, giving an error
through an asp.net custom validator, it is as follows:
function doDateCheckNow(source, args)
{
var oDate = document.getElementById(source.controltovalidate); //
dd/mm/yyyy
|
by: andreas |
last post by:
When I copy a vb.net project using date formats from one PC with a windows
date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I
get errors.
How can I change for a while in the project the date format in vb.code (
not in Windows) and how can I find out which date format the PC Windows is
using.
Thanks for any response
|
by: fniles |
last post by:
On my machine in the office I change the computer setting to English (UK) so
the date format is dd/mm/yyyy instead of mm/dd/yyyy for US.
This problem happens in either Access or SQL Server.
In the database I have a table with Date/time column. The database is
located on a machine that is set to dd/mm/yyyy also.
When I enter date 7/1/08 (as in January 7, 2008), it stores it in the
database as 1/7/08 instead of 7/1/08. Why is it like that...
|
by: OzNet |
last post by:
I have some functions to calculate the working days in a given period. This includes a table that is queried to calculate the number of public holidays that don’t occur on a weekend.
If I test the function using the intermediate window, it works fine. However, when I pass the dates from the code attached to my form, the results are inaccurate.
You will notice my dates are in Australian format. Everything works fine using the Australian...
|
by: ollyb303 |
last post by:
Hello,
I am using a dynamic crosstab report to track performance statistics for my company and I have hit a problem.
I would like the option to track stats daily (for the last 7 complete days), weekly (for the last 6 weeks) and monthly (for the last 6 complete months).
Daily and monthly are not causing me a problem - I have used the following code to construct the query:
strXT = "TRANSFORM Sum(Query2.STAT) AS SumOfSTAT " & _...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |