PHP - Unexpected T_constant_encapsed_string
It keeps saying unexpected T_CONSTANT_ENCAPSED_STRING. What is a t_constant_encapsed string and why am I getting there error?
if ( isset( $_POST['menuid'] ) ) { $menuid = (int)$_POST['menuid']; $query = "SELECT COUNT(`sortorder`) AS numOrder FROM `menuitems` WHERE `menu_id` = '".$menuid."'"; $result = mysqli_query ($dbc, $query); $row = mysqli_fetch_array( $result, MYSQL_ASSOC ); $sortorder = $row[ 'numOrder' ] + 1; echo $sortorder; } Similar TutorialsHello. I'm relatively new to PHP and can't figure out what's wrong. function tweet_button () { echo ' <div class="twitter-share vcount"> <a class="twitter-button" rel="external nofollow" title="Share this article on Twitter" href="http://twitter.com/share?text=<?php echo $shareTitle; ?>+-&url=<?php echo $shareUrl; ?> &via=<?php if (!$retweetNick == '') { echo $retweetNick; } ?> &related=<?php if (!$retweetrelate == ''){ echo $retweetrelate; } ?>:<?php if (!$retweetrelate == '') { echo $retweetrelatedesc; } ?>" target="_blank">Tweet this article</a> <span class="twitter-count"><?php echo $retweetInfo; ?></span></div> '; } This was part of the code of a WordPress plugin I'm trying to make and when I try to activate the plugin, it gives me Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\xampp\htdocs\wordpress\wp-content\plugins\sample-plugin\sample-plugin.php on line 51 Line 51 is the line that starts with &related= Thank you. I am getting syntax error, unexpected T_CONSTANT_ENCAPSED_STRING on the date stamp line below but I can't see what is causing the problem. when I comment it out the problem goes away so I know I it is there. please help. $email_message = "Form details below.\n\n"; $email_message = date("m/d/Y")"\n"; Hello guys, I have a problem with the php, I have got an parse error, the error is: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/myuser/public_html/mysite.com/email.php on line 69 <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'user'); define('DB_PASSWORD', 'pass'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $name = clean($_GET['name']); $email = clean($_GET['email']); $comments = clean($_GET['comments']); $rate = clean($_GET['rate']); if($name == '') { $errmsg_arr[] = 'name or member ID missing'; $errflag = true; } else { } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['name'])) { $insert[] = 'member_or_from = \'' . clean($_GET['name']) .'\''; // echo "tested"; } if(isset($_GET['email'])) { $insert[] = 'email_address = \'' . clean($_GET['email']) . '\''; } if(isset($_GET['comments'])) { $insert[] = 'comments = \'' . clean($_GET['comments']) . '\''; } if(isset($_GET['rate'])) { $insert[] = 'rate = \'' . clean($_GET['rate']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); if(isset($name)) { $to = "myemail@myemail.com"; $subject = $type'; $message = '$comments', '$rate'; $headers = 'From: $name '@myemail.com'' mail($to, $subject, $message, $headers); } else { $to = "myemail@myemail.com"; $subject = $type'; $message = '$comments', '$rate'; $headers = 'From: $email' mail($to, $subject, $message, $headers); if (!mysql_query($sql,$link)) { die('Error: ' . mysql_error()); } echo "Thank you for sent us the feedback"; } } } ?> I don't know where it went wrong in line 69. Please could any of you help me to correct the problem I am getting?? Any advise would be much appreciate. Hi, I keep getting the above error when testing out my system. The section of code that is having the error is: if ($_SESSION['username']=='login') { if (isset($_REQUEST['file'])) { $fc = file_get_contents($_REQUEST['file']); $text = explode("<!-- EDITABLE -->",$fc); echo "<form method='post' action=''><textarea name='content'>$text[1]</textarea>"; echo "<p><input type='hidden' name='file' value='".$_REQUEST['file']."' /><input name='submitUpdate' type='submit' value='Update Page'></form>"; } else { // edit to link to your own static html files echo "<p align='center'> <a href="?index.html">Home Page</a><br/> <a href="?contact_us.html">Contact Us</a><br/> //THIS IS THE LINE THATS GIVING ME THE PROBLEM <br/> <em>Click on the links above to edit the files.</em><br/> <a href="?logout">logout</a></p>"; } } Can anybody help? I'd really appreciate it. Thanks in advance Hi im having trouble with this coding and this error: 'Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/fightwa1/public_html/fightrd1.php on line 1' Code: [Select] <?php include 'connect.php'; include 'fightheaderrd1.php'; session_start(); $username = $_SESSION['loginusername']; if (isset($_SESSION['loginusername'])){ echo "<center><h2>Round 1</h2></center><br /><br />"; $result = mysql_query("SELECT * FROM boxerinfo WHERE username = '$username' AND status = 'online'"); while($row = mysql_fetch_array($result)) { echo "<div id='bluecorner'><table border='1' bordercolor='#000000' width='150' align='center'>"; echo "<tr bgcolor='#0000FF'>"; echo "<th align='center'><font color='#FFFFFF'>".$row['username']."</font></th>"; echo "</tr>"; echo "</table></div>"; } $result2 = mysql_query("SELECT * FROM boxerinfo WHERE fighterrequest = '$username' AND status = 'online'"); while($row2 = mysql_fetch_array($result2)) { echo "<div id='redcorner'><table border='1' bordercolor='#000000' width='150' align='center'>"; echo "<tr bgcolor='#990002'>"; echo "<th align='center'><font color='#FFFFFF'>".$row2['username']."</font></th>"; echo "</tr>"; echo "</table></div>"; } ?> <script src="http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js" type="text/javascript">/* script comment */</script> <div id="display"></div> <script type="text/javascript"> //<![CDATA[ // Number of seconds to wait between refreshes var seconds = 10; // Function to handle refreshing every iteration var refresher = function() { // Adding data to the request forces the POST method to be used by jQuery // rather than adding something useless like a timestamp, // send something like the location of the calling page var data_to_send = {location: window.location}; // Load the contents of the page into the <div> $('#display').load('fightlivecommentary.php'); } // Set the function up to execute every "seconds" seconds // Save a reference to the interval so we can stop it with "clearInterval(refreshing)" later var refreshing = setInterval(refresher, seconds * 1000); //]]> </script> <? }else{ echo "Please <b>Sign In</b> above or <a href='signup.php'><b>Sign Up</b></a> to create your boxer!</a>"; } include 'footer.php'; ?> Thanks for any help Hello fellow phpfeaks, I have been working on debugging this script for hours. I am getting this error message: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/heartl20/public_html/sendmail.php on line 58 Here is the php portion of the code with line 58 identified. I don't think that line 58 is really the offender but something in the code is. Your help for this php newbie is much appreciated. Also any suggestions on making this script better would be appreciated also. Code: [Select] <?php include ('class.Date.php'); $oDate = new Date; $sDate = $oDate->GenerateCurrentDate(); // print 'The time is: ' . $sTime; if(!isset($_POST['submit'])) { //This page should not be accessed directly. Need to submit the form. echo "error; you need to submit the form!"; } $firstname = $_POST['FirstName']; $lastname = $_POST['LastName']; $name = $firstname." ".$lastname; $visitor_email = $_POST['Emailadd']; $message = $_POST['spec_request']; $orgname = $_POST['OrgName']; $mailaddress = $_POST['mailaddress']; $city = $_POST['city']; $state = $_POST['Mstate']; $zip = $_POST['zip']; $phone = $_POST['phone']; $ipadd = $_POST['ipadd']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; if(IsInjected($visitor_email)) { echo "Bad email value!"; exit; } $server = "ecbiz76.inmotionhosting.com"; $username = "heartl20_cntacts"; $password = "HeartConts1"; $link = @mysql_connect ($server, $username, $password) or die (mysql_error()); if (!@mysql_select_db("heartl20_contactusdb", $link)) { echo "<p>There has been an error. This is the error message:</p>"; echo "<p><strong>" . mysql_error() . "</strong></p>"; echo "Please Contact Your Systems Administrator with the details"; } $sql = "SELECT * FROM directemail"; $sql .= " WHERE (Rec_ID = '{$_POST['SelRecp']}')"; $result = mysql_query($sql, $link); if (!$result) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit(); } while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $Rec_ID = $row['Rec_ID']; $FullName = $row['FullName']; $Function = $row['Function']; $EmailAdd = $row['EmailAdd']; } $email_from = 'postmaster@heartlandindustries.org'; $email_subject = "Contact Us Form submission"; $email_body = "$FullName, You have received an inquiry from $name \r" "Here is the message: \r" //This is line 58 "$message \r" "Additional Information: \r" "Mailing Address: $mailaddress \r" "$city $state, $zip \r" "Phone: $phone \r" "This message was sent on: $sDate From: $ipadd \r" "Using: $httpagent "; $to = "harold@haroldrau.com"; $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to,$email_subject,$email_body,$headers); // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } /* Closes Connection to the MySQL server */ mysql_close ($link); ?> Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\xampp\htdocs\hk\config.php on line 22 Code: <?php // require the hotels config file require "../config.php"; // start the sessions session_start(); // check if the user is signed in if(!isset($_SESSION['username'])) { Header("Location: ../index.php?error=signedout"); } elseif(!isset($_SESSION['account'])) { Header("Location: ../index.php?error=signedout"); } // process all the queries in here // do the user related ones $assoc = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE username = '".$_SESSION['username']."'")); $username = $assoc'['username']'; $ranknum = $assoc['rank']; // parse the rank $parseRank = mysql_fetch_assoc(mysql_query("SELECT * FROM ranks WHERE id = '{$ranknum}' $rank = $parseRank['name']; // get server status $sStatus = mysql_fetch_assoc(mysql_query("SELECT * FROM server_status")); $usersonline = $sStatus['users_online']; $roomsloaded = $sStatus['rooms_loaded']; $status = $sStatus['status']; echo $assoc['rank']; exit(); if($assoc['rank'] < 6) { header("Location: ../index.php"); } ?> On line 22; $username = $assoc'['username']'; I keep geting this i dont whats worong with it Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING line 1 Code: [Select] <?php session_start(); $username = $_SESSION['username']; ?> <?php require "header.php"; ?> <?php if ($username){?> <?php echo "<br/><br/>"."Welcome <b>$username</b>, <a href='logout.php'>Logout</a href>"."<br /><br />"; ?> <?php echo "<center><h2>Hey $username! What do you want to do?</h2></center>"; ?> <div id="ahome"> <table> <form action="createnews" method="post"> <tr> <td><td> <td><td> </tr> <tr> <td>Title of Article<td> <td><input type="text" size="45" name="newstitle"/><td> </tr> <tr> <td>Author of Article<td> <td><input type="text" size="40" name="by"/><td> </tr> <tr> <td>Body of Article<td> <td><textarea cols="45" rows="25" name="newsbody"></textarea><td> </tr> <tr> <td><td> <td><input type="submit" name="submitbtn" value="Add News"/><td> </tr> </form></table> </div> <div id="rhome"> New Admin Stuff Coming Soon....<br></br> <a href="#">Create a New Page</a><br></br> <a href="#">Edit a Review</a> </div> <?php } else echo "<font color='red'><center><h1>You must be logged in to view this page.</h1></center></font>"; ?> <?php require "footer.php"; ?> I know this is probably a missing curly bracket or some other syntax, but I can't seem to spot it, anyone see it? i get this error btw. Parse error: syntax error, unexpected $end in C:\Program Files\xampp\htdocs\cameo\login.php on line 39 <?php session_start(); //sql variables $server = "localhost"; $user = "root"; $pass = ""; $db = "cameo"; //iff user isn't logged in, try to log them in if(!isset($_SESSION['username'])){ if(isset($_POST['submit'])){ //connect to database $dbc = mysqli_connect($server, $user, $pass, $db); //grab entered form data $user_username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $user_password = mysqli_real_escape_string($dbc, trim($_POST['username'])); //if both username and password are entered then find a match in the database if((!empty($user_username)) && (!empty($user_password))) { //look up the username and password in the database $query = "SELECT username FROM cameo WHERE username = '$user_username' AND '$user_password'"; $data = mysqli_query($dbc, $query); //authenticate if data matches a row if(mysqli_num_rows($data) == 1){ //login is okay $row = mysqli_fetch_array($data); $_SESSION['username'] = $row['username']; $_SESSION['is_admin'] = $row['is_admin']; header('Location:index.php'); } else { //username and password are incorrect or missing, so send a message $error_msg = 'Sorry, you must enter a valid username and password to log in.'; } } } ?> Hi, could someone please tell me why I'm getting an unexpected { error in the following code. I have went over it several times and everything seems to be matching. Code: [Select] <?php require_once("functions.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php DatabaseConnection(); $query= "SELECT * FROM treats"; $result_set= mysql_query($query); /*if( $result_set = mysql_query($query) ) { while( $products = mysql_fetch_row($result_set) ) { echo $products[0]; echo $products[1]; echo $products[2]; echo $products[3]; echo $products[4]; echo "<img src=\"{$products[5]}\">"; // assuming this is where the image url is } } //print_r(mysql_fetch_row($result_set));*/ $output = "<table>"; while($row = mysql_fetch_array($result)) { $productDetail1['product_id']; $productDetail2['product_title']; $productDetail3['product_Description']; $productDetail4['price']; $productDetail5['product_pic']; $output .= (" <tr> <td>".$productDetail1['product_id'] ."</td> </tr> ") } $output .= "</table>"; ?> </body> </html> Am I blind? I don't see the problem with this code. It says: Parse error: syntax error, unexpected '}' in /data/21/2/40/160/2040975/user/2235577/htdocs/edit_user1.php on line 35 Code: [Select] <html> <body> <?php if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { $id = $_POST['id']; } else { echo 'you have reached this page in error. no variable passed'; exit(); } // that was the part to check for passed variables. This is what does something with it require ('databaseconnect.php'); if (isset($_POST['submitted'])) { $errors = array(); } if (empty($_POST['scientific name'])) { $errors[] = 'you did not enter a scientific name' } else { $sn = escape_data($_POST['scientific_name']); } // now the common name if (empty($_POST['common_name_english'])) { $errors[] = 'you did not enter a common name' } else { $cn = escape_data($_POST['scientific_name_english']); } // now make changes if (empty($errors)) { $query = "UPDATE table SET plant_name='$id', scientific_name='$sn', common_name_english='$cn' WHERE plant_name=$id"; $result = $mysql_query ($query); if (mysql_affected_row() == 1) { echo 'edit a plant<br> The plant has edited' } else { echo 'system error<br> the plant could not be edited due to a system error.'; echo mysql_error() . 'query:' . $query ; exit(); } } else { echo 'error<br> something already insystem or did not work.'; } } else { echo 'error<br>'; foreach ($errors as $msg) { echo " - $msg<br>"; } echo ' please try again'; } // end of if } // endo of submit condition // always show form $query = "SELECT scientific_name, Common_name_english FROM table WHERE plant_name=$id"; $result = $mysql_query ($query); if(mysql_num_rows($result) == 1) { $row mysql fetch_array ($result); echo 'edit a user' <form action="edit_user1.php" method="post"> scientific name: <input type="text" name="scientific_name" size="45" value="' . $row[scientific_name] . '"><br> common name: <input type="text" name="common_name_english" size="45" value="' . $row[common_name_english] . '"><br> <input type="submit" name="submit" value="submit" /><br> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id . '"/> </form>'; } else { echo 'page error'; } mysql_close(); </body> </html> Just trying to do a basic query... not working and don't know why: here is inserts.php: <?php $username="wormste1_barry"; $password="barry"; $database="wormste1_barry"; $CarName=$_POST['CarName']; $CarTitle=$_POST['CarTitle']; $CarPrice=$_POST['CarPrice']; $CarMiles=$_POST['CarMiles']; $CarDescription=$_POST['CarDescription']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO tablename VALUES ('','$CarName','$CarTitle','$CarPrice','$CarMiles','$CarDescription'); mysql_query($query); mysql_close(); ?> That parses the simple form of : form.html: <HTML> <HEAD> </HEAD> <BODY> <form action="inserts.php" method="post"> car Name: <input type="text" name="CarName"><br> Car Title: <input type="text" name="CarTitle"><br> Car Price: <input type="text" name="CarPrice"><br> Car Miles: <input type="text" name="CarMiles"><br> Car Description: <input type="text" name="CarDescription"><br> <input type="Submit"> </form> </BODY> </HTML> I get the error: Parse error: syntax error, unexpected $end in /home/wormste1/public_html/tilburywebdesign/shop/FTPServers/barryottley/showroom/inserts.php on line 23 Don't know whats wrong? Hi, could someone please tell me why I'm getting unexpected $end error in the following code? <?php function documentType(){ echo <<<HEREDOC <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ` ` "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> } HEREDOC; ?> hello i keep getting an error Parse error: syntax error, unexpected $end in /home/cookbook/public_html/cookbook.php on line 144 can someplease explain it to me? here is the code [list type=decimal] [li][/li] [li][/li] [/list]<?php //include("include/session.php"); @session_start(); // Start_session, check if user is logged in or not, and connect to the database all in one included file include_once("scripts/checkuserlog.php"); // Include the class files for auto making links out of full URLs and for Time Ago date formatting include_once("wi_class_files/autoMakeLinks.php"); include_once ("wi_class_files/agoTimeFormat.php"); // Create the two objects before we can use them below in this script $activeLinkObject = new autoActiveLink; $myObject = new convertToAgo; ?> <?php // Include this script for random member display on home page include_once "scripts/homePage_randomMembers.php"; ?> <?php $sql_blabs = mysql_query("SELECT id, mem_id, the_blab, blab_date FROM blabbing ORDER BY blab_date DESC LIMIT 30"); $blabberDisplayList = ""; // Initialize the variable here while($row = mysql_fetch_array($sql_blabs)){ $blabid = $row["id"]; $uid = $row["mem_id"]; $the_blab = $row["the_blab"]; $notokinarray = array("fag", "gay", "shit", "fuck", "stupid", "idiot", "asshole", "cunt", "douche"); $okinarray = array("sorcerer", "grey", "shug", "farg", "smart", "awesome guy", "asshole", "cake", "dude"); $the_blab = str_replace($notokinarray, $okinarray, $the_blab); $the_blab = ($activeLinkObject -> makeActiveLink($the_blab)); $blab_date = $row["blab_date"]; $convertedTime = ($myObject -> convert_datetime($blab_date)); $whenBlab = ($myObject -> makeAgo($convertedTime)); //$blab_date = strftime("%b %d, %Y %I:%M:%S %p", strtotime($blab_date)); // Inner sql query $sql_mem_data = mysql_query("SELECT id, username, firstname, lastname FROM myMembers WHERE id='$uid' LIMIT 1"); //die($sql_mem_data); while($row = mysql_fetch_array($sql_mem_data)){ $uid = $row["id"]; $username = $row["username"]; $firstname = $row["firstname"]; if ($firstname != "") {$username = $firstname; } // (I added usernames late in my system, this line is not needed for you) /////// Mechanism to Display Pic. See if they have uploaded a pic or not ////////////////////////// $ucheck_pic = "members/$uid/image01.jpg"; $udefault_pic = "members/0/image01.jpg"; if (file_exists($ucheck_pic)) { $blabber_pic = '<div style="overflow:hidden; width:40px; height:40px;"><img src="' . $ucheck_pic . '" width="40px" border="0" /></div>'; // forces picture to be 100px wide and no more } else { $blabber_pic = "<img src=\"$udefault_pic\" width=\"40px\" height=\"40px\" border=\"0\" />"; // forces default picture to be 100px wide and no more } $blabberDisplayList .= ' <table width="100%" align="center" cellpadding="4" bgcolor="#CCCCCC"> <tr> <td width="7%" bgcolor="#FFFFFF" valign="top"><a href="profile.php?id=' . $uid . '">' . $blabber_pic . '</a> </td> <td width="93%" bgcolor="#EFEFEF" style="line-height:1.5em;" valign="top"><span class="greenColor textsize10">' . $whenBlab . ' <a href="profile.php?id=' . $uid . '">' . $username . '</a> said: </span><br /> ' . $the_blab . '</td> </tr> </table>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta name="Description" content="Web Intersect is a deft combination of powerful free open source software for social networking, mixed with insider guidance and tutorials as to how it is made at its core for maximum adaptability. The goal is to give you a free website system that has a network or community integrated into it to allow people to join and interact with your website when you have the need." /> <meta name="Keywords" content="web intersect, how to build community, build social network, how to build website, learn free online, php and mysql, internet crossroads, directory, friend, business, update, profile, connect, all, website, blog, social network, connecting people, youtube, myspace, facebook, twitter, dynamic, portal, community, technical, expert, professional, personal, find, school, build, join, combine, marketing, optimization, spider, search, engine, seo, script" /> <title>CookBookers</title> <link href="style/main.css" rel="stylesheet" type="text/css" /> <link rel="icon" href="favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <script src="js/jquery-1.4.2.js" type="text/javascript"></script> <style type="text/css"> #Layer1 { height:210px; background-image: url(images/top_container_bg_recipes_new.gif); } body { background-color: #3c60a4; } </style> </head> <body> <?php include_once "header_template.php"; ?> <center> <table cellpadding="0px" cellspacing="0px" style="border:0px solid #666666;" width="950"> <tr> <td> <table width="95%" height="22" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color:#F2F2F2; border:0px solid #666666;"> <tr> <td style="padding-left:45px;"> <?php //die($_SESSION['username']); $qryUsers = "SELECT * from recipies WHERE user='".$_SESSION['username']."'"; //die($qryUsers); $rsUsers = @mysql_query($qryUsers) or die(mysql_error()); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="16%"><h3>All Recipies of </h3></td> <td width="84%"><h3><?php print $_SESSION['username']; ?></h3></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <?php while($rowUsers = @mysql_fetch_object($rsUsers)) { ?> <?php print"<h3>Public Recipes</h3><br>"; $qryUsers = "SELECT * from recipies WHERE user='".$_SESSION['username']."'"; print"<ol>"; $rsUsers = @mysql_query($qryUsers) or die(mysql_error()); if( @mysql_num_rows($rsUsers)>0 ) { while($rowUsers = @mysql_fetch_object($rsUsers) ) { print "<li style='margin:5px 0px;'><a href=description.php?Rid=".$rowUsers->Rid.">".$rowUsers->title."</a></li>"; } } print"</ol>"; ?> </td> </tr> </table> </td> </tr> <tr> </td> </tr> </table> </center> <?php include_once "footer_template.php"; ?> </body> </html> I'm getting a unexpected t_if error and not sure where my fix is. Code: [Select] <?php if($templateVar == '') { $templateVar = 'peach'; //defaulting to be safe } else { $templateVar = $templateVar; //passed from controller } ?> <?php $this->load->view($templateVar . '/header'); ?> <?php $this->load->view($templateVar . '/navigation'); ?> <!-- End Navigation --> <?php $this->load->view($templateVar . '/msgbox'); ?> <?php if((empty($bodyType))||(!isset($bodyType))||(trim($bodyType)=="")){$this->load->view($templateVar . '/body_full');} elseif($bodyType == "full"){$this->load->view($templateVar . '/body_full');} /* Commented out for now, as currently we only have one layout dimension, this is $ out various sections that have different layouts, 2 columns, 3 columns, columns$ on and so forth. elseif($bodyType == "2column"){$this->load->view($templateVar . '/body_2column$ elseif($bodyType == "3column"){$this->load->view($templateVar . '/body_3column$ elseif($bodyType == "blog"){$this->load->view($templateVar . '/body_blog');} */ else{$this->load->view($templateVar . '/body_full');} ?> <?php $this->load->view($templateVar . '/footer'); ?> Issue line: Code: [Select] if((empty($bodyType))||(!isset($bodyType))||(trim($bodyType)=="")){$this->load->view($templateVar . '/body_full');} does anyone see why i get an unexpected T_VARIABLE here? Ive varied the code from something i had that was working so i don't see why it fails to work, any help would be great thanks. Code: [Select] <?php require_once('_includes/db_connection.php'); if ($result = mysql_query('SELECT Banned FROM users WHERE username = '$username'')) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); if ($row['Banned'] != No) { echo "You are banned"; exit; } } } ?> Wondering what the heck is wrong with it, worked before i varied the error messages, had a pal check it out, he couldn't really spot anything wrong either, obviously were both being blind at what is missing, if someone would be kind enough to explain the segment of code that's causing the error is below. if ($amount < 1);echo "You must enter the number of troops you wish to hire.";exit;}else{ if ($amount > $maxdef);echo "You cannot hire over your housing limit.";exit;}else{if ($amount = "");echo "You must enter the number of troops you wish to hire.";exit;else if ($HireCost > $CashOnHand);echo "You do not have enough cash on hand to hire these troops.";exit;() I get parse error unexpected '{' on line 153 (this is last bracket of the code) but all the { brackets are closed. Whats wrong with this code: Code: [Select] function outputModule($moduleID, $moduleName, $sessionData) { if(!count($sessionData)) { return false; } $markTotal = 0; $markGrade = 0; $weightSession = 0; $grade = ""; $sessionsHTML = ''; }; if ($markGrade >70) $grade = 'A'; elseif ($markGrade >=60 && $average <=69) $grade = 'B'; elseif ($markGrade >=50 && $average <=59) $grade = 'C'; foreach($sessionData as $session) { $sessionsHTML .= "<p><strong>Session:</strong> {$session['SessionId']} {$session['Mark']} {$session['SessionWeight']}%</p>\n"; $markTotal += ($session['Mark'] / 100 * $session['SessionWeight']); $weightSession += ($session['SessionWeight']); $markGrade = ($markTotal / $weightSession * 100); } $moduleHTML = "<p><br><strong>Module:</strong> {$moduleID} - {$moduleName} {$markTotal} {$markGrade} {$grade}</p>\n"; return $moduleHTML . $sessionsHTML; } $output = ""; $studentId = false; $courseId = false; $moduleId = false; while ($row = mysql_fetch_array($result)) { if($studentId != $row['StudentUsername']) { //Student has changed $studentId = $row['StudentUsername']; $output .= "<p><strong>Student:</strong> {$row['StudentForename']} {$row['StudentSurname']} ({$row['StudentUsername']})\n"; } if($courseId != $row['CourseId']) { //Course has changed $courseId = $row['CourseId']; $output .= "<br><strong>Course:</strong> {$row['CourseId']} - {$row['CourseName']} <br><strong>Year:</strong> {$row['Year']}</p>\n"; } if($moduleId != $row['ModuleId']) { //Module has changed if(isset($sessionsAry)) //Don't run function for first record { //Get output for last module and sessions $output .= outputModule($moduleId, $moduleName, $sessionsAry); } //Reset sessions data array and Set values for new module $sessionsAry = array(); $moduleId = $row['ModuleId']; $moduleName = $row['ModuleName']; } //Add session data to array for current module $sessionsAry[] = array('SessionId'=>$row['SessionId'], 'Mark'=>$row['Mark'], 'SessionWeight'=>$row['SessionWeight']); } //Get output for last module $output .= outputModule($moduleId, $moduleName, $sessionsAry); //Display the output echo $output; } } |