Forum Moderators: coopster

Message Too Old, No Replies

Problem inserting text in database

         

nicuz

5:48 am on Nov 1, 2006 (gmt 0)



I have a crawler that will fetch urls from a webpage. The urls are stored in my database. The next time I run the crawler script it checks the page for new urls and adds them to the database. The problem I'm having is that some of the webpages have urls with invalid characters (I think):

<a href="javascript:MM_openBrWindow('/pay-5','terms','scrollbars=yes,width=500,height=400');">

This kind of url cannot be inserted in my database:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '','terms','scrollbars=yes,width=500,height=400');', '2006-11-01 00:38:59', 'pl' at line 1

Anyone knows a way around this?
I appreciate it

appi2

6:37 am on Nov 1, 2006 (gmt 0)

10+ Year Member



if your using php mysql
have a look at
mysql_real_escape_string()
and
addslashes()

justgowithit

6:44 am on Nov 1, 2006 (gmt 0)

10+ Year Member



Actually, there really is no problem you're just dealing with a pop-up spawned from a host page via javascript. In your example the true URL would be "http://www.somesite.com/pay-5". The other values between "()" are constructs for the pop-up page.

All you need to do is restructure the string prior to inputing it in your database.