Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "xxxx";
- $username = "xxxx";
- $password = "xxxx";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=lyl2test", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- $sql = "SELECT civ_licenses from players WHERE uid = 230";
- foreach ($conn->query($sql) as $parseString) {
- $parseString['civ_licenses'] = str_replace('"[', '[', $parseString['civ_licenses']);
- $parseString['civ_licenses'] = str_replace(']"', ']', $parseString['civ_licenses']);
- $parseString['civ_licenses'] = str_replace('`', '"', $parseString['civ_licenses']);
- }
- if(!$obj = json_decode($parseString['civ_licenses'])) {
- echo json_last_error_msg();
- }
- foreach($obj as $key => $value) {
- echo $value[0];
- if($value[1] === 1) {
- echo " vorhanden";
- } else {
- echo " nicht vorhanden";
- }
- echo "<br>";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement