note 120089 added to mysqli.real-query

From: Date: Wed, 26 Oct 2016 10:18:25 +0000
Subject: note 120089 added to mysqli.real-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-206960@lists.php.net to get a copy of this message
Straightforward function - simply connect to the database and execute a query, similar to this function bellow. <?php function check_password($username, $password) { // Create connection $db = new mysqli('localhost','database_user','database_pass','database_name'); // Check for errors if($db->connect_errno){ echo $db->connect_error; } // Execute query $result = $db->real_query("Select * From users Where username='$username' And password='$password'"); // Always check for errors if($db->connect_errno){ echo $db->connect_error; } return $result == true; } ?> Very easy. Replace database_user, database_pass and database_name with the proper names, and the text inside real_query with your actual query. Don't forget the quotes on either side (except for numbers, there you can omit them) otherwise it won't work. Hope that helps someone. ---- Server IP: 72.52.91.14 Probable Submitter: 194.96.78.102 ---- Manual Page -- http://php.net/manual/en/mysqli.real-query.php Edit -- https://master.php.net/note/edit/120089 Del: integrated -- https://master.php.net/note/delete/120089/integrated Del: useless -- https://master.php.net/note/delete/120089/useless Del: bad code -- https://master.php.net/note/delete/120089/bad+code Del: spam -- https://master.php.net/note/delete/120089/spam Del: non-english -- https://master.php.net/note/delete/120089/non-english Del: in docs -- https://master.php.net/note/delete/120089/in+docs Del: other reasons-- https://master.php.net/note/delete/120089 Reject -- https://master.php.net/note/reject/120089 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206960) next »