doesnt submit data to database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

doesnt submit data to database

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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());
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

also in my PHP myadmin it says
"No index defined!"
what does this mean?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post 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.
Post Reply