wmguk Posted October 13, 2008 Share Posted October 13, 2008 Hi Guys, I'm getting this error: Parse error: syntax error, unexpected T_ELSE in /var/www/vhosts/domain.co.uk/httpdocs/admin/scripts/createclient.php on line 78 however I've checked that line, and above and below and I think i need all the { } that I have, can anyone else have a look for me please? <?php error_reporting(0); include ("connection.php"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db($db, $con); $company = $_POST['company']; $address = $_POST['address']; $name = $_POST['name']; $position = $_POST['position']; $tel = $_POST['tel']; $mob = $_POST['mob']; $email = $_POST['email']; $benefit = implode(",", $_POST['benefit']); $jobspecname = $_POST['jobspecname']; $jobspec = $_POST['jobspec']; $jobspecsel = $_POST['jobspecsel']; $howmany = $_POST['howmany']; $type = $_POST['type']; $duration = $_POST['duration']; $ftpt = $_POST['ftpt']; $hours = $_POST['hours']; $location = $_POST['location']; $wage = $_POST['wage']; $qualifications = $_POST['qualifications']; $experience = $_POST['experience']; $licences = $_POST['licences']; $contype = $_POST['contype']; $agree = $_POST['agree']; $c_comments = $_POST['c_comments']; $appointment = $_POST['appointment']; //CHECK FOR EMAIL ADDRESS ALREADY USED /* Select data from database. */ $sql="SELECT * FROM client WHERE email='$email'"; $result=mysql_query($sql); $count=mysql_num_rows($result); /* If email is alrady in use. */ if($count==1){ $msg = "Sorry but this email address has already been used, Please <a href='lostpassword.php?email=$email'>Click Here</a> to resend your password. "; $err = 1; } else { if($jobspecsel=='yes'){ //UPLOAD FILE $target_path = "../jobspec/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $filename = basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { $msg = "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; $err = 2; } else{ $msg = "There was an error uploading the file, please try again!"; } //set the random id length $random_id_length = 10; $rnd_id = crypt(uniqid(rand(),1)); $rnd_id = strip_tags(stripslashes($rnd_id)); $rnd_id = str_replace(".","",$rnd_id); $rnd_id = strrev(str_replace("/","",$rnd_id)); $rnd_id = substr($rnd_id,0,$random_id_length); $appdate = date("Y-m-d"); $password = $rnd_id; mysql_query("INSERT INTO client (company, password, date, address, name, position, tel, mob, email, jobspecname, filename, appointment, contype, agree) VALUES ('$company', '$password', '$appdate', '$address', '$name', '$position', '$tel', '$mob', '$email', '$jobspecname', '$filename', '$appointment', '$contype', '$agree');"); } } else { //set the random id length $random_id_length = 10; $rnd_id = crypt(uniqid(rand(),1)); $rnd_id = strip_tags(stripslashes($rnd_id)); $rnd_id = str_replace(".","",$rnd_id); $rnd_id = strrev(str_replace("/","",$rnd_id)); $rnd_id = substr($rnd_id,0,$random_id_length); $appdate = date("Y-m-d"); $password = $rnd_id; mysql_query("INSERT INTO client (company, password, date, address, name, position, tel, mob, email, jobspecname, jobspec, benefit, howmany, type, duration, ftpt, hours, location, wage, qualifications, experience, licences, c_comments, appointment, contype, agree) VALUES ('$company', '$password', '$appdate', '$address', '$name', '$position', '$tel', '$mob', '$email', '$jobspecname', '$jobspec', '$benefit', '$howmany', '$type', '$duration', '$ftpt', '$hours', '$location', '$wage', '$qualifications', '$experience', '$licences', '$c_comments', '$appointment', '$contype', '$agree');"); } } include ("email.php"); ?> <META HTTP-EQUIV="Refresh" CONTENT="0; URL=../thanks.php?email=<? echo $email; ?>&password=<? echo $password;?>&msg=<? echo $msg;?>&err=<? echo $err;?>"> Link to comment https://forums.phpfreaks.com/topic/128144-solved-t_else-unexpected-but-ive-checked-and-checked/ Share on other sites More sharing options...
MasterACE14 Posted October 13, 2008 Share Posted October 13, 2008 I've fixed it for you. around line 78 you had... } } else { just needed to remove the first curly brace. here's the code fixed up... <?php error_reporting(0); include ("connection.php"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db($db, $con); $company = $_POST['company']; $address = $_POST['address']; $name = $_POST['name']; $position = $_POST['position']; $tel = $_POST['tel']; $mob = $_POST['mob']; $email = $_POST['email']; $benefit = implode(",", $_POST['benefit']); $jobspecname = $_POST['jobspecname']; $jobspec = $_POST['jobspec']; $jobspecsel = $_POST['jobspecsel']; $howmany = $_POST['howmany']; $type = $_POST['type']; $duration = $_POST['duration']; $ftpt = $_POST['ftpt']; $hours = $_POST['hours']; $location = $_POST['location']; $wage = $_POST['wage']; $qualifications = $_POST['qualifications']; $experience = $_POST['experience']; $licences = $_POST['licences']; $contype = $_POST['contype']; $agree = $_POST['agree']; $c_comments = $_POST['c_comments']; $appointment = $_POST['appointment']; //CHECK FOR EMAIL ADDRESS ALREADY USED /* Select data from database. */ $sql="SELECT * FROM client WHERE email='$email'"; $result=mysql_query($sql); $count=mysql_num_rows($result); /* If email is alrady in use. */ if($count==1){ $msg = "Sorry but this email address has already been used, Please <a href='lostpassword.php?email=$email'>Click Here</a> to resend your password. "; $err = 1; } else { if($jobspecsel=='yes'){ //UPLOAD FILE $target_path = "../jobspec/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $filename = basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { $msg = "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; $err = 2; } else{ $msg = "There was an error uploading the file, please try again!"; } //set the random id length $random_id_length = 10; $rnd_id = crypt(uniqid(rand(),1)); $rnd_id = strip_tags(stripslashes($rnd_id)); $rnd_id = str_replace(".","",$rnd_id); $rnd_id = strrev(str_replace("/","",$rnd_id)); $rnd_id = substr($rnd_id,0,$random_id_length); $appdate = date("Y-m-d"); $password = $rnd_id; mysql_query("INSERT INTO client (company, password, date, address, name, position, tel, mob, email, jobspecname, filename, appointment, contype, agree) VALUES ('$company', '$password', '$appdate', '$address', '$name', '$position', '$tel', '$mob', '$email', '$jobspecname', '$filename', '$appointment', '$contype', '$agree');"); } else { //set the random id length $random_id_length = 10; $rnd_id = crypt(uniqid(rand(),1)); $rnd_id = strip_tags(stripslashes($rnd_id)); $rnd_id = str_replace(".","",$rnd_id); $rnd_id = strrev(str_replace("/","",$rnd_id)); $rnd_id = substr($rnd_id,0,$random_id_length); $appdate = date("Y-m-d"); $password = $rnd_id; mysql_query("INSERT INTO client (company, password, date, address, name, position, tel, mob, email, jobspecname, jobspec, benefit, howmany, type, duration, ftpt, hours, location, wage, qualifications, experience, licences, c_comments, appointment, contype, agree) VALUES ('$company', '$password', '$appdate', '$address', '$name', '$position', '$tel', '$mob', '$email', '$jobspecname', '$jobspec', '$benefit', '$howmany', '$type', '$duration', '$ftpt', '$hours', '$location', '$wage', '$qualifications', '$experience', '$licences', '$c_comments', '$appointment', '$contype', '$agree');"); } } include ("email.php"); ?> Regards ACE Link to comment https://forums.phpfreaks.com/topic/128144-solved-t_else-unexpected-but-ive-checked-and-checked/#findComment-663680 Share on other sites More sharing options...
wmguk Posted October 13, 2008 Author Share Posted October 13, 2008 Hi, Thank you for that, I've made the change, and it is now inserting in to the DB however it is not including email.php or run <META HTTP-EQUIV="Refresh" CONTENT="0; URL=../thanks.php?email=<? echo $email; ?>&password=<? echo $password;?>&msg=<? echo $msg;?>&err=<? echo $err;?>"> at the end... I think thats what the extra } was trying to allow... Link to comment https://forums.phpfreaks.com/topic/128144-solved-t_else-unexpected-but-ive-checked-and-checked/#findComment-663684 Share on other sites More sharing options...
MasterACE14 Posted October 13, 2008 Share Posted October 13, 2008 it should include email.php regardless, it's not inside a if or else. And as for the Meta Refresh, its probably best to use header(); function. Link to comment https://forums.phpfreaks.com/topic/128144-solved-t_else-unexpected-but-ive-checked-and-checked/#findComment-663687 Share on other sites More sharing options...
wmguk Posted October 13, 2008 Author Share Posted October 13, 2008 oh ok, hmmm, there is obviously something happening now, as the email is defo not working, I will use the header instead, however will it make much difference? I dont notice any difference normally between the meta refresh or the header Thanks for your help so far Link to comment https://forums.phpfreaks.com/topic/128144-solved-t_else-unexpected-but-ive-checked-and-checked/#findComment-663692 Share on other sites More sharing options...
wmguk Posted October 13, 2008 Author Share Posted October 13, 2008 scrub that, I managed to miss a } on the email.php page too... Link to comment https://forums.phpfreaks.com/topic/128144-solved-t_else-unexpected-but-ive-checked-and-checked/#findComment-663706 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.