473,811 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can I insert current date / time?

Hello,

I have the following section of php code which updates a mysql record
from a form. For the values of livedate and livetime I need to insert
the current_date() and current_time() respectively.

When I run the code however it falls over at the line with

GetSQLValueStri ng(current_date (), "date")

The error is Fatal error: Call to undefined function: current_date()

any ideas?

Thanks,

td
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "frmaddsw") ) {
$updateSQL = sprintf("UPDATE software SET title=%s, shortdesc=%s,
`desc`=%s, version=%s, minreqs=%s, wareid=%s, catid=%s, hpage=%s,
dllink=%s, dlsize=%s, liveyn=%s, triallength=%s, price=%s, keywords=%s,
submitdate=%s, submittime=%s, livedate=%s, livetime=%s WHERE swid=%s",
GetSQLValueStri ng($_POST['title'], "text"),
GetSQLValueStri ng($_POST['shortdesc'], "text"),
GetSQLValueStri ng($_POST['desc'], "text"),
GetSQLValueStri ng($_POST['version'], "text"),
GetSQLValueStri ng($_POST['minreqs'], "text"),
GetSQLValueStri ng($_POST['wareid'], "int"),
GetSQLValueStri ng($_POST['catid'], "int"),
GetSQLValueStri ng($_POST['hpage'], "text"),
GetSQLValueStri ng($_POST['dllink'], "text"),
GetSQLValueStri ng($_POST['dlsize'], "text"),
GetSQLValueStri ng($_POST['liveyn'], "text"),
GetSQLValueStri ng($_POST['triallength'], "text"),
GetSQLValueStri ng($_POST['price'], "double"),
GetSQLValueStri ng($_POST['keywords'], "text"),
GetSQLValueStri ng($_POST['submitdate'], "date"),
GetSQLValueStri ng($_POST['submittime'], "date"),
// falls over here GetSQLValueStri ng(current_date (), "date"),
GetSQLValueStri ng(current_time (), "date"),
//GetSQLValueStri ng($_POST['livedate'], "date"),
//GetSQLValueStri ng($_POST['livetime'], "date"),
GetSQLValueStri ng($_POST['swid'], "int"));
Jul 21 '05 #1
2 10086
toedipper wrote:
Hello,

I have the following section of php code which updates a mysql record
from a form. For the values of livedate and livetime I need to insert
the current_date() and current_time() respectively.

When I run the code however it falls over at the line with

GetSQLValueStri ng(current_date (), "date")

The error is Fatal error: Call to undefined function: current_date()

any ideas?

Thanks,

td
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "frmaddsw") ) {
$updateSQL = sprintf("UPDATE software SET title=%s, shortdesc=%s,
`desc`=%s, version=%s, minreqs=%s, wareid=%s, catid=%s, hpage=%s,
dllink=%s, dlsize=%s, liveyn=%s, triallength=%s, price=%s, keywords=%s,
submitdate=%s, submittime=%s, livedate=%s, livetime=%s WHERE swid=%s",
GetSQLValueStri ng($_POST['title'], "text"),
GetSQLValueStri ng($_POST['shortdesc'], "text"),
GetSQLValueStri ng($_POST['desc'], "text"),
GetSQLValueStri ng($_POST['version'], "text"),
GetSQLValueStri ng($_POST['minreqs'], "text"),
GetSQLValueStri ng($_POST['wareid'], "int"),
GetSQLValueStri ng($_POST['catid'], "int"),
GetSQLValueStri ng($_POST['hpage'], "text"),
GetSQLValueStri ng($_POST['dllink'], "text"),
GetSQLValueStri ng($_POST['dlsize'], "text"),
GetSQLValueStri ng($_POST['liveyn'], "text"),
GetSQLValueStri ng($_POST['triallength'], "text"),
GetSQLValueStri ng($_POST['price'], "double"),
GetSQLValueStri ng($_POST['keywords'], "text"),
GetSQLValueStri ng($_POST['submitdate'], "date"),
GetSQLValueStri ng($_POST['submittime'], "date"),
// falls over here
GetSQLValueStri ng(current_date (), "date"),
GetSQLValueStri ng(current_time (), "date"),
//GetSQLValueStri ng($_POST['livedate'], "date"),
//GetSQLValueStri ng($_POST['livetime'], "date"),
GetSQLValueStri ng($_POST['swid'], "int"));


Because current_date() is not a PHP function - it's a MySQL function. If you
need to get MySQL's date, you need to issue a SELECT for it, i.e.

$result = mysql_query('SE LECT CURRENT_DATE');
$data=$mysql_fe tch_array($resu lt);
$now = $data[0];

Of course, add error checking.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 21 '05 #2
toedipper wrote:
Hello,

I have the following section of php code which updates a mysql record
from a form. For the values of livedate and livetime I need to insert
the current_date() and current_time() respectively.

When I run the code however it falls over at the line with

GetSQLValueStri ng(current_date (), "date")

The error is Fatal error: Call to undefined function: current_date()

any ideas?

Thanks,

td
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "frmaddsw") ) {
$updateSQL = sprintf("UPDATE software SET title=%s, shortdesc=%s,
`desc`=%s, version=%s, minreqs=%s, wareid=%s, catid=%s, hpage=%s,
dllink=%s, dlsize=%s, liveyn=%s, triallength=%s, price=%s, keywords=%s,
submitdate=%s, submittime=%s, livedate=%s, livetime=%s WHERE swid=%s",
GetSQLValueStri ng($_POST['title'], "text"),
GetSQLValueStri ng($_POST['shortdesc'], "text"),
GetSQLValueStri ng($_POST['desc'], "text"),
GetSQLValueStri ng($_POST['version'], "text"),
GetSQLValueStri ng($_POST['minreqs'], "text"),
GetSQLValueStri ng($_POST['wareid'], "int"),
GetSQLValueStri ng($_POST['catid'], "int"),
GetSQLValueStri ng($_POST['hpage'], "text"),
GetSQLValueStri ng($_POST['dllink'], "text"),
GetSQLValueStri ng($_POST['dlsize'], "text"),
GetSQLValueStri ng($_POST['liveyn'], "text"),
GetSQLValueStri ng($_POST['triallength'], "text"),
GetSQLValueStri ng($_POST['price'], "double"),
GetSQLValueStri ng($_POST['keywords'], "text"),
GetSQLValueStri ng($_POST['submitdate'], "date"),
GetSQLValueStri ng($_POST['submittime'], "date"),
// falls over here
GetSQLValueStri ng(current_date (), "date"),
GetSQLValueStri ng(current_time (), "date"),
//GetSQLValueStri ng($_POST['livedate'], "date"),
//GetSQLValueStri ng($_POST['livetime'], "date"),
GetSQLValueStri ng($_POST['swid'], "int"));


One other thing - you could use current_date in the INSERT statement directly, i.e.

$result = mysql_query("IN SERT INTO xxx(col1, col2, col3, date_col) VALUES " .
"$value1, $value2, $value3, current_date()) ";
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2423
by: Bob Bedford | last post by:
I've a query with insert records in a table. I've 2 fields: DateTimeInsertion and DateTimeLastModification. When I create the record, I must have those 2 fields set the same value. Now I've this Insert into article values(now(), now(),....)
3
38802
by: Michael Hertz | last post by:
I am performing a XSLT stylesheet on a XML document and produce a new XML document. How can I insert in this new XML stylesheet a tag <currtime>..."the current date/time"....</currtime> where "the current date/time" above is replaced by the real current time (e.g. 12th Sep 2004 09:23:78 Michael
18
10330
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the date and time, but my script is erroring. '-- Get login date and time cmdLoginDate = Date() cmdLoginTime = Time()
3
3664
by: | last post by:
I have a datetime field in table. I want to insert the current time of database server to the table thr ASP.NET (C#). I have dataset to do the insert: DataSet1.TableNameRow rowNew = (DataSet1.TableNameRow)DataSet1.TableName.NewRow(); rowNew.DateTimeField = System.DateTime.Now;
9
4049
by: cavassinif | last post by:
I need to dynamic select a column in which insert a vale based on a parameter value, I have this code, but it throws an incorrect syntax error. How do I dinamically select a column to insert based on a parameter? Create PROCEDURE dbo.UpdateDetalleOT ( @eotId int, )
6
3479
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns, there's another column in the DB table named 'RegDateTime' whose datatype is Date/Time which is...
0
1670
by: gpspocket | last post by:
help me -CURSOR backward insert from End Date > to Start Date how to insert dates from end to start like this SELECT 111111,1,CONVERT(DATETIME, '17/03/2008', 103), CONVERT(DATETIME, '01/03/2008' i explain i have stord prosege that create mod cycle shift pattern and it working ok
58
8154
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also the parts section an i seem to be having trouble. When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections...
3
11880
by: perhapscwk | last post by:
I using a insert query to insert some data into mysql. I use now() as the current date and time but it always have 3.X hours different from actual date. what i should use instead? thanks.
0
9734
marktang
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...
0
10652
Oralloy
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...
1
10408
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9211
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7673
isladogs
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...
0
6895
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();...
0
5561
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.