Advertisement
Guest User

Untitled

a guest
Oct 12th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.54 KB | None | 0 0
  1. mysql> SELECT `volume` , `temp` , `humidity` , `co2` , `pressure` FROM `measurements` ORDER BY `ID` DESC LIMIT 1;
  2.  
  3. +--------+------+----------+-------+----------+
  4. | volume | temp | humidity | co2 | pressure |
  5. +--------+------+----------+-------+----------+
  6. | 59.76 | 1.88 | 13.7 | 44.62 | 0 |
  7. +--------+------+----------+-------+----------+
  8.  
  9. $sql = 'SELECT volume FROM measurements ORDER BY ID DESC LIMIT 1';
  10.  
  11. $sql = 'SELECT volume, temp , humidity FROM measurements ORDER BY ID DESC LIMIT 1';
  12. $sql = 'SELECT * FROM measurements ORDER BY ID DESC LIMIT 1';
  13.  
  14. <?php
  15. ini_set('display_errors', 'On');
  16. error_reporting(E_ALL | E_STRICT);
  17. $servername = "localhost";
  18. $username = "XYZ";
  19. $password = "12345";
  20. $myDB = "database";
  21. try {
  22. $conn = new PDO("mysql:host=$servername;dbname=$myDB", $username, $password);
  23. // set the PDO error mode to exception
  24. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  25. //echo "Connected successfully";
  26. }
  27. catch(PDOException $e)
  28. {
  29. echo "Connection failed: " . $e->getMessage();
  30. }
  31.  
  32.  
  33. $sql = 'SELECT volume, temp , humidity FROM measurements ORDER BY ID DESC LIMIT 1';
  34.  
  35. foreach ($conn->query($sql) as $row) {
  36. $first_volume = number_format ( $row['volume'],1);
  37. $first_temp = number_format ( $row['temp'],1);
  38. $first_humidity = number_format ( $row['humidity'],1);
  39. $first_co2 = number_format ( $row['co2'],1);
  40. $first_pressure = number_format ( $row['pressure'],0);
  41. }
  42. $conn = null;
  43. ?>
  44.  
  45. port = 3306
  46. socket = /tmp/mysql.sock
  47. user=root
  48.  
  49. [mysqld]
  50. innodb_force_recovery = 0
  51. datadir = /var/lib/mysql
  52. max_allowed_packet=256M
  53.  
  54. # Remove leading # and set to the amount of RAM for the most important data
  55. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
  56. innodb_buffer_pool_size = 8M
  57.  
  58. # Remove leading # to turn on a very important data integrity option:
  59. #logging
  60. # changes to the binary log between backups.
  61. # log_bin
  62.  
  63. # Remove leading # to turn on error logging.
  64. log_error = hostname_error.log
  65. #log_error=/var/log/mysql
  66.  
  67. # we have a read-only filesystem with one persistent writeable area only
  68. # so point to this single writeable location
  69. datadir = /var/lib/mysql/data
  70.  
  71. # These are commonly set, remove the # and set as required.
  72. # lc-messages-dir = .....
  73. # plugin-dir = .....
  74. # basedir = .....
  75. port = 3306
  76. # server_id = .....
  77. pid_file = /var/run/mysqld/mysqld.pid
  78.  
  79. user=root
  80. # Remove leading # to set options mainly useful for reporting servers.
  81. # The server defaults are faster for transactions and fast SELECTs.
  82. # Adjust sizes as needed, experiment to find the optimal values.
  83. join_buffer_size = 8M
  84. sort_buffer_size = 2M
  85. read_rnd_buffer_size = 2M
  86.  
  87. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  88.  
  89. if ( preg_match( "%^(www.)?livedomain.com$%", $_SERVER["HTTP_HOST"]) ) {
  90. define('APPLICATION_LIVE', true);
  91. } elseif ( preg_match( "%^(www.)?devdomain.net$%", $_SERVER["HTTP_HOST"]) ) {
  92. define('APPLICATION_LIVE', false);
  93. } else {
  94. die("INVALID HOST REQUEST (".$_SERVER["HTTP_HOST"].")");
  95. // Log or take other appropriate action.
  96. }
  97.  
  98. 2015-03-31T22:05:20.525812Z 2 [Note] Aborted connection 2 to db: 'database' user: 'root' host: 'localhost' (Got an error reading communication packets)
  99. 2015-03-31T22:05:21.897761Z 3 [Note] Aborted connection 3 to db: 'database' user: 'root' host: 'localhost' (Got an error reading communication packets)
  100. 2015-03-31T22:05:23.136331Z 4 [Note] Aborted connection 4 to db: 'database' user: 'root' host: 'localhost' (Got an error reading communication packets)
  101.  
  102. wait_timeout=2147483
  103. max_allowed_packet=1073741824
  104. interactive_timeout=90800
  105. connect_timeout=31536000
  106.  
  107. max_execution_time = 30 ; Maximum execution time of each script, in seconds
  108. max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
  109. ;max_input_nesting_level = 64 ; Maximum input variable nesting level
  110. memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)
  111.  
  112. root@Bone:~ netstat -a | grep mysql
  113. tcp 0 0 :::mysql :::* LISTEN
  114. unix 2 [ ACC ] STREAM LISTENING 7347 /tmp/mysql.sock
  115.  
  116. 00:19:38.400102 ARP, Request who-has 192.168.1.100 (d0:5f:b8:81:17:de (oui Unknown)) tell 192.168.1.200, length 46
  117. 00:19:38.400170 ARP, Reply 192.168.1.100 is-at d0:5f:b8:81:17:de (oui Unknown), length 28
  118. 00:19:40.399156 ARP, Request who-has 192.168.1.1 tell 192.168.1.200, length 46
  119.  
  120. root@Bone:/var ls -l ./pt-mysql-summary
  121. -rwxr-xr-x 1 root root 104093 Apr 1 00:10 ./pt-mysql-summary
  122. root@Bone:/var ./pt-mysql-summary
  123. -sh: ./pt-mysql-summary: not found
  124.  
  125. eth0 Link encap:Ethernet HWaddr D0:5F:B8:81:17:DE
  126. inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
  127. inet6 addr: fe80::d25f:b8ff:fe81:17de/64 Scope:Link
  128. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  129. RX packets:1105 errors:0 dropped:0 overruns:0 frame:0
  130. TX packets:412 errors:0 dropped:0 overruns:0 carrier:0
  131. collisions:0 txqueuelen:1000
  132. RX bytes:90361 (88.2 KiB) TX bytes:68063 (66.4 KiB)
  133. Interrupt:174
  134.  
  135. lo Link encap:Local Loopback
  136. inet addr:127.0.0.1 Mask:255.0.0.0
  137. inet6 addr: ::1/128 Scope:Host
  138. UP LOOPBACK RUNNING MTU:65536 Metric:1
  139. RX packets:11 errors:0 dropped:0 overruns:0 frame:0
  140. TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
  141. collisions:0 txqueuelen:1
  142. RX bytes:937 (937.0 B) TX bytes:937 (937.0 B)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement