waps2
11-09-2011, 08:11 PM
Hi
I have the following function and have added the mysql_real_escape to try and stop sql injection but it nots working.
If I enter some ' ' into the form field and then look into my database. The ' ' are still there with no backslashes.
Anyone see the problem ?
function insertintodatabase() {
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$department=$_POST['department'];
$name=$_POST['yourname'];
$email=$_POST['emailaddress'];
$phone=$_POST['phonenumber'];
$comments=mysql_real_escape_string($_POST['enquiry']);
$optin=$_POST['salesoptin'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name(Department, Full_Name, Email_Address, Phone_Number, Comments, Email_Optin)VALUES('$department', '$name', '$email', '$phone', '$comments', '$optin')";
$result=mysql_query($sql);
// close connection
mysql_close();
}
:confused:
I have the following function and have added the mysql_real_escape to try and stop sql injection but it nots working.
If I enter some ' ' into the form field and then look into my database. The ' ' are still there with no backslashes.
Anyone see the problem ?
function insertintodatabase() {
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$department=$_POST['department'];
$name=$_POST['yourname'];
$email=$_POST['emailaddress'];
$phone=$_POST['phonenumber'];
$comments=mysql_real_escape_string($_POST['enquiry']);
$optin=$_POST['salesoptin'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name(Department, Full_Name, Email_Address, Phone_Number, Comments, Email_Optin)VALUES('$department', '$name', '$email', '$phone', '$comments', '$optin')";
$result=mysql_query($sql);
// close connection
mysql_close();
}
:confused: