Thomas Nyman wrote:


Hi

I found an instruction on the net concerning "Date Arithmetic" and which seems to be exactly what I need to hel me get going..however there seems to be either a mistake on my behalf or on the writers behalf.

Can anyone say whats wrong with this query

$query2="UPDATE KK_Fatalie SET datum = DATE_ADD(date,INTERVAL intervall'
''.$typeArray[$row->type].")WHERE kk_ID="".$row->kk_ID"";

The query is suppose to result in the following;

do an UPDATE on table KK_Fatalie and set the column datum equal to todays date increased with the interval stated in the column intervall where the kolumn kk_ID equals the kk_ID in my earlier php query.

You say you want to add an interval to today's date, but your query is apparently adding to a column named date. To get today's date, use the CURDATE() function.


$query2="UPDATE KK_Fatalie
         SET datum = CURDATE() + INTERVAL intervall ".$typeArray[$row->type]
      ." WHERE kk_ID="".$row->kk_ID"";

I'm assuming inteval1 holds an integer and $typeArray[$row->type] holds an appropriate INTERVAL type (DAY or YEAR or...)

On the other hand, if you really do have a column named date you wish to use, then you need to realize that date is a reserved word, so it has to be enclosed in backticks to use it as a name.

Michael


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to