Re: Please help newbie php / mysql
| From: | Seung Hwan Kang | Date: | Mon, 21 Apr 2003 12:37:16 +0000 |
| Subject: | Re: Please help newbie php / mysql | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-19529@lists.php.net to get a copy of this message | ||
let's say! you submit a field name called mode with value of "create".
// createtbl.php
<?
$dbhost = "localhost"; $dbuser = "id";$dbpasswd = "pass";
$dbname = "db";if (strtolower($_POST["mode"]) == "create") { $result = mysql_query ("
create table tbl1
(
no int unsigned default '0' not null auto_increment,
name varchar(50) not null,
primary key (no)
)
");
if (!$result)
{
echo mysql_errno() . ":";
echo mysql_error() . "<br>";
}
else
{
echo("A table is successfully created!");
}
}
else
{
echo "Query error!";
}
?>
Jonathon Penberthy wrote:
Hi, I'm currently learning php and mysql, i have installed the latest version of Apache (2.0.45) and the PHP (4.3.1) and mysql, on windows XP pro. I am able to display the status of the MySQL database using a php script that displays the results in a browser. But I can't submit a query to the database to create a new table, I am able to create the table using the SQL dialog in the MySQL manager. So I know that there is not a problem with the syntax of my SQL, I'm using the same connection as used for the status display script and I know the query I type into the form is being parsed as I display it as soon as the script starts. Please help me if you can I'm getting very frustrated by at being stuck at the first hurdle. Jonathon.