Re: Please help newbie php / mysql

From: Date: Mon, 21 Apr 2003 12:39:19 +0000
Subject: Re: Please help newbie php / mysql
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-19530@lists.php.net to get a copy of this message
i missed some parts... Seung Hwan Kang wrote:
let's say! you submit a field name called mode with value of "create". // createtbl.php <?
$dbhost     = "localhost";
$dbuser     = "id";
$dbpasswd = "pass";
$dbname     = "db";
// connection to MySQL DB
$conn = mysql_pconnect("$dbhost","$dbuser","$dbpasswd") or die ("Could not connect to database"); mysql_select_db("$dbname", $conn) or die ("Could not select database");
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.


« previous php.windows (#19530) next »