This topic is locked

Empty Value

2/11/2020 4:46:54 PM
PHPRunner General questions
P
PaulM author

I have the below query that doesn't insert the $data[PV_agent] data into the OwnerID and I just get an empty value. Everything else works OK except no values are inserted into the OwnerID. To check it out I've run this query and it works OK...

$sql="insert into Dummy_Table (DT_details) values ('$data[PV_Agent]')";

CustomQuery($sql);
I've tried double quotes, single quotes but just can't get it to work
$sql = DB::PrepareSQL("SELECT

concat(' - ',P_name_number,' ',P_street,' ',P_area,' ',P_town,' ',P_county,' ',P_postcode)

FROM Property_Visit,

Property

where P_id = $values[PV_P_id]");

$PV_addr=DBLookup( $sql );
[size="4"]$PV_agent=$data["PV_Agent"];[/size]
$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);
if ($PV_date_visit_arranged != null)

{

$sql="INSERT INTO calcalendar

(

Datefield,

Enddate,

Timefield,

EndTime,

DayEvent,

Subject,

Description,

[size="4"]OwnerID,[/size]

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 $PV_addr',

[size="4"]'$data[PV_agent]',[/size]

1,

3

)";
CustomQuery($sql);

}

Sergey Kornilov admin 2/11/2020

If you use Database API it will save you lots of time now and in the future. It takes care of commas, quotes, SQL injection prevention etc:

https://xlinesoft.com/phprunner/docs/db_insert.htm