Re: parsing html in pgsql using php
am 22.08.2002 16:06:27 von dbrown
You need to escape your apostrophes. Your query statment uses
apostrophes and you have them in the string that your inserting into the db.
I believe you can use addslashes() and stripslashes() to help you with this.
http://www.php.net/manual/en/function.addslashes.php
Dave
Clio wrote:
>Subject ... how to?
>
>here is an example:
>
>
>
>
>$tmp = "
>
>
>
> Sample text in table.
> |
>
>
>";
>
>pg_connect("host=localhost dbname=daatabase user=web_user password=password");
>
>pg_query("insert into site_common values ('01','00','".$tmp."')");
>
>
>?>
>
>
>Here is an error:
>
>
>Warning: pg_query() query failed: ERROR: parser: parse error at or near "175" in /w/devel/test/dbinsert.php on line 80
>
>
>Any ideas?
>
>
>/ Clio
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>
>
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/users-lounge/docs/faq.html
Re: parsing html in pgsql using php
am 22.08.2002 16:10:52 von Roj Niyogi
A good way to debug these is to put the complete query into a variable
called $strSQL and then echo it to the browser. Then, examine the
string to see whether the quotes pair up and that characters are escaped
properly.
$strSQL = "insert into site_common values ('01','00','".$tmp."')";
echo $strSQL;
exit; //remove this line when you think it will work
pg_query($strSQL);
Roj
Clio wrote:
>Subject ... how to?
>
>here is an example:
>
>
>
>
>$tmp = "
>
>
>
> Sample text in table.
> |
>
>
>";
>
>pg_connect("host=localhost dbname=daatabase user=web_user password=password");
>
>pg_query("insert into site_common values ('01','00','".$tmp."')");
>
>
>?>
>
>
>Here is an error:
>
>
>Warning: pg_query() query failed: ERROR: parser: parse error at or near "175" in /w/devel/test/dbinsert.php on line 80
>
>
>Any ideas?
>
>
>/ Clio
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
Re: parsing html in pgsql using php
am 23.08.2002 02:36:06 von hodges
Another way to do this is with a "here doc" block:
$sample = <<< HERE
quote marks in here don't need to be escaped.
it will look just like plain html code.
also good for queries
HERE;
print ("$sample");
Tom
On 22 Aug 2002 at 9:06, David C. Brown wrote:
> You need to escape your apostrophes. Your query statment uses
> apostrophes and you have them in the string that your inserting into the db.
>
> I believe you can use addslashes() and stripslashes() to help you with this.
>
> http://www.php.net/manual/en/function.addslashes.php
>
> Dave
>
> Clio wrote:
>
> >Subject ... how to?
> >
> >here is an example:
> >
> >
> >
> >
> >$tmp = "
> >
> >
> >align='right'>
> > |
> > background-color: #f0f0f0;\">
> > Sample text in table.
> >
> >
> >
> >";
> >
> >pg_connect("host=localhost dbname=daatabase user=web_user password=password");
> >
> >pg_query("insert into site_common values ('01','00','".$tmp."')");
> >
> >
> >?>
> >
> >
> >Here is an error:
> >
> >
> >Warning: pg_query() query failed: ERROR: parser: parse error at or near "175"
> >in /w/devel/test/dbinsert.php on line 80
> >
> >
> >Any ideas?
> >
> >
> >/ Clio
> >
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 2: you can get off all lists at once with the unregister command
> > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> >
> >
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly