Question

I have a profile form and when my user update their profile , the current date also will be added to the decription of the profile.

$today = Date("l F d, Y"); 

$sqlUpdate = 'UPDATE USER_PROFILE SET 
FIRST_NAME =("'.$FIRST_NAME.'"), 
LAST_NAME=("'.$LAST_NAME.'"), URL=("'.$URL.'"), 
DESCRIPTION= CONCAT_WS(',',"'.$today.'","'.$DESCRIPTION.'") 
WHERE ID = "'.$GetID.'";';

I'm not sure how I can concate date to string in php, I would appreciate any help :)

here is the erro:

Parse error: parse error, unexpected ',' on line 122
Was it helpful?

Solution

you must escape the quote:

$today = Date("l F d, Y"); 

$sqlUpdate = 'UPDATE USER_PROFILE SET 
FIRST_NAME =("'.$FIRST_NAME.'"), 
LAST_NAME=("'.$LAST_NAME.'"), URL=("'.$URL.'"), 
DESCRIPTION= CONCAT_WS(\',\',"'.$today.'","'.$DESCRIPTION.'") 
WHERE ID = "'.$GetID.'";';

or you can just make the DESCRIPTION column receive its actual value:

$today = Date("l F d, Y") . $DESCRIPTION; 

$sqlUpdate = "
    UPDATE USER_PROFILE SET 
        FIRST_NAME = '$FIRST_NAME'
        , LAST_NAME = '$LAST_NAME'
        , URL= '$URL'
        , DESCRIPTION = '$today' 
    WHERE
        ID = '$GetID'
";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top