Jump to content

Couple of questions about sending info to MySQL db


JeBu

Recommended Posts

How is it safe to send info to MySQL database? Should I encrypt/encode the data before sending it?

 

for example:

 

<?php
...
//connection is established
...
$insert = "INSERT INTO table_name VALUES('$var1', '$var2')";
mysql_query($insert);
?>

 

Is it possible to use get access to my database, i.e to DROP TABLE/DATABASE or smth.

Have heard of MySQL injection

 

Any help/link is welcome

I would first clean it using something like mysql_real_escape_string. This should prevent most types of insertion. Also you need to list the field names in your query like this

 

$sql = "INSERT (`field1`, `field2`) INTO `table` VALUES('$var1', '$var2')";

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.