473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

GetSQLValueString(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",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['shortdesc'], "text"),
GetSQLValueString($_POST['desc'], "text"),
GetSQLValueString($_POST['version'], "text"),
GetSQLValueString($_POST['minreqs'], "text"),
GetSQLValueString($_POST['wareid'], "int"),
GetSQLValueString($_POST['catid'], "int"),
GetSQLValueString($_POST['hpage'], "text"),
GetSQLValueString($_POST['dllink'], "text"),
GetSQLValueString($_POST['dlsize'], "text"),
GetSQLValueString($_POST['liveyn'], "text"),
GetSQLValueString($_POST['triallength'], "text"),
GetSQLValueString($_POST['price'], "double"),
GetSQLValueString($_POST['keywords'], "text"),
GetSQLValueString($_POST['submitdate'], "date"),
GetSQLValueString($_POST['submittime'], "date"),
// falls over here GetSQLValueString(current_date(), "date"),
GetSQLValueString(current_time(), "date"),
//GetSQLValueString($_POST['livedate'], "date"),
//GetSQLValueString($_POST['livetime'], "date"),
GetSQLValueString($_POST['swid'], "int"));
Jul 21 '05 #1
2 10047
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

GetSQLValueString(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",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['shortdesc'], "text"),
GetSQLValueString($_POST['desc'], "text"),
GetSQLValueString($_POST['version'], "text"),
GetSQLValueString($_POST['minreqs'], "text"),
GetSQLValueString($_POST['wareid'], "int"),
GetSQLValueString($_POST['catid'], "int"),
GetSQLValueString($_POST['hpage'], "text"),
GetSQLValueString($_POST['dllink'], "text"),
GetSQLValueString($_POST['dlsize'], "text"),
GetSQLValueString($_POST['liveyn'], "text"),
GetSQLValueString($_POST['triallength'], "text"),
GetSQLValueString($_POST['price'], "double"),
GetSQLValueString($_POST['keywords'], "text"),
GetSQLValueString($_POST['submitdate'], "date"),
GetSQLValueString($_POST['submittime'], "date"),
// falls over here
GetSQLValueString(current_date(), "date"),
GetSQLValueString(current_time(), "date"),
//GetSQLValueString($_POST['livedate'], "date"),
//GetSQLValueString($_POST['livetime'], "date"),
GetSQLValueString($_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('SELECT CURRENT_DATE');
$data=$mysql_fetch_array($result);
$now = $data[0];

Of course, add error checking.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.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

GetSQLValueString(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",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['shortdesc'], "text"),
GetSQLValueString($_POST['desc'], "text"),
GetSQLValueString($_POST['version'], "text"),
GetSQLValueString($_POST['minreqs'], "text"),
GetSQLValueString($_POST['wareid'], "int"),
GetSQLValueString($_POST['catid'], "int"),
GetSQLValueString($_POST['hpage'], "text"),
GetSQLValueString($_POST['dllink'], "text"),
GetSQLValueString($_POST['dlsize'], "text"),
GetSQLValueString($_POST['liveyn'], "text"),
GetSQLValueString($_POST['triallength'], "text"),
GetSQLValueString($_POST['price'], "double"),
GetSQLValueString($_POST['keywords'], "text"),
GetSQLValueString($_POST['submitdate'], "date"),
GetSQLValueString($_POST['submittime'], "date"),
// falls over here
GetSQLValueString(current_date(), "date"),
GetSQLValueString(current_time(), "date"),
//GetSQLValueString($_POST['livedate'], "date"),
//GetSQLValueString($_POST['livetime'], "date"),
GetSQLValueString($_POST['swid'], "int"));


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

$result = mysql_query("INSERT 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*******@attglobal.net
==================
Jul 21 '05 #3

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

Similar topics

2
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...
3
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...
18
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...
3
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 =...
9
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...
6
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...
0
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,...
58
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...
3
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.