Hello Everyone,
I have written code to create Temporary Table using PHP script. Now, when I run the script, it seems to have created the temporary table. Now, my problem is when I try to do INSERT statement in PhpMyAdmin into the temporary table I create, I am getting an error message in phpMyAdmin which says table not found. The thing is I do not know if I am creating the temp tables correctly or If I am not writing the code properly. Any help would be appreciated.
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$hostname = "localhost";
$username = "1104107";
$password = "r940c1";
$database = "db1104107";
//echo '24';
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password);
$db = mysql_select_db($database, $dbhandle)
or die("Unable to connect to MySQL");
//echo "Connected to MySQL<br>";
echo '4';
$query_createTemporaryTable = "CREATE TEMPORARY TABLE `Basket`(
temporary_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
ArtistName VARCHAR( 20 ) ,
NAMEOfTheDVD VARCHAR( 30 )
)Engine = MyISAM";
$result_createtemptable = mysql_query($query_createTemporaryTable) or die(mysql_error());
echo $result_createtemptable;
$query_insertintotable = "INSERT INTO Basket( ArtistName, NAMEOfTheDVD) VALUES ( 'R', 'SHAWooSHANK')";
$result_insertintotable = mysql_query($query_insertintotable ) or die(mysql_error());
$query_selecttemptable = "SELECT ArtistName,NAMEOfTheDVD FROM Basket";
$result_selecttemptable = mysql_query( $query_selecttemptable) or die(mysql_error());
while($row_selecttemptable = mysql_fetch_array($result_selecttemptable))
echo $row_selecttemptable['ArtistName'] . ' ,' . $row_selecttemptable['NAMEOfTheDVD'];
?>