creating a database straight from a form entry

hi, i have this code…

business type <?php

error_reporting (0);
$Business_Name = $_POST [“Business_Name”];
$Business_Type = $_POST [“Business_Type”];
$db_name = $_POST [“Business_Name”];

echo “You own “.$Business_Name .” which is a " .$Business_Type .”.";
?>
add another business.

<?php mysql_connect ("localhost", "root", "") or die(mysql_error("Connection Failed!")); mysql_query ("CREATE DATABASE $db_name") or die(mysql_error("Database not created!")); ?>

…that will not create the database its supposed to. the post are from a form if that helps.Everywhere else is fine. Thanks in advance!!

i think you need to enclose your variable in single qoutation

[php]
mysql_query (“CREATE DATABASE ‘$db_name’”)
[/php]

That gives me “Warning: mysql_error() expects parameter 1 to be resource, string given in C:\wamp\www\Two_Gun\biztype.php on line 14”

Is there any other way a user can create his own database according to what he enters in the form? (In my case the business type)

[php]
mysql_query ("CREATE DATABASE $db_name") or die(mysql_error());
[/php]

I hope it works,

Good luck

Sponsor our Newsletter | Privacy Policy | Terms of Service