I have a data entry php code. I am allowing the user to select a table to be displayed on a separate page for easy access. I can get the code to insert the selected table into the "maintable" table, but I can't get any information out of that table. The insert table file won't even get the current table name from it even though on that same page I am inserting into that database. So I figure if I can fix this problem, I can fix that one, too. The maintable table has just one column with one record in one of my other databases. I am doing this so that the user doesn't have access to this directly since they can see all of the other tables in a different database.
The data-entry-header.php file has my connect statements, $connect being the one I am using for this database connection. What I get as a result is my main-form.php file with no table name. So it isn't throwing any errors, it's just not getting the table name. I know my connect statement and table/column names are correct because I have used the same one for the insert statement.
include 'data-entry-header.php';
$keys = array();
/* Query for Main Table Value */
$string = 'SELECT TableName FROM maintable';
$resultMain = mysqli_query($connect, $string) or die(mysqli_error($link));
while ($rowMain = mysqli_fetch_row($resultMain)){
$table = $rowMain[0];
}
/* Display Message or Table */
if ($table = NULL || $table = "" ){
echo 'No Main Table has been set. Go to the <a href="set-main-table.php">Set Main Table</a> page to select a Main Table.';
}
else {
include 'main-form.php';
}
/* Get footer Contents */
include "../footer.php";
try { $resultMain = mysqli_query($connect, $string); } catch { echo mysqli_error(); }perhaps ?mysqli_querydoes not throw any exceptions.