PHP - T_constant_encapsed_string
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"; ?> Similar TutorialsParse 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']'; 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; } Hello. 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 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); ?> 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 |