1

I am inserting data into a database and i need to do the following string...

Text 1 t/a Text 2

do i need to use addslashes function when inserting using PHP for the / character?

I did try without and the addslashes function which inserts into the database fine however when i run a query in my visual basic program i get an error message saying Command Failed and i think its because of the / character

Any help would be appreciated, thank you

ops
  • 2,023
  • 18
  • 21

2 Answers2

1

You should almost never use addslashes. Most times when it might be useful, there is a more specific general escaping function available (or, occasionally, one needs to be written).

If you are inserting into a database, then you should usually be handling your escaping using parameterized queries (via prepared statements).

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

addslashes is unsafe for SQL and you should never use it in that context. Use parameterized queries instead as Quentin suggests.

In any case your problem is not the forward slash / because that character has no special meaning in SQL string literals. Your problem is caused by something else.

Jon
  • 428,835
  • 81
  • 738
  • 806