Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. inventoryObjects.php is a script used to grab the values
  5. of an inventory object and output it so that Simba can read the
  6. webpage and apply them to a variable in-script
  7. */
  8.  
  9. $username = "[redacted]"; //predefined user and pass
  10. $password = "[redacted]";
  11. $db_name = "[redacted]"; //name of the db
  12. $table = "[redacted]"; //name of the table
  13. $serverIP = "[redacted]";
  14.  
  15. $invObj = str_replace("_", " ", $_GET['name']);
  16.  
  17. //connects to the database based on the above parameters
  18. $database = new mysqli ($serverIP, $username, $password, $db_name);
  19.  
  20. if ($database -> connect_errno)
  21. {
  22. //if there is an error, print this so simba can read it and
  23. //terminate, instead of attempting something stupid
  24. Die(printF("Error: Connect failed. Reason: %s/n", $database -> connect_errno));
  25. }
  26.  
  27. $database -> select_db($table);
  28.  
  29. //generates query to get the object's data
  30. $query = "SELECT * FROM $table WHERE name = '$invObj' LIMIT 1";
  31.  
  32. //does the query
  33. if ($result = $database -> query($query))
  34. {
  35. if (($result -> num_rows) <= 0)
  36. {
  37. printF("Error. No inventory object named \"%s\" exists in the database.", $invObj);
  38. }else
  39. {
  40. $row = $result -> fetch_assoc();
  41. printF("Successfully completed query!<br />name = %s<br />mainText = %s<br />normDTM = %s<br />noteDTM = %s<br />height = %d<br />width = %d<br />outlineCount = %d<br />convexity = %s<br />family = %s<br />stacks = %s<br />stacksInBank = %s<br />tradeable = %s<br />value = %d<br />highAlchValue = %d<br />lowAlchValue = %s<br />", $row['name'], $row['mainText'], str_replace(" ", "+", $row['DTM']), str_replace(" ", "+", $row['noteDTM']), $row['height'], $row['width'], $row['outlineCount'], $row['convexity'], $row['family'], $row['stacks'], $row['stacksInBank'], $row['tradeable'], $row['value'], $row['highAlchValue'], $row['lowAlchValue']);
  42. }
  43. $result -> close();
  44. }else
  45. {
  46. printF("Error. The query failed.");
  47. }
  48.  
  49. $database -> close();
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement