php - i try to create table in mysql with use of random() function.?


I want to create able in mysql with random name of table name i try but cant created. this is my code

$sql="CREATE TABLE $temp_table (FirstName CHAR(30),LastName CHAR(30),Age INT)";



Identifiers may begin with a digit but unless quoted may not consist solely of digits. Try doing this instead:

$sql="CREATE TABLE $temp_table (FirstName CHAR(30),LastName CHAR(30),Age INT)";

function randLetter()
  return chr(97 + mt_rand(0, 25));



Try quoting the name:

$sql="CREATE TABLE `$temp_table` (FirstName CHAR(30),LastName CHAR(30),Age INT)";

MySQL doesn't like numbers as identifiers. (Or prefix with something liketable_.)

People are also looking for solutions to the problem: php - Mysql function returns empty result


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.