0

I tried to use the prepared statement for very first time. It worked fine on localhost in postgres but now not working on website. The error is always : Internal server error 500.

Following is the code

$test_query = "SELECT pid, productname FROM products WHERE pid = 1";
if(isset($_POST['submission'])){
$db_connect =new mysqli(HOST,USER,PASSWORD,DB_NAME);
$email = $_POST['emailid'];
if (!$db_connect) {
    die("Connection failed: " . mysqli_connect_error());
}else{
    echo "Connected successfully : " ;
    $stmt = $db_connect->prepare($test_query);
    $stmt->execute();

    $response=$stmt->get_result();

    if($response->num_rows>0){
        print "Hurrey!";
    }
}}
Aaron
  • 45
  • 1
  • 8

1 Answers1

1

Your code working fine in both localhost and Server as well, check your database credentials. If there is no problem with database connection, then find your error by setting Error reporting ON in your server's php.ini file configuration

Anitha
  • 135
  • 1
  • 8
  • Anitha: How to set error reporting On? There is successful database connection but after adding select statement it stops with 500. – Aaron Nov 29 '19 at 07:48
  • use `error_reporting(-1);` in your PHP code to view any error from your code and also in your php.ini file uncomment the line "error_reporting=E_ALL" by removing (;) before the line starts – Anitha Nov 29 '19 at 07:57
  • Creating new php.ini is only option on godaddy server. How could I do both tasks suggested. – Aaron Nov 29 '19 at 11:15
  • Where did you have your php files? – Anitha Nov 29 '19 at 12:25
  • I created the php5.ini and added the lines as suggested in this link. My all files are in public_html folder of godaddy. https://stackoverflow.com/questions/5438060/showing-all-errors-and-warnings – Aaron Nov 29 '19 at 16:21
  • https://stackoverflow.com/questions/16140917/how-to-access-the-php-ini-file-in-godaddy-shared-hosting-linux .. hope you did like this in godaddy server. – Anitha Nov 29 '19 at 16:46