I have the following code to see if a table (based on the user selection) exist or not, but it's giving me the following error:
[21-Mar-2019 11:34:11 UTC] PHP Fatal error: Uncaught PDOException:
SQLSTATE[42S02]: Base table or view not found: 1146 Table
'filecleaner.opened_2019-03-21' doesn't exist in
C:\inetpub\wwwroot\FileCleaner\consultas.php:126 Stack trace:
0 C:\inetpub\wwwroot\FileCleaner\consultas.php(126): PDOStatement->execute(Array)
1 {main} thrown in C:\inetpub\wwwroot\FileCleaner\consultas.php on line 126
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare("SELECT * FROM filecleaner.`Opened_". $DataDeConsulta ."`");
$stmt->execute([$DataDeConsulta]);
$count = $stmt->fetchColumn();
if ($count <= 0) {
$DataDeConsultaError = 'There is no information on that date!';
$valid = false;
}
if (isset($valid)) {
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM filecleaner.`Opened_". $DataDeConsulta ."`";
//session_start();
$_SESSION['DataDeConsulta'] = $DataDeConsulta;
$query_result=$pdo->query($sql);
foreach ($pdo->query($sql) as $row) {
echo '';
echo ''. htmlentities($row['Emails']) . ' ';
echo ' ';
echo '';
echo ' ';
}
Database::disconnect();
}
No comments:
Post a Comment