Page 1 of 1

doesnt submit data to database

Posted: Fri Jun 03, 2005 7:01 pm
by method_man
for some reason when you register for my game it connects but it doesnt send the data to the database or send the person an email.

here is my code

Code: Select all

<?PHP

require('dblink.php');

//mysql query
$query = 'INSERT INTO member (Username, Password, Email Address, First Name, Last Name, Sex, Date of Birth, City, Country) VALUES ("'.$_POST[Username].'", "'.$_POST[Password].'", "'.$_POST[Email].'")';
$db_query = mysql_query($query);
$to = $_POST['Email'];//the email address the user submitted
$subject = 'You Registered!';
$message = 'You have just registered to play on The Streets. To log in go to the main page and use your username and password to sign in.';//the body of the email you are sending

mail($to, $subject, $message);//mail sent

?>
sorry for asking so many questions about mysql, im very new to it.

thanks,

matt

Posted: Fri Jun 03, 2005 7:06 pm
by Burrito
your query won't work because you don't have the same number of values for the number of columns you've entered.

they must match up:

ex:

Code: Select all

$query = "insert into mytable (col1,col2,col3) values ('val1','val2','val3')";
also, having spaces in your field names is bad bad bad...use underscores instead.

you should add a die to your query function that will display the thrown error so you can have MySQL tell you what is wrong with it.

ex:

Code: Select all

mysql_query($query)
  or die(mysql_error());

Posted: Fri Jun 03, 2005 7:25 pm
by method_man
also in my PHP myadmin it says
"No index defined!"
what does this mean?

Posted: Fri Jun 03, 2005 7:53 pm
by neophyte
The first column in a table is usually an index||key. I think this is what it is refering to... PHPMyAdmin doesn't like the fact that you haven't defined one for your table.