php - Converting query to parametrised query -


i have query on site , have been hacked because of it.

i have spent 2 hours looking how convert query secure , have not got anywhere.

if don't mind, please convert 1 me can see on rest?

$camera_id = $_get['camera_id'];  $cameras = mysqli_query($conn, "select * cameras id = $camera_id"); $camera = mysqli_fetch_array($cameras); 

try this.

$camera_id = $_get['camera_id'];  $cameras = mysqli_prepare($conn, "select * cameras id = ?"); mysqli_stmt_bind_param($cameras, $camera_id); $cameras->execute(); 

while making switch, switch straight away pdo. it's far better mysqli

   $db = new pdo('mysql:host=localhost;dbname=mydb', 'username', 'password');    $stmt = $db->prepare("select * cameras id = :camera_id");    $stmt->execute(array(":camera_id"=>$camera_id));    $result = $stmt->fetchall(); 

or instead of fetchall()

while($row = $stmt->fetch(pdo::fetch_assoc)) {     echo $row['field1'].' '.$row['field2']; //etc... } 

as can see more readable. , if later decide eto switch postgresql change real easy.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -