Posted: Tue May 23, 2006 4:36 pm
Your insert code was fine the way it was (with the possible exception of the '/' in the 'osx/osx.css'). Maybe try passing the insert data through mysql_real_escape_string() and see what comes of it.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
$server = "localhost"; // server to connect to.
$database = "nhwood_spirfboard"; // the name of the database.
$db_user = "nhwood_testing"; // mysql username to access the database with.
$db_pass = "******"; // mysql password to access the database with.
$table = $_POST['username']; // the table that this script will set up and use.
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
// create table on database
$insert = "INSERT INTO $table (style, texttest, title) VALUES ('osx', 'Welcome to SPIRFBoard', 'Title');";
mysql_query($insert)
or die ("Could not create tables because ".mysql_error());
echo "Complete.";
?>Code: Select all
<?php
$server = "localhost"; // server to connect to.
$database = "dbname"; // the name of the database.
$db_user = "dbname"; // mysql username to access the database with.
$db_pass = "******"; // mysql password to access the database with.
$table = $_POST['username']; // the table that this script will set up and use.
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database) or die ("Could not select database because ".mysql_error());
// create table on database
$insert = "INSERT INTO $table (style, texttest, title) VALUES ('osx', 'Welcome to SPIRFBoard', 'Title');";
if (!$result = mysql_query($insert))
{
die ("Could not create tables because ".mysql_error());
}
if (mysql_affected_rows($result))
{
echo "Complete.";
}
else
{
echo "Not COmplete";
}
?>