Php 'update' command script possibly needs sql injection protection? -


this question has answer here:

my database suffered sql injection attack, because relatively new programming , did not know that. have been trying learn how prevent them, cannot figure out how script. have type of script implemented though. how can prevent sql injection attack using script?

<?php  $autor = $_get["multi"]; $autop = $_get["multis"];  $sql = "update autoj set autob = '$autop' autoq = '$autor'";  $hd = "something"; $dd =  $_get['something']; $ud = "something"; $pd = "something";  $mysqli = new mysqli($hd, $ud, $pd, $dd);  if (mysqli_connect_errno()) {    printf("connect failed: %s\n", mysqli_connect_error());    exit(); }  $result = $mysqli->query($sql); if ($result) { .... 

try this:

$hd = "something"; $dd = "put here"; $ud = "something"; $pd = "something";  $mysqli = new mysqli($hd, $ud, $pd, $dd);  if (mysqli_connect_errno()) {    printf("connect failed: %s\n", mysqli_connect_error());    exit(); }  $autor = $_get["multi"]; $autop = $_get["multis"]; $autor = $mysqli->real_escape_string($autor); $autop = $mysqli->real_escape_string($autop);  $sql = "update autoj set autob = '$autop' autoq = '$autor'"; 

also, on line two, see used $_get['something'] select database. don't.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -