This topic is locked
[SOLVED]

 Add and hour to a value

1/14/2020 6:13:16 PM
PHPRunner General questions
P
PaulM author

I am trying to insert a row into the calendar for which I need to add 1 hour for the EndTime. I've tried various ways of doing it but am now baffled. Can anyone help please?
$sql="INSERT INTO calcalendar

(

Datefield,

Enddate,

Timefield,

EndTime,

DayEvent,

Subject,

Description,

OwnerID,

Recurrence,

Category

)

values

(

'$values[PV_date_visit_arranged]',

'$values[PV_date_visit_arranged]',

'$values[PV_time_visit_arranged]',

'$values[PV_time_visit_arranged]->modify(+1 hour)',

0,

'$values[PV_subject]',

'$values[PV_description]',

'someone@gmail.com',

1,

0

)";
CustomQuery($sql);

A
acpan 1/14/2020

Try below code.

  1. May be better to quote your $values array:

    $values[PV_subject] => $values["PV_subject"]
  2. Try to assign to variables first before you form the sql, easier to troubleshoot later.
  3. echo out the final SQL and run manually if you have problem.



$PV_subject = $values["PV_subject"];

$PV_description = $values["PV_description"];
$PV_date_visit_arranged = $values["PV_date_visit_arranged"];

$PV_time_visit_arranged = $values["PV_time_visit_arranged"];
$PV_time_visit_1_hour_later = strtotime($values["PV_time_visit_arranged"]) + 60*60;

$PV_time_visit_1_hour_later_formated = date('H:i:s', $PV_time_visit_1_hour_later);
$sql="INSERT INTO calcalendar

(

Datefield,

Enddate,

Timefield,

EndTime,

DayEvent,

Subject,

Description,

OwnerID,

Recurrence,

Category

)

values

(

'$PV_date_visit_arranged',

'$PV_date_visit_arranged',

'$PV_time_visit_arranged',

'$PV_time_visit_1_hour_later_formated',

0,

'$PV_subject',

'$PV_description',

'someone@gmail.com',

1,

0

)";
CustomQuery($sql);


ACP

P
PaulM author 1/15/2020



I am trying to insert a row into the calendar for which I need to add 1 hour for the EndTime. I've tried various ways of doing it but am now baffled. Can anyone help please?
$sql="INSERT INTO calcalendar

(

Datefield,

Enddate,

Timefield,

EndTime,

DayEvent,

Subject,

Description,

OwnerID,

Recurrence,

Category

)

values

(

'$values[PV_date_visit_arranged]',

'$values[PV_date_visit_arranged]',

'$values[PV_time_visit_arranged]',

'$values[PV_time_visit_arranged]->modify(+1 hour)',

0,

'$values[PV_subject]',

'$values[PV_description]',

'someone@gmail.com',

1,

0

)";
CustomQuery($sql);


thank you for your reply but the only thing I can't seem to do is add and hour to $values[PV_time_visit_arranged] as in the line $values[PV_time_visit_arranged]->modify(+1 hour). If I hard code a value such as 17:00 it works. All I need is the correct syntax to add an hour to $values[PV_time_visit_arranged]

A
acpan 1/15/2020

Now i am confused by your reply. Did you even try the suggestion?

P
PaulM author 1/15/2020



Now i am confused by your reply. Did you even try the suggestion?


My apologies, I missed a bit of it out and it works perfectly. Thank you very much for your help.