Computing.Net > Forums > Programming > php mysql connect to database parse

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

php mysql connect to database parse

Reply to Message Icon

Name: piercy
Date: April 22, 2006 at 02:16:15 Pacific
OS: mac os 104
CPU/Ram: unknown
Product: apple
Comment:

hi im new to php programming and i have created a form
that sends a email to an email address tht i specify. i want this
email to be displayed in a table in my database. i have
tried loads of different online tutorials etc. but keep
getting the same parse error. it is always on the line with
msql_connect(). i am wondering if there is some sort of
error with the usenames because from what i remember
we had a bit of trouble setting permissions, usernames
and password in mysql.
the root user has no password although i have set up
another user called guest with a password of password.
dunno if it makes it easier either way.

anyways heres the code i have tried.

$fname = $_POST["first"];
$sname = $_POST["last"];
$email = $_POST["email"];
$msg = $_POST["message"];
$date = date('l dS F Y at h:i:s A');


mail('anon@anon.com', 'html form to email' ,
"From: $fname $sname \n email address: $email \n sent:
$date \n \n \n \t $msg")


$db = @mysql_connect('localhost', 'root', '');
mysql_select_db(test) ;
$result = "INSERT INTO messages ('first name' , 'last name'
, 'email address' , 'date' , 'message') VALUES ('$fname' ,
'$lname' , '$email' , '$date' , '$msg'")
mysql_query($sql)

please help!
thanks
piercy



Sponsored Link
Ads by Google

Response Number 1
Name: SN
Date: April 23, 2006 at 10:28:30 Pacific
Reply:

You've got quite a few errors...

1. You're missing a semicolon after the mail function (this is the one causing your problem.)
2. $result = "INSERT INTO..." should probably be $sql = "INSERT INTO..."
3. You're missing a semicolon after the statement referred to in issue #2
4. Missing a semicolon after mysql_query($sql).

For future reference, you are much more likely to get answers when you post what the error is...It's not usually as obvious as these ones were.

Good luck,
-SN


0
Reply to Message Icon

Related Posts

See More


running shell script on X... DLL and Embedded Programm...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: php mysql connect to database parse

Hello unable to connect to database www.computing.net/answers/programming/hello-unable-to-connect-to-database/19621.html

PHP connection to MySql www.computing.net/answers/programming/php-connection-to-mysql/6458.html

mySQL connect function in PHP www.computing.net/answers/programming/mysql-connect-function-in-php/10621.html