2

I am using adodb with php. I need to insert html into my database, and need to know the best method to escape the quotes before inserting it into the database? I tried using pg_escape_string() but it still does not seem to insert.

What is the best method to do this?

Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412

2 Answers2

5

The best method is to use a parameterized query. See here to get started:

Community
  • 1
  • 1
Tomalak
  • 332,285
  • 67
  • 532
  • 628
  • I am not sure I understand how this will help in escaping. – Nic Hubbard Feb 28 '10 at 08:00
  • @Nic: But that is the whole *point* of parameterized queries. You don't need any escaping. You pass the raw string into the parameter, and that's it. – Tomalak Feb 28 '10 at 09:53
  • Ok, I guess even after looking at those posts I am still every confused how to use parameterized queries. – Nic Hubbard Feb 28 '10 at 19:54
  • $sql = "INSERT tbl (id, html) VALUES (?, ?)"; $results = $this->db->Execute($sql, array($id_val, $html_string)); – Tomalak Mar 01 '10 at 00:22
2
$conn = &ADONewConnection('access');

$var = $conn->qstr("Clean");
Jason Plank
  • 2,336
  • 5
  • 31
  • 40
Julio
  • 1,903
  • 2
  • 16
  • 19