1

I created a small application that goes to the amazon api and grabs the asin, and a few other things. This works perfectly fine on my localhost however, once putting it in heroku, it seems to stop working.

I get this error:

 GET https://efreiner1-qn.herokuapp.com/printDatabase.php 500 (Internal Server Error)

and this stack trace

send @ jquery-3.1.1.js:9536
ajax @ jquery-3.1.1.js:9143
display @ main.js:11
(anonymous) @ main.js:7
mightThrow @ jquery-3.1.1.js:3570
process @ jquery-3.1.1.js:3638 

it seems to be having an error reading the php file, I already needed moved it from /php/file.php to the main folder, but it is still not working.

However, the response I get is a css response that I stuck on top of the php file so I know its hitting it. Here are 2 screen shots that I took to maybe shed some light.

I am not exactly sure what this is, I hope it helps

This is the css that it took from the top

And this is the PHP file, which works on the localhost

<style type="text/css">

#table
{
    font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
    font-size: 12px;
    margin: 45px;
    width: 480px;
    text-align: left;
    border-collapse: collapse;
}
 th
{
    padding: 8px 2px;
    font-weight: normal;
    font-size: 14px;
    border-bottom: 2px solid #5264AE;
    border-right: 30px solid #5264AE;
    border-left: 30px solid #5264AE;
    color: #FFFFFF;
}
 td
{
    padding: 12px 2px 0px 2px;
    border-right: 30px solid #5264AE;
    border-left: 30px solid #5264AE;
    color: #FFFFFF;
}
</style>


<?php
            include_once('configDB.php');

                 $result = mysql_query("SELECT asin, title, mpn, price FROM amazon");



          echo    "<table id='table'>";
          echo      "<tr>";
          echo        "<th>ASIN</th>";
          echo        "<th>Title</th>";
          echo        "<th>MPN</th>";
          echo        "<th>Price</th>";
          echo      "</tr>";



          while ($row = mysql_fetch_array($result)) {
            echo      "<tr>";
            echo       "<td>".$row{'asin'}."</td>";
            echo       "<td>".$row{'title'}."</td>";
            echo       "<td>".$row{'mpn'}."</td>";
            echo       "<td>".  $row{'price'}."</td>";
            echo     "</tr>";

          }

          echo     "</table>";


?>

From what it seems to me, this is a problem from ajax maybe, I am not sure, here is the ajax request

  $.ajax({
        url: 'printDatabase.php',
        complete: function(response) {
            $('#left').html(response.responseText);
        },
        error: function(result) {

            $('#left').html(result);
        }
    });

Thank you, I hope this is enough information

Edon Freiner
  • 338
  • 2
  • 17

1 Answers1

0

I have solved the problem. The issue was that I was using mysql() instead of mysqli() the version of php on my localhost was older of that on the server and therefor worked on my machine but not on the server

Edon Freiner
  • 338
  • 2
  • 17