Page 1 of 1

submit form help

Posted: Tue Jun 07, 2005 5:22 pm
by method_man
i am getting an error on my code and i dont know why.

here is my code

Code: Select all

<?PHP

require('dblink.php');

//mysql query
$query = 'INSERT INTO member (username("'.$_POST[username].'"), password("'.$_POST[password].'"), email1("'.$_POST[email1].'"), firstname("'.$_POST[firstname].'"), lastname("'.$_POST[lastname].'"), sex("'.$_POST[sex].'"), dob("'.$_POST[dob].'"), city("'.$_POST[city].'"), country("'.$_POST[country].'"))';
mysql_query($query)
   or die(mysql_error());
$db_query = mysql_query($query);
$to = $_POST['email1'];//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

break;
Username: $_POST['username']

break;
Password: $_POST['password'];

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

?>
it says the parse error is on line 14 which is
$to = $_POST['email1'];//the email address the user submitted
thanks,

matt

Posted: Tue Jun 07, 2005 8:02 pm
by thegreatone2176
i see a few things

your line 12 $message you dont have an ending ;


line 15 and 18 I dont see what you are trying to do but they are wrong if you are trying to have like Username: $username shown then do

echo "Username: $username";

Posted: Tue Jun 07, 2005 8:49 pm
by method_man
ill see if it works.

Posted: Tue Jun 07, 2005 9:04 pm
by method_man
that fixed that error :D thanks
but now i have a different one

here is where the code has an error

Code: Select all

$query = 'INSERT INTO member (username("'.$_POST[username].'"), password("'.$_POST[password].'"), email1("'.$_POST[email1].'"), firstname("'.$_POST[firstname].'"), lastname("'.$_POST[lastname].'"), sex("'.$_POST[sex].'"), dob("'.$_POST[dob].'"), city("'.$_POST[city].'"), country("'.$_POST[country].'"))';
here is the error message
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '("admin"), password("test"), email1("methodman14@hotmail.com"),
the username i typed in was admin the password was test and the email was methodman14

thanks,

matt

Posted: Tue Jun 07, 2005 9:59 pm
by method_man
i am running php 4.3.10
and mysql 4.1.9

Posted: Wed Jun 08, 2005 2:53 am
by CoderGoblin

Code: Select all

$query = &quote;INSERT INTO member 
(username,password,email1,firstname,lastname,sex,dob,city,country)
VALUES ('.$_POST&#1111;username].',
        '.$_POST&#1111;password].',
        '.$_POST&#1111;email1].',
        '.$_POST&#1111;firstname].',
        '.$_POST&#1111;lastname].',
        '.$_POST&#1111;sex].',
        '.$_POST&#1111;dob].',
        '.$_POST&#1111;city].',
        '.$_POST&#1111;country].')&quote;;

Posted: Wed Jun 08, 2005 1:03 pm
by method_man
now it says no database selected but i have one selected

Code: Select all

<?php

$connection = mysql_connect('127.0.0.1', 'streetlife', '');
if (!$connection) {
   die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

?>

Posted: Wed Jun 08, 2005 1:11 pm
by John Cartwright

Code: Select all

<?php

$connection = mysql_connect('127.0.0.1', 'streetlife', '');
mysql_select_db('database_name');
if (!$connection) {
   die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

?>
.......

Posted: Wed Jun 08, 2005 1:48 pm
by method_man
still dont work

Posted: Wed Jun 08, 2005 1:54 pm
by John Cartwright
show me what you have done.. make sure you have changed 'database_name' to your db's name.

Posted: Wed Jun 08, 2005 6:12 pm
by method_man
for some reason i cant get on my php admin thing so i cant get into my databases
it says this
#1045 - Access denied for user 'root'@'localhost' (using password: NO)