Jump to content

Add a fixed number of days to today


bravo14

Recommended Posts

Hi Guys

 

I am trying to populate a field in a database with a the date 4 days from 'today'.

 

I have used the query below, but I am getting an error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE_ADD(NOW(), INTERVAL 4 DAY))' at line 2

 

$add_vehicle_sql=mysql_query("INSERT INTO `tbl_auction_lot`(`cust_id`,`reserve`,`make`,`model`,`spec`,`fuel`,`doors`,`mot_date`,`fns`,`fos`,`rns`,`ros`,`condition`,`reg_no`,`service_history`,`sale_type`,`status`,`keepers`,`gearbox`,`emissions`,`colour`,`date_first_reg`,`date_manufacture`,`bhp`,`engine_size`,`end_date`)
VALUES ('$seller_id','$reserve','$make','$model','$body_style','$fuel_type','$no_of_doors','$mot','$fns','$fos','$rns','$ros','$vehicle_condition','$vrm','$service_history','auction','$status','$prev_keepers','$gearbox','$emissions','$colour','$date_reg','$date_man','$bhp','$engine_size',DATE_ADD(NOW(), INTERVAL 4 DAY))")

How would I do this?

Link to comment
https://forums.phpfreaks.com/topic/231670-add-a-fixed-number-of-days-to-today/
Share on other sites

Your query looks correct. I suspect there is something in one of the values that is breaking the sql syntax and the error is just detected at that point.

 

I recommend that you form your sql query in a php variable and then echo that variable so that you can see what exactly the sql is.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.