PHP - Unexpected T_else Parse Error ????
Hi I was just writing an script on which i got an error and i can't find why and where i made it wrong.
here is the code Code: [Select] <?php include(dbinfo.inc); if(isset($_POST[submit])) { foreach($_POST as $field=>$value) { if(empty($value)) { echo "All fields are required, Please enter all the details in the form"; exit(); } } // Transfering POST variables into local variables $username = $_POST[username]; $password = $_POST[password]; $enroll = $_POST[enroll]; $email = $_POST[email]; $actype = $_POST[actype]; $firstname = $_POST[firstname]; $lastname = $_POST[lastname]; $connect = mysql_connect($host,$account,$password) or die("Couldn't connect to the database"); mysql_select_db($dbname, $connect); //Check if username already exist $sql = "Select * from memberinfo where username='$username'"; $result = mysql_query($sql, $connect); if(mysql_num_rows($result) > 0) { echo "username already exist"; } else { $sql = "INSERT INTO memberinfo (enroll, username, password, type, first_name, last_name) VALUES ($enroll, '$username', $password, '$firstname', '$lastname', '$actype')"; mysql_query($sql, $connect) or die("coudn't connnect to DB"); } } echo "<html> <head> <title>Register Form</title> </head> <body>"; include(form.inc); echo "</body></html>"; ?> the error is Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\vits\register.php on line 30 please help me on this.... Similar TutorialsHi, I was looking to add pagination to my site and I found a resource for it at http://www.w3cgallery.com/w3c-blog/php-mysql-ajax-hacks-trick/ajax-fetch-records-by-phpmysql-with-pagination however, I downloaded the source and eventhough I've changed the database connection, table fields it still comes up with an error "Parse error: syntax error, unexpected T_ELSE on line 95", I appreciate it if anyone could help! thanks! Code: [Select] <?php $dbhost = 'localhost'; $dbuser = 'xxxxx'; $dbpass = 'xxxxx'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'xxxxx'; mysql_select_db($dbname); ############# must create your db base connection $strPage = $_REQUEST[Page]; if($_REQUEST[mode]=="Listing"){ $query = "SELECT * FROM user"; $result = mysql_query($query) or die(mysql_error()); $Num_Rows = mysql_num_rows ($result); ########### pagins $Per_Page = 5; // Records Per Page $Page = $strPage; if(!$strPage) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $query.=" order by Id ASC LIMIT $Page_Start , $Per_Page"; $result = mysql_query($query) or die(mysql_error()); ?> <table border="0"> <tbody> <tr> <td>Name</td> <td>Email</td> </tr> <?php // Insert a new row in the table for each person returned if(mysql_num_rows($result) > 0 ) { while($data= mysql_fetch_array($result)){ ?> <tr> <td><?php echo $data['Name'] ?></td> <td><?php echo $data['Email'] ?></td> </tr> <div class="resultbg pagination"> <!--Total <?php //echo $Num_Rows;?> Record : --> <? } if($Prev_Page) { echo " <li><a href=\"JavaScript:SANAjax('Listing','$Prev_Page')\"> << Back</a> </li>"; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo " <li><a href=\"JavaScript:SANAjax('Listing','$i')\">$i</a> </li>"; } else { echo "<li class='currentpage'><b> $i </b></li>"; } } if($Page!=$Num_Pages) { echo " <li><a href=\"JavaScript:SANAjax('Listing','$Next_Page')\">Next >></a> </li>"; } ?> </div> <?php ############ } else{ echo "<div class='error'>No Records Found!</div>"; } } ################ end I'm working on a script that take information from a form and enters it into a mysql database. Everything was working except that the way it is written you must select an image to upload to your profile. I wanted to make the image upload part optional so I added an if/else to the script. If (user supplies image) { process image } else { use missing image icon } I'm getting the following error :Parse error: syntax error, unexpected T_ELSE ... on line 70 (which is where I have my else statement. From reading the forums it sounds like I'm missing a curly brace, but there I think I have the braces right. Here is the part of the code described. Line 70 is :else { Code: [Select] <?php // if user provided image if (!empty($_FILES[$image_fieldname])) { // Make sure we didn't have an error uploading the image ($_FILES[$image_fieldname]['error'] == 0) or handle_error("the server couldn't upload the image you selected.", $php_errors[$_FILES[$image_fieldname]['error']]); // Is this file the result of a valid upload? // The @ supresses PHP's errorfor this and uses our custom version instead. @is_uploaded_file($_FILES[$image_fieldname]['tmp_name']) or handle_error("you were trying to do something naughty. Shame on you!", "Uploaded request: file named '{$_FILES[$image_fieldname]['tmp_name']}'"); // Is this actually an image? @getimagesize($_FILES[$image_fieldname]['tmp_name']) or handle_error("you selected a file for your picture that isn't an image.", "{$_FILES[$image_fieldname]['tmp_name']} isn't a valid image file."); // Name the file uniquely $now = time(); while (file_exists($upload_filename = $upload_dir . $now . '-' . $_FILES[$image_fieldname]['name'])) { $now++; // Finally, move the file to its permanent location @move_uploaded_file($_FILES[$image_fieldname]['tmp_name'], $upload_filename) or handle_error("we had a problem saving your image to its permanent location.", "permissions or related error moving file to {$upload_filename}"); } // end if user provided image else { // set file name equal to missing picture icon $upload_filename = "uploads/profile_pics/missing_user.png"; } ?> I also inclused the entire file if you need to see that. Code: [Select] <?php require_once 'scripts/app_config.php'; require_once 'scripts/database_connection.php'; $upload_dir = SITE_ROOT . "uploads/profile_pics/"; $image_fieldname = "user_pic"; // Potential PHP upload errors $php_errors = array(1 => 'Maximum file size in php.ini exceeded', 2 => 'Maximum file size in HTML form exceeded', 3 => 'Only part of the file was uploaded', 4 => 'No file was selected to upload.'); $first_name = trim($_REQUEST['first_name']); $last_name = trim($_REQUEST['last_name']); $username = trim($_REQUEST['username']); $password = trim($_REQUEST['password']); $email = trim($_REQUEST['email']); $bio = trim($_REQUEST['bio']); $facebook_url = str_replace("facebook.org", "facebook.com", trim($_REQUEST['facebook_url'])); $position = strpos($facebook_url, "facebook.com"); if ($position === false) { $facebook_url = "http://www.facebook.com/" . $facebook_url; } $twitter_handle = trim($_REQUEST['twitter_handle']); $twitter_url = "http://www.twitter.com/"; $position = strpos($twitter_handle, "@"); if ($position === false) { $twitter_url = $twitter_url . $twitter_handle; } else { $twitter_url = $twitter_url . substr($twitter_handle, $position + 1); } // if user provided image if (!empty($_FILES[$image_fieldname])) { // Make sure we didn't have an error uploading the image ($_FILES[$image_fieldname]['error'] == 0) or handle_error("the server couldn't upload the image you selected.", $php_errors[$_FILES[$image_fieldname]['error']]); // Is this file the result of a valid upload? // The @ supresses PHP's errorfor this and uses our custom version instead. @is_uploaded_file($_FILES[$image_fieldname]['tmp_name']) or handle_error("you were trying to do something naughty. Shame on you!", "Uploaded request: file named '{$_FILES[$image_fieldname]['tmp_name']}'"); // Is this actually an image? @getimagesize($_FILES[$image_fieldname]['tmp_name']) or handle_error("you selected a file for your picture that isn't an image.", "{$_FILES[$image_fieldname]['tmp_name']} isn't a valid image file."); // Name the file uniquely $now = time(); while (file_exists($upload_filename = $upload_dir . $now . '-' . $_FILES[$image_fieldname]['name'])) { $now++; // Finally, move the file to its permanent location @move_uploaded_file($_FILES[$image_fieldname]['tmp_name'], $upload_filename) or handle_error("we had a problem saving your image to its permanent location.", "permissions or related error moving file to {$upload_filename}"); } // end if user provided image else { // set file name equal to missing picture icon $upload_filename = "uploads/profile_pics/missing_user.png"; } $insert_sql = sprintf("INSERT INTO users " . "(first_name, last_name, username, " . "password, email, " . "bio, facebook_url, twitter_handle, " . "user_pic_path) " . "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');", mysql_real_escape_string($first_name), mysql_real_escape_string($last_name), mysql_real_escape_string($username), mysql_real_escape_string(crypt($password, $username)), mysql_real_escape_string($email), mysql_real_escape_string($bio), mysql_real_escape_string($facebook_url), mysql_real_escape_string($twitter_handle), mysql_real_escape_string($upload_filename)); // Insert the user into the database mysql_query($insert_sql) or handle_error(mysql_error()); // Redirect the user to the page that displays user information header("Location: show_user.php?user_id=" . mysql_insert_id()); ?> Here is my code that the probelm is in the line is 1162 if ($num == '')($num = '1'); $frts = ($num*PPPAGE-PPPAGE); if($siteType == "US"){($siteid = '0&language=en-US') && ($sitenum = 'salic=0');} if($siteType == "UK"){($siteid = '3&language=en-GB') && ($sitenum = 'salic=3');} if($siteType == "AU"){($siteid = '15&language=en-AU') && ($sitenum = 'salic=15');} if($siteType == "CA"){($siteid = '2&language=en-CA') && ($sitenum = 'salic=2');} if($siteType == "AT"){($siteid = '16&language=de-AT') && ($sitenum = 'salic=16');} if($siteType == "BE"){($siteid = '123&language=nl-BE') && ($sitenum = 'salic=23');} if($siteType == "FR"){($siteid = '71&language=fr-FR') && ($sitenum = 'salic=71');} if($siteType == "NL"){($siteid = '146&language=nl-NL') && ($sitenum = 'salic=146');} if($siteType == "IT"){($siteid = '101&language=it-IT') && ($sitenum = 'salic=101');} if($siteType == "ES"){($siteid = '186&language=es-ES') && ($sitenum = 'salic=186');} if($siteType == "SG"){($siteid = '216') && ($sitenum = 'salic=180');} if($siteType == "IN"){($siteid = '203&language=en-IN') && ($sitenum = 'salic=95');} $random = rand(0, 1); if ($cloak == '1'){ if ($random == '0'){ $RSSFEEDS = array( 0 => "http://rss.api.ebay.com/ws/rssapi?FeedName=SearchResults&siteId=".$siteid."&output=RSS20&fss=".$front->fss."&sasl=".$front->sellerid."&sacat=".$front->catid."&ftrt=1&fbd=1&sabdlo=".$front->minbid."&sabdhi=".$front->maxbid."&saprclo=".$front->minprice."&saprchi=".$front->maxprice."&floc=1&saslop=1&fsop=$front->sort&fsoo=$front->fsoo&from=R6&fss=0&sacur=0&afepn=".CJID."&customid=".$front->sid."&saslc=0&fcl=3&saaff=afepn&catref=C5&frpp=100&satitle=".urlencode($front->q)."+".urlencode($sitewidequery)."&ftrv=1&fts=$srchdesc&".$sitenum."&sascs=".$front->bin."&fspt=".$front->local."&fpos=".$front->zip."&sadis=".$front->miles."&frts=$frts", );} else { $RSSFEEDS = array( 0 => "http://rss.api.ebay.com/ws/rssapi?FeedName=SearchResults&siteId=".$siteid."&output=RSS20&fss=".$front->fss."&sasl=".$front->sellerid."&sacat=".$front->catid."&ftrt=1&fbd=1&sabdlo=".$front->minbid."&sabdhi=".$front->maxbid."&saprclo=".$front->minprice."&saprchi=".$front->maxprice."&floc=1&saslop=1&fsop=$front->sort&fsoo=$front->fsoo&from=R6&fss=0&sacur=0&afepn=".$cjid2."&customid=".$front->sid."&saslc=0&fcl=3&saaff=afepn&catref=C5&frpp=100&satitle=".urlencode($front->q)."+".urlencode($sitewidequery)."&ftrv=1&fts=$srchdesc&".$sitenum."&sascs=".$front->bin."&fspt=".$front->local."&fpos=".$front->zip."&sadis=".$front->miles."&frts=$frts", ); } else { if ($random == '0'){ $RSSFEEDS = array( 0 => "http://rss.api.ebay.com/ws/rssapi?FeedName=SearchResults&siteId=".$siteid."&output=RSS20&fss=".$front->fss."&sasl=".$front->sellerid."&sacat=".$front->catid."&ftrt=1&fbd=1&sabdlo=".$front->minbid."&sabdhi=".$front->maxbid."&saprclo=".$front->minprice."&saprchi=".$front->maxprice."&floc=1&saslop=1&fsop=$front->sort&fsoo=$front->fsoo&from=R6&fss=0&sacur=0&afepn=".CJID."&customid=".$front->sid."&saslc=0&fcl=3&saaff=afepn&catref=C5&frpp=100&satitle=".urlencode($front->q)."+".urlencode($sitewidequery)."&ftrv=1&fts=$srchdesc&".$sitenum."&sascs=".$front->bin."&fspt=".$front->local."&fpos=".$front->zip."&sadis=".$front->miles."&frts=$frts", ); } else { $RSSFEEDS = array( 0 => "http://rss.api.ebay.com/ws/rssapi?FeedName=SearchResults&siteId=".$siteid."&output=RSS20&fss=".$front->fss."&sasl=".$front->sellerid."&sacat=".$front->catid."&ftrt=1&fbd=1&sabdlo=".$front->minbid."&sabdhi=".$front->maxbid."&saprclo=".$front->minprice."&saprchi=".$front->maxprice."&floc=1&saslop=1&fsop=$front->sort&fsoo=$front->fsoo&from=R6&fss=0&sacur=0&afepn=".$cjid2."&customid=".$front->sid."&saslc=0&fcl=3&saaff=afepn&catref=C5&frpp=100&satitle=".urlencode($front->q)."+".urlencode($sitewidequery)."&ftrv=1&fts=$srchdesc&".$sitenum."&sascs=".$front->bin."&fspt=".$front->local."&fpos=".$front->zip."&sadis=".$front->miles."&frts=$frts", ); } } if (!isset($feedid)) $feedid = 0; $rss_url = $RSSFEEDS[$feedid]; //echo $rss_url; it have something to do with the else but i have no idea. please help thank you Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\mywork\unique.php on line 15 <html> <head> <title> </title> </head> <body bgproperties="fixed"> <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $con = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'mywork'; mysql_select_db($dbname, $con); $sql=mysql_query(insert into users (regno,name,gender,date,month,year,emailid,cell,paddress,caddress,incometype,incomeamt,dad,fyes,dadocup,mom,myes,momocup,password) VALUES ('$_POST[regno]','$_POST[name]','$_POST[gender]','$_POST[date]','$_POST[month]','$_POST[year]','$_POST[emailid]','$_POST[cell]','$_POST[paddress]','$_POST[caddress]','$_POST[incometype]','$_POST[incomeamt]','$_POST[dad]','$_POST[fyes]','$_POST[dadocup]','$_POST[mom]','$_POST[myes]','$_POST[momocup]','$_POST[password]')"); $sql1=mysql_fetch_array($sql); $result = @mysql_query($SQl1); $result="SELECT * FROM users WHERE regno='$regno'"; while($row = mysql_fetch_array($result)) { //echo $row['regno']."regno<br>"; //echo $row['name']."name<br>"; //echo $row['gender']."gender<br>"; //echo $row['date']."date<br>"; //echo $row['month']."month<br>"; //echo $row['year']."year<br>"; //echo $row['emailid']."emailid<br>"; //echo $row['cell']."cell<br>"; //echo $row['paddress']."paddress<br>"; //echo $row['caddress']."caddress<br>"; //echo $row['incometype']."incometype<br>"; //echo $row['incomeamt']."incomeamt<br>"; //echo $row['dad']."dad<br>"; //echo $row['fyes']."fyes<br>"; //echo $row['dadocup']."dadocup<br>"; //echo $row['mom']."mom<br>"; //echo $row['myes']."myes<br>"; //echo $row['momocup']."momocup<br>"; //echo $row['password']."password<br>"; } echo "Thanks for Register!"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?> <form name="security" action="index.php" method="post"> <input type="submit" value="click here to login"> </form> </body> </html> I don`t get it, waht is wrong?! Code: [Select] <?php require_once 'auth.php'; if (!isset($_SESSION['SESS_VERIFY'])) { header("location: access-denied.php"); exit(); } if ($_SESSION['lang'] == 'Ro') { // setare data romania date_default_timezone_set('Europe/Bucharest'); $today = getdate(); $zi = $today['mday']; $luna = $today['mon']; $lunastring = $today['month']; $an = $today['year']; $data = $zi.$luna.$an; $data = (string)$data; $ora = date('H:i:s'); $msg = array(); $err = array(); $luni = array ( 1=>'Ianuarie', 2=>'Februarie', 3=>'Martie', 4=>'Aprilie', 5=>'Mai', 6=>'Iunie', 7=>'Iulie', 8=>'August', 9=>'Septembrie', 10=>'Octobrie', 11=>'Noiembrie', 12=>'Decembrie'); // comun const SQL_ERR = 'SQL statement failed with error: '; const ADD_MODEL = 'ADAUGA UN MODEL NOU'; . .many constants.. . } elseif ($_SESSION['lang'] == 'It') {... Thank you!
Hello everyone,
1 <?php
7 // Create connection
10 // Check connection
14 $firstname = $conn->real_escape_string($_REQUEST['firstname']); 25 $sql2 = "INSERT INTO countries VALUES ('$country')"; 27 $sql3 = "INSERT INTO Contacts (firstname, lastname, address, city, country, phone, email) VALUES ('$firstname', '$lastname', '$address', $city, $country, '$phone_number','$email')";
29 SELECT * FROM cities;
if($conn->query($sql2) === true){
if($conn->query($sql3) === true){ I just enabled error reporting and I am not that familiar with it. I know I have an error some where around line 33. I know I am missing a bracket or a comma or some other syntax error I just cannot find where the error is. Below is my script. Thanks for any help. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Airline Survey</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="author" content="Revised by abc1234"/> </head> <body> <?php $WaitTime = addslashes($_POST["wait_time"]); $Friendliness = addslashes($_POST["friendliness"]); $Space = addslashes($_POST["space"]); $Comfort = addslashes($_POST["comfort"]); $Cleanliness = addslashes($_POST["cleanliness"]); $Noise = addslashes($_POST["noise"]); if (empty($WaitTime) || empty($Friendliness) || empty($Space) || empty($Comfort) || empty($Cleanliness) || empty($Noise)) echo "<hr /><p>You must enter a value in each field. Click your browser's Back button to return to the form.</p><hr />"; else { $Entry = $WaitTime . "\n"; $Entry .= $Friendliness . "\n"; $Entry .= $Space . "\n"; $Entry .= $Comfort . "\n"; $Entry .= $Cleanliness . "\n"; $Entry .= $Noise . "\n"; $SurveyFile = fopen("survey.txt", "w") } if (flock($SurveyFile, LOCK_EX)) { if (fwrite($SurveyFile, $Entry) > 0) { echo "<p>The entry has been successfully added.</p>"; flock($SurveyFile, LOCK_UN; fclose($SurveyFile); else echo "<p>The entry could not be saved!</p>"; } else echo "<p>The entry could not be saved!</p>"; } ?d> <p><a href="AirlineSurvey.html">Return to Airline Survey</a></p> </body> </html> I have been trying to get my files to upload onto a computer and I receive this message: Parse error: syntax error, unexpected T_STRING in /home/content/19/6550319/html/listing.php on line 27. Line 27 is how the php logs into my SQL. The problem is that I was able to log in before. I just made changes to the form by adding a dropdown menu and price and now it says it doesnt parse. Can anyone figure this out. I will include the code without the login information because the forum is public but I did put the words left out for you to see where I took out the passcodes. Code: [Select] <?php //This is the directory where images will be saved $target = "potofiles/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $price=$_POST['price']; $gig=$_POST['giga']; $yesg=$_POST['yesg']; $pic=($_FILES['photo']['name']); $pic2=($_FILES['phototwo']['name']); $pic3=($_FILES['photothree']['name']); $pic4=($_FILES['photofour']['name']); $description=$_POST['iPadDescription']; $condition=$_POST['condition']; $fname=$_POST['firstName']; $lname=$_POST['lastName']; $email=$_POST['email'] // Connects to your Database mysql_connect ("left out", "left out", "left out") or die(mysql_error()) ; mysql_select_db("left out") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO listing (price,giga,yesg,photo,phototwo,photothree,photofour,iPadDescription,condition,firstName,lastName,email) VALUES ('$price', '$gig', '$yesg', '$pic', '$pic2', '$pic3', '$pic4', '$description', '$condition', '$fname', '$lname', '$email')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } echo date("m/d/y : H:i:s", time()) ?> Hi folks, I am a complete n00b at php and mysql. I am teaching myself from books and the WWW, but alas I am stuck... the error I get is: Parse error: syntax error, unexpected T_STRING in X:\xampp\htdocs\search.php on line 7 here is the code: <?php mysql_connect ("localhost", "user", "password") or die (mysql_error()); mysql_select_db ("it_homehelp_test") or die (mysql_error()); $term = $_POST['term']; $sql = $mysql_query(select * from it_homehelp_test where ClientName1 like '%term%'); <<<------this is line 7 while ($row = mysql_fetch_array($sql)){ echo 'Client Name:' .$row['ClientName1']; echo 'Address:' .$row['Address1']; echo 'Phone:' .$row['Tel1']; } ?> Any help you can offer would be great. I can also post the ".html" file that creates the search bar if it is needed. Thanks Hey Everyone, I'm getting this error when I submit my contact form. Parse error: syntax error, unexpected $end in /home1/user/public_html/contact/process.php on line 22 I got this code from a video on youtube. http://www.youtube.com/watch?v=rdsz9Ie6h7I If I made a mistake or TYPO please let me know. Thanks! Here's my code: <?php $emailSubject = 'Contact Form Submission'; $sendto = 'info@mydomain.com'; $nameField = $_Post['name']; $emilField = $_Post['email']; $phoneField = $_Post['phone']; $SubjectField = $_Post['subject']; $messageField = $_Post['message']; $body = <<<EOD <br><hl><br>This Form was submitted from the Domain.com contact page.<br> Name: $name<br> E-Mail: $email<br> Phone: $phone<br> Subject: $subject<br> Message: $message<br> BOD; $headers = "FROM: $email\r\n"; $headers .="Content-Type: text/html\r\n"; $success = mail($sendto, $emailSubject, $body, $headers); ?> <?php error_reporting(E_ALL); include_once("conninfo2.php"); include_once('classes/bcrypt.php'); class User { private $_bcrypt; $this->_bcrypt = new Bcrypt; if($this->_bcrypt->verify($password, $this->data()->password)){ } if(isset($_POST['username'])) { $firstname = strip_tags($_POST['firstname']); $surname = strip_tags($_POST['surname']); $pnumber = strip_tags($_POST['pnumber']); $username = strip_tags($_POST['username']); $email1 = strip_tags($_POST['email1']); $email2 = strip_tags($_POST['email2']); $password1 = $_POST['password1']; $password2 = $_POST['password2']; //code below will make sure all fields are filled in if(trim($firstname) == "" || trim($surname) == "" || trim($pnumber) == "" || trim($username) == "username" || trim($email1) == "" || trim($email2) == "" ||trim($password1) == "" || trim($password2) == "") { echo "Error, all fileds need to be filled in"; $db = null; exit(); } //code below checks that the emails entered both match one another if($email1 != $email2) { echo "Emails do not match, please try again"; $db = null; exit(); } //code below matches the passwords entered else if($password1 != $password2) { echo "Passwords do not match please try again"; exit(); } if(!filter_var($email1, FILTER_VALIDATE_EMAIL)) { echo "Your email is invalid, please try again"; $db = null; exit(); } //checks if the email exists within the database $stmt = $db->prepare("SELECT email FROM login WHERE email=:email1 LIMIT 1"); $stmt->bindValue(':email1',$email1, PDO::PARAM_STR); try{ $stmt->execute(); $count = $stmt->rowCount(); } catch(PDOException $e) { echo $e->getMessage(); $db = null; exit(); } //checks if the username exists $usernameSQL = $db->prepare("SELECT username FROM login WHERE username=:username LIMIT 1"); $usernameSQL->bindValue(':username',$username,PDO::PARAM_STR); try{ $usernameSQL->execute(); $usernameCount = $usernameSQL->rowCount(); } catch(PDOExemption $e) { echo $e->getMessage(); $db = null; exit(); } //checks if the email is already within the database if($count > 0) { echo "This email already exists"; $db = null; exit(); } //checks the username if($usernameCount > 0) { echo "This username is unavailable please try another"; $db = null; exit(); } $user = new User; $bcrypt = new Bcrypt; try { $email1->create(array( 'username' => Input::get('username'), 'password1' => $bcrypt->hash(Input::get('password')), 'firstname' => Input::get('name'), 'surname' => Input::get('surname'), 'pnumber' => Input::get('pnumber'), 'email1' => Input::get('email'), 'ipaddress' => Input::get('ipaddress'), 'signup_date' => date('Y-m-d H:i:s'), 'group' => 1 )); //grab the last id used within the database $lastId = $db->lastInsertId(); $stmt3 = $db->prepare("INSERT INTO activated (user, token) VALUES ('$lastId', :token)"); $stmt3->bindValue(':token',$token,PDO::PARAM_STR); $stmt3->execute(); //email activation $from = "From Auto Responder @ Mediaedit <admin@mediaedit.com>"; $subject = "IMPORTANT: Please activate your account"; $link = 'http://mediaed.it/roxanne/activate.php?user='.$lastId.'&token='.$token.''; //email body $message = " Thanks for register with Mediaedit, before your able to use our services you will need to verify your email so that we know your human $link "; //headers $headers = 'MIME-Version: 1.0' . "rn"; $headers .= "Content-type: textrn"; $headers .= "From: Mediaedit"; //send email now mail($email1, $subject, $message, $headers, '-f noreply@mediated.it'); $db->commit(); echo "Thanks for registering, before you can us our services you need to activate your account an email has been sent which you will recieve shortly"; $db = null; exit(); } catch(PDOException $e){ $db->rollBack(); echo $e->getMessage(); $db = null; exit(); } } ?>i keep getting Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION I keep getting an error code when running my php, it states: Parse error: syntax error, unexpected $end in W:\www\blog\login.php on line 33 Line 33 is </html> Code: [Select] <?php mysql_connect ("localhost", "root", ""); mysql_select_db("blog"); ?> <html> <head> <title>Login</title> </head> <body> <?php if(isset($_POST['submit'])){ $name = $_POST['name']; $pass = $_POST['password']; $result = mysql_query("SELECT * FROM users WHERE name='$name' AND pass='$pass'"); $num = mysql_num_rows($result); if($num == 0){ echo "Bad login, go <a href='login.php'>back</a>"; }else{ session_start(); $SESSION ['name'] = $name; header("Location: admin.php"); } ?> <form action='login.php' method='post'> Username: <input type='text' name='name' /><br /> Password: <input type='password' name='password' /><br /> <input type='submit' name='sumbit' value='Login!' /> </form> </body> </html>Can any one advise me whats wrong? i keep getting the above error.. help this is a class of the log entry <?php require_once "config.php"; abstract class DataObject { protected $data = array(); public function__construct( $data ) { foreach ( $data as $key => $value ) { if ( array_key_exists( $key, $this->data )) $this->data[$key] = $value; } } public function getValue( $field ) { if ( array_key_exists( $field, $this->data )) { return $this->data[$field]; } else { die( "field not found" ); } } public function getValueEncoded( $field ) { return htmlspecialchars( $this->getValue( $field )); } protected function connect() { try { $conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD ); $Conn->setAttribute( PDO::ATTR_PERSISTENT, true ); $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); } catch ( PDOException $e->getMessage() ); die( "connection failed: " . $e->getMessage() ); } return $conn; } protected function disconnect( $conn ) { $conn = ""; } } ?> Code: [Select] <?php if (!isset($_POST['submit'])) { ?> <h2>Todays Special</h2> <p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <select name="day"> <option value="1">Monday/Wednesday <option value="2">Tuesday/Thursday <option value="3">Friday/Sunday <option value="4">Saturday </select> input type="submit" name="submit" value="Go"> </form> <?php // get form selection $day = $_POST['day']; // check value and select appropriate item switch ($day) { case 1: $special = 'Chicken in oyster sauce'; break; case 2: $special = 'French onion soup'; break; case 3: $special = 'Pork chops with mashed potatoes and green salad'; break; default: $special = 'Fish and chips'; break; } ?> Hey, I just started using WordPress - I'm a complete newbie, and am super perplexed by this error I'm getting in functions.php. I'm hoping I am just making a simple mistake, but I'd really appreciate some suggestions as to what the issue is. The error: Parse error: syntax error, unexpected T_VARIABLE in /homepages/33/d123623052/htdocs/rap3/wp-content/themes/business-turnkey/functions.php on line 196 That line would be at the very bottom of my code. From what I can tell, this error occurs when the code is missing a punctuation mark like a [ ( { , ' etc. I've been looking over the code for ages, and from what I can see all the brackets have a matching end, there's no out of place punctuation. <?php define('THEME_URI', get_stylesheet_directory_uri()); define('THEME_IMAGES', THEME_URI . '/assets/img'); define('THEME_CSS', THEME_URI . '/assets/css'); define('THEME_JS', THEME_URI . '/assets/js'); define('THEME_TEMPLATES', THEME_URI . '/assets/templates'); $GLOBALS['content_width'] = 900; /* Define Theme Defaults */ $options = get_option('turnkey_theme_options'); if($options['templatestyle'] == null) $options['templatestyle'] = 'modern'; if($options['typography'] == null) $options['typography'] = 'typography1'; function turnkeySlider() { $options = get_option('turnkey_theme_options'); if($options['sliderTimer'] != null) $rotateTimer = $options['sliderTimer']; else $rotateTimer = 5000; ?> <script type="text/javascript" charset="utf-8"> jQuery(document).ready(function($) { $('.slide-container').cycle({ fx: 'scrollHorz',next: '#slide-nav .next',prev: '#slide-nav .prev',pause: 1, timeout:<?php echo $rotateTimer; ?>}); }); </script> <?php } add_action('wp_head', 'turnkeySlider'); require_once ( get_stylesheet_directory() . '/theme-options.php' ); require_once ( 'slider/turnkey-slider.php' ); if (function_exists('register_sidebar')) { register_sidebar(array( 'name'=> 'Homepage Widgets', 'id' => 'homepage_widgets', 'before_widget' => '<div class="widget group %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3>', 'after_title' => '</h3>' )); register_sidebar(array( 'name'=> 'Sidebar 1', 'id' => 'sidebar_1', 'before_widget' => '<div class="widget group %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4>', 'after_title' => '</h4>' )); register_sidebar(array( 'name'=> 'Sidebar 2', 'id' => 'sidebar_2', 'before_widget' => '<div class="widget group %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4>', 'after_title' => '</h4>' )); register_sidebar(array( 'name'=> 'Footer Widgets', 'id' => 'footer-widgets', 'before_widget' => '<div class="widget group %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3>', 'after_title' => '</h3>' )); } if ( function_exists( 'register_nav_menus' ) ) { register_nav_menus( array( 'turnkey_mainnav' => 'TurnKey Main Navigation', 'turnkey_secondary' => 'TurnKey Secondary Navigation' ) ); }; add_theme_support( 'post-thumbnails' ); // Makes Sure thumbnails show up in RSS function do_post_thumbnail_feeds($content) { global $post; if(has_post_thumbnail($post->ID)) { $content = '<div>' . get_the_post_thumbnail($post->ID) . '</div>' . $content; } return $content; } add_filter('the_excerpt_rss', 'do_post_thumbnail_feeds'); add_filter('the_content_feed', 'do_post_thumbnail_feeds'); // Define Thumbnail Images Sizes if ( function_exists( 'add_image_size' ) ) { add_image_size( 'post-thumb-threecol', 390, 200, true ); add_image_size( 'post-thumb-onetwocol', 520, 200, true ); /* Slide Image */ add_image_size( 'special', 580, 340, true ); } if ( !is_admin() ) { // instruction to only load if it is not the admin area function googlejquery() { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'); } add_action('init', 'googlejquery'); wp_register_script('functions', get_bloginfo('template_directory') . '/assets/js/functions.js'); wp_register_script('cycle', get_bloginfo('template_directory') . '/assets/js/cycle.min.js'); wp_register_script('lightbox', get_bloginfo('template_directory') . '/assets/js/lightbox_me.js'); // enqueue the script wp_enqueue_script('jquery'); wp_enqueue_script('functions'); wp_enqueue_script('cycle'); wp_enqueue_script('lightbox'); }; function the_breadcrumb() { if (!is_home()) { echo '<a href="'; echo get_option('home'); echo '">'; bloginfo('name'); echo "</a> » "; if (is_category() || is_single()) { the_category('title_li='); if (is_single()) { echo " » "; the_title(); } } elseif (is_page()) { echo " <span class='current'> "; echo the_title(); echo " </span> "; } } } function rap_register_sidebars() { register_sidebar(array( 'name' => 'Scheduling campaign sidebar', 'id' => 'rap-scheduling-sidebar', 'description' => 'Sidebar for Scheduling Campaign template pages only.', 'before_widget' => '<div class="widget">', 'after_widget' => '</div>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>' )); } // Add Automatic Feed Links add_theme_support('automatic-feed-links'); add_filter('widget_text', 'do_shortcode'); add_action('widgets_init', 'rap_register_sidebars'); // Below added by Jessica 6/24/13 to display Salesforce lookup fields on Gravity Forms field mapping page add_filter('gf_salesforce_skip_reference_types', '__return_false'); // Below added by Jessica to change the field value on the Join Us and Training forms add_action("gform_pre_submission_1", "pre_submission_JoinUs"); add_action("gform_pre_submission_8", "pre_submission_Training"); add_action("gform_pre_submission_15", "pre_submission_HCAP"); function pre_submission_JoinUs($form){ if ($_POST["input_15"] == 'Former Retail Worker') $_POST["input_15"] = 'Retail Worker'; } function pre_submission_Training($form){ if ($_POST["input_18"] == 'Former Retail Worker') $_POST["input_18"] = 'Retail Worker'; } function pre_submission_HCAP($form){ if ($_POST["input_15"] == 'Former Retail Worker') $_POST["input_15"] = 'Retail Worker'; } ?> Edited by motprogram, 11 December 2014 - 04:33 PM. Hey, Its something to do with the ' or \ I know that as Ive been trying alot. Code Code: [Select] if ($this->isAdmin && count ($func_players) > SettingsManager::GetSetting(Settings::BAN_LIMIT)) return $this->sendErrorBox('max', 'You can\'t ban that many Users at once!', 'Gosh', 'iBan'); foreach($func_players as $func_player) $func_player->ban(&this->playerName, $this->isAdmin); return $this->sendErrorBox('max', sprintf( '%s ha%s been banned.' $this->getPlayerString($func_players), count($func_players) == 1 ? 's' : 've'), 'SykoPwns:P', 'Sykos:iBan'); Thanks for your help! Ive tried alot of things I think I could just take out the \ or something!! |