pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedparsing html in pgsql using php
4+ messages / 4 participants
[nested] [flat]
* parsing html in pgsql using php
@ 2002-08-22 13:59 Clio <clio@zgia.zp.ua>
2002-08-22 14:06 ` Re: parsing html in pgsql using php David C. Brown <dbrown@centennialwines.com>
2002-08-22 14:10 ` Re: parsing html in pgsql using php Roj Niyogi <niyogi@pghoster.com>
0 siblings, 2 replies; 4+ messages in thread
From: Clio @ 2002-08-22 13:59 UTC (permalink / raw)
To: pgsql-php
Subject ... how to?
here is an example:
<?php
$tmp = "
<table width='175' cellSpacing='0' cellPadding='0' border='0' align='right'><tr>
<td align='center' vAlign='middle' style=\"border: 1px solid black; background-color: #f0f0f0;\">
Sample text in table.
</td>
</tr></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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: parsing html in pgsql using php
2002-08-22 13:59 parsing html in pgsql using php Clio <clio@zgia.zp.ua>
@ 2002-08-22 14:06 ` David C. Brown <dbrown@centennialwines.com>
2002-08-23 00:36 ` Re: parsing html in pgsql using php hodges@xprt.net
1 sibling, 1 reply; 4+ messages in thread
From: David C. Brown @ 2002-08-22 14:06 UTC (permalink / raw)
To: Clio <clio@zgia.zp.ua>; +Cc: pgsql-php
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:
>
><?php
>
>
>$tmp = "
>
><table width='175' cellSpacing='0' cellPadding='0' border='0' align='right'><tr>
> <td align='center' vAlign='middle' style=\"border: 1px solid black; background-color: #f0f0f0;\">
> Sample text in table.
> </td>
></tr></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)
>
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: parsing html in pgsql using php
2002-08-22 13:59 parsing html in pgsql using php Clio <clio@zgia.zp.ua>
2002-08-22 14:06 ` Re: parsing html in pgsql using php David C. Brown <dbrown@centennialwines.com>
@ 2002-08-23 00:36 ` hodges@xprt.net
0 siblings, 0 replies; 4+ messages in thread
From: hodges@xprt.net @ 2002-08-23 00:36 UTC (permalink / raw)
To: pgsql-php
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:
> >
> ><?php
> >
> >
> >$tmp = "
> >
> ><table width='175' cellSpacing='0' cellPadding='0' border='0'
> >align='right'><tr>
> > <td align='center' vAlign='middle' style=\"border: 1px solid black;
> > background-color: #f0f0f0;\">
> > Sample text in table.
> > </td>
> ></tr></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
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: parsing html in pgsql using php
2002-08-22 13:59 parsing html in pgsql using php Clio <clio@zgia.zp.ua>
@ 2002-08-22 14:10 ` Roj Niyogi <niyogi@pghoster.com>
1 sibling, 0 replies; 4+ messages in thread
From: Roj Niyogi @ 2002-08-22 14:10 UTC (permalink / raw)
To: Clio <clio@zgia.zp.ua>; +Cc: pgsql-php
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:
>
><?php
>
>
>$tmp = "
>
><table width='175' cellSpacing='0' cellPadding='0' border='0' align='right'><tr>
> <td align='center' vAlign='middle' style=\"border: 1px solid black; background-color: #f0f0f0;\">
> Sample text in table.
> </td>
></tr></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)
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-08-23 00:36 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-08-22 13:59 parsing html in pgsql using php Clio <clio@zgia.zp.ua>
2002-08-22 14:06 ` David C. Brown <dbrown@centennialwines.com>
2002-08-23 00:36 ` hodges@xprt.net
2002-08-22 14:10 ` Roj Niyogi <niyogi@pghoster.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox