Skip to content

Instantly share code, notes, and snippets.

@marcosnakamine
Created March 30, 2017 14:01
Show Gist options
  • Save marcosnakamine/17547b260d53eb9475af14eeff15fcfa to your computer and use it in GitHub Desktop.
Save marcosnakamine/17547b260d53eb9475af14eeff15fcfa to your computer and use it in GitHub Desktop.
PHP - MySQLi mysqli_connect, query, fetch_array, mysqli_escape_string
<?php
$db = mysqli_connect( 'host','user_name','password', 'data_base_name' );
$query = $db->query('
SELECT * FROM table_name
WHERE id = mysqli_escape_string( $db, '1' )
');
if( $query->num_rows > 0 ){
while ( $row = $query->fetch_array() ) {
var_dump( $row );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment