Help Me

I got most of this code to work but I cannot get this code to insert the mail or name to go into the DB.

Here is the code

HTML

Test City:
Nme:
E-mail
System 1
System 2
About you

PHP Handler

<?php $city = $_POST[city]; $Name = $_POST[name]; $Mail = $_POST[mail]; $sys1 = $_POST[sys1]; $sys2 = $_POST[sys2]; $about = $_POST[about]; //MySQL Connection mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("gamers") or die(mysql_error()); // Insert a row of information into the table mysql_query("INSERT INTO gamers (city, name, mail, sys1, sys2, about) VALUES('$city', '$name', '$mail', '$sys1', '$sys2', '$about' ) ") or die (mysql_error()); ?>

Please help I am trying to figure it out

Try changing your variable assignments from the posted variables from

$city = $_POST[city];
to
$city = $_POST[[size=99px]’[/size]city[size=99px]’[/size]];
Note the RED single quotes ’

The $_POST is an array. Typically it expects an Index. Old school always meant a numeric Index, however PHP allows a string to be an index. Without quoting the string, PHP has to “GUESS” and as you may guess, the results are not always what are desired. ESPECIALLY if one of your string indexes (not quoted) are a keyword somewhere else in PHP

Also are there any error messages? What happens if you just echo out the SQL statement?

i.e.

<?php
$city = $_POST[city];
$Name = $_POST[name];
$Mail = $_POST[mail];
$sys1 = $_POST[sys1];
$sys2 = $_POST[sys2];
$about = $_POST[about];

ECHO "INSERT INTO gamers (city, name, mail, sys1, sys2, about) VALUES('$city', '$name', '$mail', '$sys1', '$sys2', '$about' ) ";
Sponsor our Newsletter | Privacy Policy | Terms of Service