pg_exec error
Mark Cave-Ayland
m.cave-ayland at WEBBASED.CO.UK
Fri Jun 10 12:29:36 PDT 2005
> -----Original Message-----
> From: UMN MapServer Users List
> [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On Behalf Of Randy James
> Sent: 10 June 2005 19:44
> To: MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: Re: [UMN_MAPSERVER-USERS] pg_exec error
>
>
> Yes it it PHP and yes thats how i want it to look:
>
> GeometryFromText('POINT(575618 5614867)',-1);
>
> And ok i'll check out the '"
Hi Randy,
In PHP there are two types of string delimiters: ' and ". If a string is
surrounded by 's then any text between the 's is assigned directly to the
variable. However, if a string is surrounded by "s then any variables
referenced in the string, e.g. $myvar, are substituted by their actual
value.
For example:
$price = 10.0;
$myvar = 'The price of the dollar is $price';
echo $myvar;
-> The price of the dollar is $price
$price = 10.0;
$myvar = "The price of the dollar is $price";
echo $myvar;
-> The price of the dollar is 10.0
I must admit that I don't recommend using "s for strings since you
inevitably forget to escape the parameters beforehand which can leave you
vunerable to injection attacks. I hope this explains exactly how your query
works though.
Anyway the reason your query fails is that you've got an extra set of 's
around your coordinates which causes your geometry to look like
POINT('575618' '123456') instead of POINT(575618 123456). So removing the 's
around $pointx and $pointy should solve the problem for you, e.g.
pg_exec($connection, "INSERT INTO sites
VALUES('$q_nxt_gid','$id','$label','$site_id','$comments',GeometryFromText('
POINT($pointx $pointy)',-1)");
Hope this helps,
Mark.
------------------------
WebBased Ltd
17 Research Way
Tamar Science Park
Plymouth
PL6 8BT
T: +44 (0)1752 797131
F: +44 (0)1752 791023
W: http://www.webbased.co.uk
More information about the MapServer-users
mailing list