...Beauty, cleaning, DIY tips and more - free to join!
   Login   Contact us   Site map   Puzzle Club   Ask a question    Newsletter

How To Put Data In A Database

Computing : Learning PHP

One of the great things about PHP is it's so easy to connect and interface with a database, for instance mySQL typically for smaller sites.

However, one big problem can come with putting data in the database. The single biggest cause of problems (apart from malicious hack attempts of course) is dealing with quotation marks or single quotes in the entry string, depending how you add the data to the database.

This is why you should always ensure that you add slashes to the quotation marks before you put the data in the database, with this simple line:
$uploadtodb = addslashes($uploadtodb);

You can also strip them when taking data out using stripslashes

Also note the setting of magic quotes (on or off) will have an impact on different servers, so it's always best to check if this is on or off and adjust code accordingly for true portability.


Profile image!
By: Stephen

  More about mysql

  Reply to How To Put Data In A Database

  Receive Our Newsletter

  Send to friend

mysql picture



Questions about mysql:

Ask question

More Articles:
How to make it easy for people to link to you
What to do if you buy the wrong size product online
Money making ideas: Computer rental