Skip to content

Instantly share code, notes, and snippets.

@a1exlism
Created July 11, 2016 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a1exlism/1e9cacc86bdf51f81d7dec141f84b208 to your computer and use it in GitHub Desktop.
Save a1exlism/1e9cacc86bdf51f81d7dec141f84b208 to your computer and use it in GitHub Desktop.
From:http://www.ahlinux.com/php/12992.html
<?php
//Example_1
$query = sprintf("SELECT * FROM Users where UserName='%s' and Password='%s'",
mysql_real_escape_string($Username),
mysql_real_escape_string($Password));
mysql_query($query);
//Example_2
$db = new mysqli("localhost", "user", "pass", "database");
$stmt = $mysqli -> prepare("SELECT priv FROM testUsers WHERE username=? AND password=?");
$stmt -> bind_param("ss", $user, $pass);
$stmt -> execute();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment