prudhvi Posted January 26, 2009 Share Posted January 26, 2009 hi guys, i'm new to php. <?php include('includes/header.html'); if(isset($_POST['submitted'])) { require_once('db_login.php'); $fname = $_POST['fname']; $lname = $_POST['lname']; $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; //connection to mysql $connection = mysql_connect($db_host,$db_username,$db_password); if(!$connection) { die("Could not connect to the mysql<br/>".mysql_error()); } //selecting database $db_selection = mysql_select_db(db_database); if(!$db_selection) { die("Could not select the database:<br/>".mysql_error()); } //query $query = "INSERT INTO users(fname,lname,username,password,email)VALUES('$fname','$lname','$username','$password','$email')"; //executing query $result = mysql_query($query); if(!$result) die("There is an error in sql query:<br/>".mysql_error()); else echo "your details are stored in database"; db_close($connection); } ?> <form action="register.php" method="post"> <fieldset> <pre> <label>First Name: <input type="text" name="fname" id="fname" size="20"/></label><br/> <script language="JavaScript" type="text/javascript"> if(document.getElementById) document.getElementById('fname').focus(); </script> <label> Last Name: <input type="text" name="fname" id="fname" size="20"/></label><br/> <label> User Name: <input type="text" name="lname" id="lname" size="20"/></label><br/> <label> Password: <input type="password" name="password" id="password" size="20"/></label><br/> <label> Email: <input type="text" name="email" id="email" size="40"/></label><br/> <input type="submit" value="Register"/> <input type="hidden" name="submitted" value="TRUE" /> </pre> </fieldset> </form> <?php include('includes/footer.html'); ?> when run this code i'm getting parse error on line3. i.e require_once('db_login.php'); i kept it in the correct still i'm getting error. could all help me to rectify it. Link to comment https://forums.phpfreaks.com/topic/142459-parse-error/ Share on other sites More sharing options...
Mchl Posted January 26, 2009 Share Posted January 26, 2009 What's in includes/header.html ? If it's plain HTML it will disrupt your script. BTW: Line 3 is if(isset($_POST['submitted'])) Link to comment https://forums.phpfreaks.com/topic/142459-parse-error/#findComment-746419 Share on other sites More sharing options...
prudhvi Posted January 26, 2009 Author Share Posted January 26, 2009 thanks for your suggestion, problem was rectified. Link to comment https://forums.phpfreaks.com/topic/142459-parse-error/#findComment-746425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.