B
B
blowly2020-06-21 16:29:06
PHP
blowly, 2020-06-21 16:29:06

json data not being uploaded?

<?php
    			$id = $_GET['id'];
      		$sql = mysqli_query($link, "SELECT `name`,`description`,`img`,`cost` FROM `product` WHERE `id` = '$id'");
        $url = "js/turkish.json";
      		$file = file_get_contents($url);
      		$file = json_decode($file, true);
      		while ($row = mysqli_fetch_assoc($sql)) {
      			echo "<tr><td ><img class='img-turkish' src='".$row['img']."'></td><td valign='top'><div class='title'>".$row['name']."</div><br><div class='text'>".$row['description']."</div><div class='cost'>Стоимость".' '.$row['cost']."</div><br>".$file."</td></tr>";
      		}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Entelis, 2020-06-21
@blowly

1. Learn to debug. Even without a fancy IDE and xdebugger, no one bothers to stick var_dump($something); after each line and check what's in it.
2. In telepath mode, I can assume that it file_get_contents($url);returns false. This happens for an obvious reason - it cannot find the file. Further, see https://www.php.net/manual/en/function.file-get-co...
3. What you wanted to do in general is not clear, the file contains an object from json_decode which you are trying to glue with a string - it obviously won't work that way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question