0
<?php

   $host = "MY_HOST";
    $username = "MY_USERNAME";
    $password = "MY_PASSWORD";
    $connection = mysqli_connect($host, $username, $password);


if(!$connection)
   die("TRY AGAIN: " . mysqli_error());


$DBQuery = "USE MY_DB";
mysqli_query($connection, $DBQuery);

  $queryResult = $connection->
      query("SELECT * FROM MY_TABLE");

  $result = array();

  while ($fetchdata=$queryResult->fetch_assoc()) {
      $result[] = $fetchdata;
  }

  echo json_encode($result);
?>

When i go to localhost/FILE_PATH/fetch.php I get the full data in JSON form

When i upload it on server and go to https://www/MYSITE.com/FILE_PATH/fetch.php I get the message TRY AGAIN:

Is there something im missing out while trying to retrieve message from server? Im using aws rds mysql

Ive put my file inside var/www/html of my server. Am i supposed to put it in htdocs or something? if so, how do i reference to the file

Prateek BB
  • 135
  • 8
  • Replace `mysqli_error` with the function for connection errors https://www.php.net/manual/en/mysqli.connect-error.php – user3783243 Aug 20 '20 at 03:21
  • I got this error Connect Error: Server sent charset unknown to the client. Please, report to the developers @user3783243 What now? – Prateek BB Aug 20 '20 at 03:35
  • Does this answer your question? [PDO::\_\_construct(): Server sent charset (255) unknown to the client. Please, report to the developers](https://stackoverflow.com/questions/43437490/pdo-construct-server-sent-charset-255-unknown-to-the-client-please-rep) – Hirumina Aug 20 '20 at 04:38
  • Does this answer your question? [mysqli\_fetch\_assoc() expects parameter / Call to a member function bind\_param() errors. How to get the actual mysql error and fix it?](https://stackoverflow.com/questions/22662488/mysqli-fetch-assoc-expects-parameter-call-to-a-member-function-bind-param) – Dharman Aug 20 '20 at 11:40

0 Answers0