1

I am trying to convert data from my DB to JSON with a PHP script. Everything works great on my local environment (MAMP). As soon as I am trying to put things together on my server, my JSON File is empty :(

What I have so far

my php script

<?php

$connection = mysqli_connect("localhost","root","root","angulardb") or die("Error " . mysqli_error($connection));


$sql = "select * from postings";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));


    $emparray = array();
    while($row =mysqli_fetch_assoc($result))
    {
        $emparray[] = $row;

    }




  $fp = fopen('menue.json', 'w');
  fwrite($fp, json_encode($emparray));
  fclose($fp);


  echo json_encode($emparray);

?>

By uploading this script to my server (& update the data), I receive an empty JSON file with no response.

Any Idea what can be wrong??? Is there additional configuration necessary on the server side?

Thanks in advance

3
  • To me, this sounds like there is a problem with writing permission to the file/folder. Commented Nov 10, 2015 at 12:33
  • I added write pwemissions for the entire folder + subfolders Commented Nov 10, 2015 at 13:11
  • Does echo $result; return anything? Commented Nov 10, 2015 at 13:24

1 Answer 1

0

Ok, got it .

the missing chsrset=utf8 caused my problem!

$pdo=new PDO("mysql:dbname=db239256x2330361;host=mysql.webhosting38.1blu.de;charset=utf8","s239256_2330361","20dj93lpav+dd");

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.