Jump to content

Storing actualy PHP code


adamwhiles

Recommended Posts

I have a site that the purpose is for users to be able to submit php code for others to see or help with whatever. I am currently inserting the actual code into a mysql, I know this is not secure but I'm looking for the best way to do this. All I need it to do is store the php code, then be able to view that code w/ highlighting etc. on another page. It works for the most part as is right now, just looking for a better option than storing in a database.

 

Also, it seems like that when the code is pulled back out of mysql the formatting(indents) are a little off, any suggestions there?

 

BTW, this site is not live so I don't have any examples to show you. It just runs privately on my local test machine.

Link to comment
Share on other sites

I don't see any reason why storing PHP code in MySQL is not secure.

 

If you're storing the programming code in MySQL, then make sure you call mysql_real_escape_string() on the code before inserting it into the database.

 

When you pull the code to display in a browser, just make sure you call htmlentities() before echo'ing it.

 

To fix the spacing, place it within < pre> and </ pre> tags (without spaces of course).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.