Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update field with actual modify date 1

Status
Not open for further replies.

softboy12

ISP
Feb 19, 2004
66
CH
hi all

i use a php form which writes datas into a mysql db
Now i have a field called "sperrdatum" in the db and this field shoud be automatically updated with the actual date and time, if the radio button "x_gesperrt" on the php Form is set to True

below is the code

------------------------------------------------------------

If ($x_gesperrt) {
myNewDateTime = NOW ()
$tkey = "" . $key . "";
$updateSQL = "UPDATE `kundenbillig` SET sperrdatum ='" & myNewDateTime & "' WHERE `Kundennummer`=" . $tkey;
}

and this the code for the radio button

<td class="ewTableHeader">Sperren&nbsp;</td>
<td class="ewTableAltRow">
<input type="radio" name="x_gesperrt" size="30" value="JA">
Ja&nbsp;<input type="radio" name="x_gesperrt" value="Nein">Nein&nbsp;

-----------------------------------------------------------


after i submit the form datas the following error occurs

Parse error: parse error, unexpected '=' in \\192.168.0.12\billighostingkunden\kundenbilligsperren.php on line 201
----------------------------------------------------------

what's wrong?

and how can create this kind of function?

thanks in advance for your trouble

best regards

E.Altherr
 
I think this is in the wrong forum, but you have a problem with line 201, or possibly line 200 in your code in that php file.

It's a syntax error, and what ever it is, the php engine doesn't understand it.

What are lines 200 and 201?

***************************************
J. Jacobs
 
Actually I just looked at your code a little further, I'll bet that
myNewDateTime = NOW ()
is line 200, but you don't end that line with a semicolon.
Ever line in php should be ended with a semicolon.

***************************************
J. Jacobs
 
ok, the myNewDateTime variable requires a $ at the start, and the value needs to be assigned as ='NOW()' and the single quotes have been removed from the query so that instead of trying to insert a datetime of literally NOW() it will call mysql's NOW() function to receive a date time correctly.

Code:
If ($x_gesperrt) {

        $myNewDateTime='NOW()';
        $tkey = "" . $key . "";
        $updateSQL = "UPDATE `kundenbillig` SET sperrdatum = ".$myNewDateTime." WHERE `Kundennummer` = ".$tkey."";

}






 
Hi KarveR (MIS)

it works

thanks for that

but now the date is shown in the english format instead of the german (2004-08-15 19:08:22 instead of 15-08-2004 19:08:22)

how can i reverse this or does this depend on the mysql server language?
 
this is the mysql default (or only way) it understands dates and times, this wil always be the way its stored.

when you want to return the date, use date_format as indicated by eric, e.g
SELECT date_format(sperrdatum,'%d-%m-%Y %H:%i:%s'),something_else,etc FROM ... ;

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top