Page 2 of 2

Posted: Tue May 23, 2006 4:36 pm
by RobertGonzalez
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.

Posted: Tue May 23, 2006 5:29 pm
by nhwood
How does this help me? All I need is to post that data, if there is a way to get the "/" in the code in some other form...

Posted: Tue May 23, 2006 5:52 pm
by RobertGonzalez
Sometimes, passing data to MySQL without checking to make sure it is acceptable leads to errors in the SQL command. I have had experiences with trying to pass '@' into mysql, as well as '\'. The DB doesn't handle those special characters well and chokes when you throw those into the script without escaping them. It was just a thought.

Posted: Tue May 23, 2006 6:54 pm
by nhwood
I worked on a replacement and I was able to just have it be "osx" rather than "osx/osx.css" Still no luck though, I will keep trying...

Posted: Tue May 23, 2006 7:06 pm
by nhwood
Does this new script look okay?

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.";

?>

Posted: Tue May 23, 2006 9:50 pm
by RobertGonzalez

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";
}
?>
Try this one and see. I just added another level of checking things.

Posted: Wed May 24, 2006 7:29 pm
by nhwood
Guess what? Everything works! Thanks a lot for all of your help! I have one last step, but I can do that myself. This forums is awesome. I've still got some work, but as soon as my public beta for my Web 2.0 project is ready I'll be sure to announce it to you!