Hello guys I got in to problem. I know this question have been answered earlier, but I still can't get trought it. Anything with my database are correct, becouse other php files works fine. Tried another hosting, still same problem.
Core php(Where error occurs):
<?php
include('getSecondDropDown.php');
$arrayForSecondDropdown[] = functionName();
foreach($arrayForSecondDropdown as $v){
echo "<option value='" . $v['Country_ID'] ."'>" . $v['Country_Name'] ."</option>";
}
?>
getSecondDropDown.php:
<?php
include('config.php');
function functionName(){
$Region_ID =$_POST['Region_ID'];
$option="";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT Country_ID, Country_Name FROM Countries WHERE Region_ID ='".$Region_ID."'");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach($stmt as $v) {
echo "<option value='" . $v['Country_ID'] ."'>" . $v['Country_Name'] ."</option>";
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
echo $option;
?>
Full error code(Shown in web console - sources) :
Country: <select name="Country_ID" id="Country_ID" form="ServiceForm">
Error: SQLSTATE[HY000] [2002] No such file or directory<option value=''></option></select></br>