Hello, I ran into a problem trying to create a file named after a table in the mysql database. The table name is stored in a variable called $tablename, and the filename should thus be, $tablename.php.

for example, a table called guestbook should create a file named guestbook.php.
But using the code below it creates guestbookphp. I don't know how to insert the dot.

Thank you in advance.

<?php
$filename = $tablename.php;

$fp = fopen($filename, 'x');
fwrite($fp, '1');
$data = fread($fp, 512);
echo $data;
fclose($fp);
?>

It should be

$filename = $tablename.".php";

Thanks for the quick help ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.