Forum Moderators: coopster

Message Too Old, No Replies

beginers php

beginners problem please help

         

angelacom3

11:18 pm on Dec 3, 2006 (gmt 0)

10+ Year Member



hey, i'm a newb 2 php. been looking at this code 4 hrs and i'm begining 2 crack!
what i'm trying to do is send fname to fname in my database named users. i'm getting this problem:
Parse error: parse error, unexpected T_STRING in /home/content/j/o/b/jobs4u/html/register_handle.php on line 25

heres my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www/w3.org/TR/xhtml1/DTD/xhtml1-transittional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="test/html;charset=iso-8859-1" />
<title>register feedback</title>
</head>
<body>

<?php # Script - register_handle.php

//Validate the name and combat Magic quotes, if necessary.

if (!empty($_REQUEST['fname'])) {
$fname = stripslashes($_REQUEST['fname']);

require_once('mysql_connect.php);

query = "INSERT INTO users (fname) VALUES ($fname))";
result = @mysql_query);

} else {
$fname = NULL;
echo 'you forgot to enter your first name';
}

?>
</body>
</html>

eelixduppy

11:31 pm on Dec 3, 2006 (gmt 0)



Welcome to WebmasterWorld!

You have some errors:


if (!empty($_POST['fname'])) {
$fname = $_POST['fname'];
if([url=http://us2.php.net/manual/en/function.get-magic-quotes-gpc.php]get_magic_quotes_gpc[/url]()) {
$fname = stripslashes($fname);
} //are you sure you have magic_quotes?

require_once('mysql_connect.php'); //this is where your error came from

$query = "INSERT INTO users (fname) VALUES ('".[url=http://us2.php.net/manual/en/function.mysql-real-escape-string.php]mysql_real_escape_string[/url]($fname)."')";
$result = [url=http://us2.php.net/manual/en/function.mysql-query.php]mysql_query[/url]($query) or [url=http://us2.php.net/manual/en/function.die.php]die[/url]([url=http://us2.php.net/manual/en/function.mysql-error.php]mysql_error[/url]());
} else {
echo 'You forgot to enter your first name';
}

Good luck! :)

angelacom3

11:55 pm on Dec 3, 2006 (gmt 0)

10+ Year Member



aww cheers, it works. thanks so much