Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
1
Language: PHP
Posted by: Jacob Mahto
Added: May 18, 2019 5:14 AM
Views: 17
Tags: database php sql
  1. <?php
  2. $username='root';
  3. $password='lion';
  4. $host='localhost';
  5. $db='id6474450_rsl';
  6. $port=3306;
  7. $socket='';
  8. $con=mysqli_connect($host,$username,$password,$db);
  9. if($con){
  10. //echo "hello";
  11. }
  12. #Query Function
  13. function query($query){
  14.   global $con;
  15.   return mysqli_query($con,$query);
  16. }
  17. #Escape function
  18. function escape($string){
  19.   global $con;
  20.   return mysqli_real_escape_string($con,$string);
  21. }
  22. #Fetch Data
  23. function fetch_array($result){
  24.   global $con;
  25.   return mysqli_fetch_array($result);
  26. }
  27. #
  28. function confirm($result){
  29.   global $con;
  30.   if(!$result){
  31.     die("Query Failed".mysqli_error($con));
  32.   }
  33. }
  34. #Row Count function
  35. function row_count($result){
  36.   return mysqli_num_rows($result);
  37. }
  38.  ?>