SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2010
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Set Date() in a variable

    Hi all,

    I am having a slight issue on what should be a simple (most likely) operation. I need to set a variable to the current date so that it can be stored in a MySQL DB. The SQl column is called date_job_rec with data type 'date'.

    the following is the code which sets the variable sgathered from a form and inputs them into the SQL argument, this works fine. But $date_job_rec isnt passing the data across (or somethign).

    HTML Code:
    	$date_job_rec = date('Y - m - d');
    	$job_status = '-';
    	
    	
    	$sql = 'Insert into property set house_name="' .$house_name_text. '" , 
    	house_number="' .$house_number_text. '" , 
    	addline1="' .$addline1_text. '",
    	addline2="' .$addline2_text. '",
    	town = "' .$town_text. '",
    	county = "' .$county_text. '",
    	postcode = "' .$postcode_text. '",
    	job_status = "' .$job_status. '",
    	contact = "' .$contact_text. '",
    	access = "' .$access_text. '",
    	msg = "' .$msg_text. '",
    	date_job_rec = "' .$date_job_rec. '", 
    	client = "'.$client.'" ';
    Many thanks in advance

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
    $date_job_rec date('Y-m-d'); 
    rm the spaces...

    In any case you can always

    echo $sql onto the page and take a good look at it

    or paste it into PhpMyAdmin or whatever you use to manage your db.

    That way you separate PHP problems from pure SQL errors

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2010
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can not belive it was spaces!!!! ty it now works.

    Also thanks for the info on the use echo and phpadmin, i'm still so very very new to this and debuggin is an art i havent looked at yet! (well not properly)

    still so much to learn, and loving it!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •