pg_exec error

Randy James rjames57 at YAHOO.COM
Fri Jun 10 16:10:52 EDT 2005


Hi Mark

I've tried a number of differant ways, 

POINT('pointx pointy')
POINT(''pointx' 'pointy'')
POINT("'pointx' 'pointy'")
POINT(pointx pointy)

with what you suggest i get:

Warning: pg_exec(): Query failed: ERROR: syntax error at end of input at
character 113 in /var/www/html/gis/create/write_postgres.phtml on line 19

I am guessing that something else i am doing is wrong. I counted the characters
and 113 is at the end of "pointy)"



--- Mark Cave-Ayland <m.cave-ayland at webbased.co.uk> wrote:

> 
> > -----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
> 
> 
> 



		
__________________________________ 
Discover Yahoo! 
Have fun online with music videos, cool games, IM and more. Check it out! 
http://discover.yahoo.com/online.html



More information about the mapserver-users mailing list