FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


login and register system error





jspets
hi

i have been following a tutorial for creating a login and register system. When it try to cerate a test account on the register page http://www.petknowledge.frih.org/registeringaccount.html it comes up saying:
Parse error: syntax error, unexpected ':' in /usr/home/jspets/domains/petknowledge.frih.org/public_html/register.php on line 31

This is the register.php i am using (i have taken out the database information for security reasons)

Code:
<?PHP
//Database Information
$dbhost = "localhost";
$dbname = "";
$dbuser = "";
$dbpass = "";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$name = $_POST['name'];
$email = $_POST['email'];   
$username = $_POST['username'];
$password = md5($_POST['password']);
// lets check to see if the username already exists
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
    echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";
    unset($username);
    include 'register.html';
    exit();
}
// lf no errors present with the username
// use a query to insert the data into the database.
$query = "INSERT INTO users (name, email, username, password)
VALUES('$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();
echo "You have successfully Registered";
// mail user their information
$yoursite = ‘http://www.petknowledge.frih.org';
$webmaster = ‘Pet Knowledge’;
$youremail = ‘mail.petknowledge.frih.org’;
$subject = "You have successfully registered at $yoursite...";
$message = "Dear $name, you are now registered at our web site. 
    To login, simply go to our web page and enter in the following details in the login form:
    Username: $username
    Password: $password   
    Please print this information out and store it for future reference.
    Thanks,
    $webmaster";
mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());
echo "Your information has been mailed to your email address.";
?>


Could someone tell me how to fix this Very Happy

edit by rvec: please use code tags
Star Wars Fanatic
It appears that you instead of apostrophes you have some weird apostrophes ( ‘ ). Make sure to use always use apostrophes that come without format. For example, use Notepad when saving, as it saves the text without any formatting. I hope that's not confusing.

Here is the php properly formatted:

Code:
<?PHP
//Database Information
$dbhost = "localhost";
$dbname = "";
$dbuser = "";
$dbpass = "";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$name = $_POST['name'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = md5($_POST['password']);
// lets check to see if the username already exists
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
echo "I'm sorry but the username you specified has already been taken. Please pick another one.";
unset($username);
include 'register.html';
exit();
}
// lf no errors present with the username
// use a query to insert the data into the database.
$query = "INSERT INTO users (name, email, username, password)
VALUES('$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();
echo "You have successfully Registered";
// mail user their information
$yoursite = 'http://www.petknowledge.frih.org';
$webmaster = 'Pet Knowledge';
$youremail = 'mail.petknowledge.frih.org';
$subject = "You have successfully registered at $yoursite...";
$message = "Dear $name, you are now registered at our web site.
To login, simply go to our web page and enter in the following details in the login form:
Username: $username
Password: $password
Please print this information out and store it for future reference.
Thanks,
$webmaster";
mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());
echo "Your information has been mailed to your email address.";
?>
rvec
you typed ` instead on ' on line 31
Code:
$yoursite = ‘http://www.petknowledge.frih.org';

should be
Code:
$yoursite = 'http://www.petknowledge.frih.org';


edit: Too late because I had to edit his post Sad
not fair

edit2: hmm I didn't even notice he did it multiple times
Related topics
(official) IE 7 Topic
Major Problem with COmputer. Help Please
.htaccess problem
Site Members' System
PhpBB Login Problem Please help me
Detected SPYware! System error #384
530 Login Incorrect
Help with Dreamweaver sessions !!!!!!!!
5 minute download wait
Some not so commonly asked questions.
login system error? can't figure it out
Login/Register Page
How to start scripting a basic clan page.
ERROR: unexpected '<' in
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.