Greetings and Salutations,
And thank you as well... unfortunately this still hasn't solved my dilemma... I should probably mention what I've tried so far...
The script started out something to the effect of
<?php
include("charts.php");
$connection=mysql_connect($host, $user, $password)
or die ("couldn't connect to server.");
$db = mysql_select_db("honor", $connection)
or die ("couldn't connect to database.");
$sql = INSERT INTO accounts(username, password, e-mail) VALUES ('$post[username]', '$post[password]', '$_post[e-mail]')
if (mysql_query($sql, $connection)) {
echo "record added!";
} else {
echo "something went wrong";
}
?>
To begin with there was no id table at all... the main problem with that was a t-string error that was fixed by changing by putting it in quotations around the...
$sql = "INSERT stuff into some table or something"
Now I had an error that said
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in /usr/local/psa/home/vhosts/elf-honor.com/httpdocs/registration.php on line 10
which seemed to be fixed or transformed at least when I changed
$post[username] to '{$post['username']}'
That was the first time that it showed anything besides an error... it now said(as my script had told it to say when it didn't work)
Then I took out the (username, password, e-mail) in
$sql = "INSERT INTO accounts(username, password, e-mail) VALUES ('{$post['username']}', '{$post['password']}', '{$_post['e-mail']}')";
And it worked once.... it let me put in the one empty insert while telling me "record added!" then gave me the error
Then I read somewhere that if the php version was younger than 4.1.x I'd have to change the "$_post" to "$http_post_vars". Figuring that php 4 was older than 4.1.x I did that... still no help
So I went to another friend for help and he had me change
$sql = "INSERT INTO accounts VALUES ('{$http_post_vars['username']}', '{$http_post_vars['password']}', '{$http_post_vars['e-mail']}')";
to
$sql = "INSERT INTO accounts (username, password, e-mail) VALUES ('{$http_post_vars['username']}', '{$http_post_vars['password']}', '{$http_post_vars['e-mail']}')";
He also had me change
if (mysql_query($sql, $connection)) {
echo "record added!";
} else {
echo "something went wrong";
}
to
mysql_query($sql, $connection) or die(mysql_error();
which gave me a parse error of
"Parse error: parse error, unexpected ';' in /usr/local/psa/home/vhosts/elf-honor.com/httpdocs/registration.php on line 12"
Tried switching the post values to variables making the new code look like this
<?php
include("charts.php");
$connection=mysql_connect($host, $user, $password)
or die ("couldn't connect to server.");
$db = mysql_select_db("honor", $connection)
or die ("couldn't connect to database.");
$username = $http_post_vars['username'];
$password = $http_post_vars['password'];
$email = $http_post_vars['e-mail'];
$sql = "INSERT INTO accounts (username, password, e-mail) VALUES ('$username', '$password', '$email')";
mysql_query($sql, $connection) or die(mysql_error();
?>
"Parse error: parse error, unexpected ';' in /usr/local/psa/home/vhosts/elf-honor.com/httpdocs/registration.php on line 16"
which was fixed by adding an extra ')" at the end of the code
"You have an error in your SQL syntax near '-mail) VALUES ('', '', '')' at line 1"
So I took out the "-" in the e-mail of my accounts table... and in any code related to it.
Now I was back to it inserting one empty entry... but at least it was giving me an error for it...
Duplicate entry '' for key 1
so baffled I just stared at the damn thing forever and ever and ever until I added the id column in my accounts table as my primary key with int(11) and auto incriment starting at 1
I didn't put it in the php code at first... because I thought it would just automatically fill in the ones I didn't mention with the default(which it did-it was the only value that had anything in it for that one row that it let me create that was completely blank otherwise)
The error was now changed to
Duplicate entry '' for key 2
Then I decided to change the part of the code that said
$sql = "INSERT INTO accounts (username, password, e-mail) VALUES ('$username', '$password', '$email')";
to
$sql = "INSERT INTO accounts (id, username, password, e-mail) VALUES ('', '$username', '$password', '$email')";
And then after the advice by Planetsim, changed it to
$sql = "INSERT INTO accounts (id, username, password, e-mail) VALUES ('NULL', '$username', '$password', '$email')";
And now just for kicks followed matt's plan, and took out the id completely... nods