New To PHP & Would Appreciate Some Advice/Help

Hey Guys:
I’m as green as grass when it comes to php and mysql and at the moment I’m trying to get my head around it all…
I have been doing a lot of reading and note taking and decided to have a chop setting up a database and a form.

I first used dreamweaver cs4 to do a binding and I had a HTML/PHP form working, until I realized that the code it use was old and depleted.

Anyway the code I am using now gives me an error message:

Parse error: syntax error, unexpected $end in /home/mlmnetw1/public_html/join_now_form.php on line [b]430

The problem is’ there is only 428 lines of code’

I have checked that all { are closed } so it’s obviously my code that sux, would anyone care to take a look at what I have and see if they can spot the problem.

"This is day 3 of trying to figure out the problem and I am stumped at this point in time.

[/b]

Maybe you’re missing closing php tag ?>
It is hard to tell what is wrong without seeing the code.

Thanks for the reply:

I dont think I am? I have stared at this code for days now :’( refered to books, forums, websites and even tried starting over but so far nothing has really jumped out,

Anyway here’s the code and a dumb question, (do all the strings, arrays, ect have to be in exactly the same order as the DB table is laid out, it is but i’m just interested in knowing for future reference.)

[php]<?php

// Set error message as upon arrival to page
$errorMsg = “”;
// First we check to see if the form has previously been submitted
if (isset($_POST[‘username’])){
//Connect to DB
require_once(‘connectDB.php’);
// Filter the posted variables
$first = ereg_replace("[^A-Za-z0-9]", “”, $_POST[‘first’]); // up arrow filters everything but letters and numbers without up arrow will filter all letters and numbers
$last = ereg_replace("[^A-Za-z0-9]", “”, $_POST[‘last’]); // ^ filters everything but letters and numbers
$UserName = ereg_replace("[^A-Za-z0-9]", “”, $_POST[‘username’]); // ^ filters everything but numbers and letters
$password = ereg_replace("[^A-Za-z0-9]", “”, $_POST[‘password’]); // filter everything but numbers and letters
$country = ereg_replace("[^A-Z a-z0-9]", “”, $_POST[‘country’]); // filter everything but spaces, numbers, and letters
$state = ereg_replace("[^A-Z a-z0-9]", “”, $_POST[‘state’]); // filter everything but spaces, numbers, and letters
$city = ereg_replace("[^A-Z a-z0-9]", “”, $_POST[‘city’]); // filter everything but spaces, numbers, and letters there is a space here allowing spaces
$phone = ereg_replace("[^A-Za-z0-9]", “”, $_POST[‘phone’]); // not sure what to filter will have to experiment
$mobile = ereg_replace("[^A-Za-z0-9]", “”, $_POST[‘mobile’]);
$business = ereg_replace("[^A-Za-z0-9]", “”, $_POST[‘business’]);
$email = stripslashes($_POST[‘email’]);
$email = strip_tags($email);
$email = mysql_real_escape_string($email);
$website = ereg_replace("[^A-Za-z0-9]", “”, $_POST[‘website’]); // also not sure what to filter will need to test
// Check to see if the user filled all fields with
// the “Required”(*) symbol next to them in the join form
// and print out to them what they have forgotten to put in
if((!$first) || (!$last) || (!$username) || (!$password) || (!$country) || (!$state) || (!$city) || (!$accounttype) || (!$email)){

    $errorMsg = "You did not submit the following required information!<br /><br />";
    if(!$first){
        $errorMsg .= "--- First Name";
    } else if(!$last){
        $errorMsg .= "--- Last Name";
    } else if(!$Username){
        $errorMsg .= "--- UserName";
    } else if(!$password){
        $errorMsg .= "--- Password";
    } else if(!$country){
        $errorMsg .= "--- Country"; 
    } else if(!$state){ 
        $errorMsg .= "--- State"; 
    } else if(!$city){ 
        $errorMsg .= "--- City"; 
    } else if(!$accounttype){
        $errorMsg .= "--- Account Type"; 
    } else if(!$email){ 
       $errorMsg .= "--- Email Address"; 
} else {
// Database duplicate Fields Check
$sql_username_check = mysql_query("SELECT id FROM primary_database WHERE username='$username' LIMIT 1"); // DB is not primary_database but path is same_structure
$sql_email_check = mysql_query("SELECT id FROM primary_database WHERE email='$email' LIMIT 1");
$username_check = mysql_num_rows($sql_username_check);
$email_check = mysql_num_rows($sql_email_check); 
if ($username_check > 0){ 
    $errorMsg = "<u>ERROR:</u><br />Your User Name is already in use inside our system. Please try another.";
} else if ($email_check > 0){ 
    $errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our system. Please try another.";
} else {
    // Add MD5 Hash to the password variable
   $hashedPass = md5($password); 
    // Add user info into the database table, claim your fields then values 
    $sql = mysql_query("INSERT INTO primary_database (first, last, username, password, country, state, city, accounttype, emailactivated, signupdate, phone, mobile, business, email, website) 
    VALUES('$first','$last','$username','$password','$country','$state','$city','$accounttype','$phone','$mobile','$business','$email','$hashedPass','$website', now())") or die (mysql_error());
    // Get the inserted ID here to use in the activation email, 
    $id = mysql_insert_id();
    // Create directory(folder) to hold each user files(pics, MP3s, etc.) 
    mkdir("memberFiles/$id", 0755); 
    // Start assembly of Email Member the activation link
    $to = "$email";
    // Change this to your site admin email
    $from = "[email protected]";

    $subject = "Complete your registration";
    //Begin HTML Email Message where you need to change the activation URL inside
    $message = '<html>
    <body bgcolor="#FFFFFF">
    Hi ' . $username . ',
    <br /><br />
    Confirm your registration.
    <br /><br />
    Please click here to activate now &gt;&gt;
    <a href="http://www.website.com/activation.php?id=' . $id . '">
    ACTIVATE NOW</a>
    <br /><br />
    Your Login Data is as follows: 
    <br /><br />
    E-mail Address: ' . $email . ' <br />
    Password: ' . $password . ' 
    <br /><br /> 
    Thanks! 
    </body>
    </html>';
    // end of message
    $headers = "From: $from\r\n"; // \r opens database read only and \n creates new database truncate old versions if they exist
    $headers .= "Content-type: text/html\r\n";
    $to = "$to";
    // Finally send the activation email to the member
    mail($to, $subject, $message, $headers);
    // Then print a message to the browser for the joiner 
    print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br />
    We just sent an Activation link to: $email<br /><br />
    <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br />
    Link inside the message. After email activation you can log in.";
    exit(); // Exit so the form and page does not display, just this success message
} // Close else after database duplicate field value checks

} // Close else after missing vars check
} //Close if $_POST
?>

Registration
First Name: " size="40" maxlength="40" />
Last Name: " size="40" maxlength="40" />
Username: " size="40" maxlength="40" />
Password: " size="32" maxlength="32" />
Account Type: "><?php echo "$accounttype"; ?> Normal User Expert User Super User
Country: "><?php echo "$country"; ?> (please select a country) none Afghanistan Albania Algeria American Samoa Andorra Angola Anguilla Antarctica Antigua and Barbuda Argentina Armenia Aruba Australia Austria Azerbaijan Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia Bosnia and Herzegowina Botswana Bouvet Island Brazil British Indian Ocean Territory Brunei Darussalam Bulgaria Burkina Faso Burundi Cambodia Cameroon Canada Cape Verde Cayman Islands Central African Republic Chad Chile China Christmas Island Cocos (Keeling) Islands Colombia Comoros Congo Congo, the Democratic Republic of the Cook Islands Costa Rica Cote d'Ivoire Croatia (Hrvatska) Cuba Cyprus Czech Republic Denmark Djibouti Dominica Dominican Republic East Timor Ecuador Egypt El Salvador Equatorial Guinea Eritrea Estonia Ethiopia Falkland Islands (Malvinas) Faroe Islands Fiji Finland France France, Metropolitan French Guiana French Polynesia French Southern Territories Gabon Gambia Georgia Germany Ghana Gibraltar Greece Greenland Grenada Guadeloupe Guam Guatemala Guinea Guinea-Bissau Guyana Haiti Heard and Mc Donald Islands Holy See (Vatican City State) Honduras Hong Kong Hungary Iceland India Indonesia Iran (Islamic Republic of) Iraq Ireland Israel Italy Jamaica Japan Jordan Kazakhstan Kenya Kiribati Korea, Democratic People's Republic of Korea, Republic of Kuwait Kyrgyzstan Lao People's Democratic Republic Latvia Lebanon Lesotho Liberia Libyan Arab Jamahiriya Liechtenstein Lithuania Luxembourg Macau Macedonia, The Former Yugoslav Republic of Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Martinique Mauritania Mauritius Mayotte Mexico Micronesia, Federated States of Moldova, Republic of Monaco Mongolia Montserrat Morocco Mozambique Myanmar Namibia Nauru Nepal Netherlands Netherlands Antilles New Caledonia New Zealand Nicaragua Niger Nigeria Niue Norfolk Island Northern Mariana Islands Norway Oman Pakistan Palau Panama Papua New Guinea Paraguay Peru Philippines Pitcairn Poland Portugal Puerto Rico Qatar Reunion Romania Russian Federation Rwanda Saint Kitts and Nevis Saint LUCIA Saint Vincent and the Grenadines Samoa San Marino Sao Tome and Principe Saudi Arabia Senegal Seychelles Sierra Leone Singapore Slovakia (Slovak Republic) Slovenia Solomon Islands Somalia South Africa South Georgia and the South Sandwich Islands Spain Sri Lanka St. Helena St. Pierre and Miquelon Sudan Suriname Svalbard and Jan Mayen Islands Swaziland Sweden Switzerland Syrian Arab Republic Taiwan, Province of China Tajikistan Tanzania, United Republic of Thailand Togo Tokelau Tonga Trinidad and Tobago Tunisia Turkey Turkmenistan Turks and Caicos Islands Tuvalu Uganda Ukraine United Arab Emirates United Kingdom United States United States Minor Outlying Islands Uruguay Uzbekistan Vanuatu Venezuela Viet Nam Virgin Islands (British) Virgin Islands (U.S.) Wallis and Futuna Islands Western Sahara Yemen Yugoslavia Zambia Zimbabwe
State: " size="32" />
City: " size="32" />
Phone: " size="32" />
Mobile: " size="32" />
Business: " size="32" />
Email: " size="32" />
Website: " size="32" />
 

 

[/php]

PROBLEM SOLVED BY phpfreaks.com it was a close} on
(isset($_POST[‘username’])){

I had

} //Close if $_POST

When I should have had

} //Close if $_POST
}

Big thanks to Mr Marcus at phpfreaks

Sponsor our Newsletter | Privacy Policy | Terms of Service