0

I have a webpage that will display information based on a certain dropdown selection that a user will make. In order to see the data, I have multiple queries that run to determine which data will be displayed. If I am using just 1 query and pdo statement, it is working for me. However, I have multiple queries and pdo statements and when I try to use multiples, I get an Internal Server Error.

Can anyone offer some advice as to what the problem may be? Here is an example of what one of my queries and PDO statements look like:

$_400p_1_1 = "SELECT CAST([Program_ID] AS INT) AS Program_ID
      ,CAST([Series] AS INT) AS Series
      ,[Supplier_Group_Name]
      ,[Buyer Group Name]
      ,[Fund Name]
      ,CAST([Agreement_ID] AS INT) AS Agreement_ID
      ,[Location Group Name]
      ,[Product Group Name]
      ,[Shipping Group Name]
      ,CAST([Tier_ID] AS INT) AS Tier_ID
      ,[Retro_to_1]
      ,CAST([Payments per Year] AS INT) AS [Payments per Year]
      ,[Condition Unit of Measure]
      ,CAST([Condition Minimum] AS INT) AS [Condition Minimum]
      ,CAST([Condition Maximum] AS INT) AS [Condition Maximum]
      ,CAST([Incentive Multiplier] AS DEC(5,4)) AS [Incentive Multiplier]
  FROM [test].[dbo].[vExample]
  WHERE [Supplier_Group_Name] = '$supp' AND [Series] = 1 AND [Fund Name] = '400P' AND [Agreement_ID] = 1
  ORDER BY [Supplier_Group_Name]";

$stmt = $pdo->prepare($_400p_1_1);
$stmt->execute();
$results1 = $stmt->fetchAll();

And here is an example of bringing in the information to display:

<label>Program ID:</label><input value="<?php echo $results1[0]['Program_ID'];?>" readonly>

I should also mention that the dropdown selection, which is in page1.php, is sent through AJAX to update.php where the queries and PDO statements are located, along with the other HTML/PHP code. Again, it works just fine though if I am only using one query and one PDO statement.

Rataiczak24
  • 1,032
  • 18
  • 53
  • Check server logs to see what's exacly wrong. – Yupik Oct 03 '17 at 13:50
  • are u sure the above code produces that error? also enable error reporting then inspect element on tht input the error will be there – Masivuye Cokile Oct 03 '17 at 14:01
  • @MasivuyeCokile I guess I'm not 100% positive but I'm assuming it is because when I am just using the one query and statement instead of multiple ones, then it works and no error is produced – Rataiczak24 Oct 03 '17 at 14:06
  • @Rataiczak24 try enable error reporting then I suspect `$results1[0]['Program_ID']` – Masivuye Cokile Oct 03 '17 at 14:08
  • With that piece of code being on my `update.php` page which is called through AJAX, since I am getting an Internal Server Error there is not a way for me to view that in my console is there? Here is where I am at right now...Right click > Inspect > Network tab > update.php – Rataiczak24 Oct 03 '17 at 14:20
  • @Rataiczak24 Don't use Inspect-element client console to view server-side error. You need to enable error_reporting in php. – Prince Adeyemi Oct 03 '17 at 14:29
  • Possible duplicate of [How to get useful error messages in PHP?](https://stackoverflow.com/q/845021/1255289) – miken32 Oct 04 '17 at 17:04

0 Answers0