i can't find the answer for this anywhere. but very simply i have a create table and a saved session. i need that session to be the table name. this is shown below. i have struggled with this and have tried to find an answer everywhere.
below is the create msql table. the session is $id and below is what i have tried so far.
$sql = "CREATE TABLE " . $id . " (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP
)";
this is the page in context (updated)
<?php
//header("Location:all_games/myscorenum.php");
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "score";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
session_start();
$id=$_SESSION['id'];
echo"$id";
$sql = "CREATE TABLE '" . $id . "' (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP
) ";
if ($conn->query($sql) === TRUE) {
echo "Table MyGuests created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$conn->close();
?>
</div>