?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help

?
?error when creating a table with php
Author:??(---.ipt.aol.com)
Date:???07-15-03 13:21

I am writing an administration panel for a board called acmlmboard. it gives my "error when creating table" after running this script (names and passes have been changed for securitythe script works,just gives me an error
----------
the script
----------
// PHP/MYSQL page.
//MySQL Variables.
require "function.php";
MySQL_connect("localhost","fake","fake","fake_db");
//Variables of Form
$id = $_POST['id'];
$name = $_POST['fname'];
$description = $_POST['description'];
$minpow = $_POST['minpow'];
$order = $_POST['order'];

//Connecting to MYSQL
MySQL_connect("localhost","fake","fake");

$sql=mysql_query("INSERT INTO forums ($id,$fname,$description,$minpow,$minpow,$minpow,0,0, , ,$order)");
$result = mysql_query($sql);

if ($result) {
echo("Table created successfully");
} else {
echo("error when creating table");
}

?>

please help me!

?Re: error when creating a table with php
Author:??(---.bluecom.no)
Date:???07-15-03 14:56

Do you get an error when you are trying to create the table or when you are trying to insert the values?

I see two strange things in you code:
1. $sql=mysql_query("INSERT INTO forums ($id,$fname,$description,$minpow,$minpow,$minpow,0,0, , ,$order)"); - Shoud have VALUES and '', like this:
$sql=mysql_query("INSERT INTO forums VALUES('$id','$fname','$description','$minpow','$minpow','$minpow','0','0', '', '','$order')");

2. Why do you run the query two times, or atleast try to?
$sql = mysql_query!
Then you have run the query!

$result = mysql_query($sql);
Take a look at that function... replace the $sql with the value it woul look like this:
$result = mysql_query(mysql_query("INSERT INTO...

If you want to keep the $result variable remove "mysql_query" from the $sql variable!

Good luck!

Go to Top??|??Go to Topic??|??Threaded View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??

Provided By
Phorum