submit form help

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

submit form help

Post 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
thegreatone2176
Forum Contributor
Posts: 102
Joined: Sun Jul 11, 2004 1:27 pm

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

Post by method_man »

ill see if it works.
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

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

Post by method_man »

i am running php 4.3.10
and mysql 4.1.9
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

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

Post 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';

?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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';

?>
.......
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

still dont work
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

show me what you have done.. make sure you have changed 'database_name' to your db's name.
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

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