Advertisement
x1705

Untitled

Feb 22nd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <?php
  2. error_reporting(1);
  3. $servername = "localhost";
  4. $username = "####";
  5. $password = "####";
  6. $dbname = "ajsearch";
  7. $datatable = "atbible";
  8.  
  9. // Create connection
  10. $conn = new mysqli($servername, $username, $password, $dbname);
  11. // Check connection
  12. if ($conn->connect_error) {
  13. die("Connection failed: " . $conn->connect_error);
  14. }
  15.  
  16. //chat user enter this "@Gen1:1-Gen1:3"
  17. $messageText = "@Gen1:1-Gen1:2";
  18. //this strips the users input into a string (for use later)
  19. //msgat is the "call to the bot" which I remove for searching capabilities and put it in a string.
  20. $msgat = substr($messageText,0,1);
  21. //this make the users input into a clean string
  22. $message = substr($messageText,1);
  23.  
  24. //this takes the entire users (cleaned) input and splits it into two strings
  25. list($message1, $message2) = explode("-", "$messageText", 2);
  26.  
  27. //a test and redundant perhaps, still working on it
  28. $message3 = substr($message1,1);
  29. $message4 = substr($message2,0);
  30.  
  31. // search sql for users input (Gen1:1 through Gen1:2) - using the (cleaned) Strings (without the '@')
  32. $mysqli = "SELECT verse FROM ".datatable." WHERE book BETWEEN '%".message3." AND ".message4."'";
  33.  
  34. $result = $conn->query($mysqli);
  35.  
  36. if ($result->num_rows > 0) {
  37. while($row = $result->fetch_assoc())
  38. //$answer= " " . $row["verse"];
  39.  
  40. //combines the results of search into one variable ($answer)
  41. {$answer= " " . $row["verse"].$row["verse"];
  42. }
  43. }
  44.  
  45. // just for debugging (echos these to a page)
  46. echo "$answer", " | ", "$message3", " | ", "$message4", " | ", "$msgat";
  47.  
  48. echo " |End.";
  49. $conn->close();
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement