乱数に基づいてデータベースを作成するためのこのコードがあります。
<?php
$con = mysql_connect("localhost","soociali","[censored]");
$databasename = rand(5, 7);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if (mysql_query("CREATE DATABASE $databasename",$con))
{
echo "Database created, called $databasename";
}
else
{
echo "Error creating database: " . mysql_error();
}
mysql_close($con);
?>
ただし、次のエラーが発生します。Error creating database: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '6' at line 1