Jump to content

How to add mysql_real_escape_string


MDanz

Recommended Posts

mysql_select_db ($database);

// Make sure the user actually
// selected and uploaded a file

       $hyperlink = $_POST['hyperlink'];
   $currency = $_POST['currency'];
   $name = $_POST['name'];
   $image = $_POST['image'];
   $info = $_POST['info'];
   $keywords = $_POST['keywords'];
   $type = $_POST['type'];

      // Create the query and insert
      // into our database.
      $query = "INSERT INTO Stacks";
      $query .= "(`image`, `hyperlink`,`currency`,`name`,`info`,`keywords`,`type`) VALUES ('$image','$hyperlink','$currency','$name','$info','$keywords','$type')";
    
      $results = mysql_query($query, $link);
     

if($query){




print "<br><font color=white>Your image details have been uploaded to the database.  <a href='member.php'>Return to Upload Page</a></font>"; }
else {
print "No image selected/uploaded";
}


     


// Close our MySQL Link
mysql_close($link);

 

how/where do i add mysql_real_escape_string to this to prevent html attack?

Link to comment
https://forums.phpfreaks.com/topic/171283-how-to-add-mysql_real_escape_string/
Share on other sites

mysql_reral_escape_string does not prevent xss attacks if that's what your getting at, it simply escapes your data for safe insertion into a database.

 

All data going into your queries should first go through mysql_reral_escape_string, for example....

 

$name = mysql_real_escape_string($_POST['name']);

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.