Jump to content

storing javascript in a database


Styles2304

Recommended Posts

I was trying to update my database with this block of info for my church that requires some javascript however the quotes are throwing me off. Can you tell me how to fix that?

 

Here's the link:

 

<a href="javascript:void(0)" onclick="changePage('randompage.html');" class="announcements">here</a>

 

 

Link to comment
https://forums.phpfreaks.com/topic/64456-storing-javascript-in-a-database/
Share on other sites

You wish to store this block of data into the database?

If so

$data = '<a href="..." onclick=" ('som..')">Here</a>';
mysql_query(sprintf("update table set field = '%s' where id = 1",
  htmlspecialchars($data, ENT_QUOTES)
));

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.