PHP - Syntax Error, Unexpected T_string
Similar TutorialsWhen I try to run a program, I am getting an error message. Not sure why and the code that has the error is shown below. Error message is syntax error, unexpected T_STRING setcookies("username","$username",time()+86400); Well sorry to bother you guys with this seemingly stupid problem. I have a file hmgc.php from a friend, and I try to modify the codes myself to add some sort of features to my site. Unfortunately, I am unable to proceed because of this error: Quote Parse error: syntax error, unexpected T_STRING in /home7/pkmnhofc/public_html/adoptables/hmgc.php on line 115 The file is attached in this message already, please take a look at it and tell me what exactly was wrong? I tried to add another if-elseif-else statement within an else statement, may this be a problem? Also this is the scripts around line 115 looks like: if($act == "2"){ $query = "SELECT * FROM ".$prefix."user_inventory WHERE item_owner='$loggedinname' and item_name='Old Rod'"; $result = mysql_query($query); $num = mysql_numrows($result); if($num == 0){ $article_title = "Oops it appears that you do not have an Old Rod yet..."; $article_content = "<center><table style='color: #FFFF31; background: Green; width: 400px; border: 1px solid #9BDDFF;'><tr><td> It seems that you do not have an Old Rod in your inventory yet, are you sure it is the best choice for you to fish without a rod?<br><br> To fix this issue, simply go back and take Fishing Quiz. You syhould be able to acquire an Old Rod for yourself if you answer all these questions successfully. Trust me, they aint really hard at all if you know something about pokemon and the fishing mechanism already.<br> <br><a href='fishingquiz.php'>Take the Fishing Quiz now!!!</a> } else{ $randnum1 = rand(1, 500); if($randnum1 >= 1 and $randnum1 < 225){ $article_title = "You got a Magikarp"; $article_content = "<center><table style='color: #b60400; background: black; width: 400px; border: 1px solid #b60400;'><tr><td><br><br> Now is your chance to adopt a wild Magikarp!</td></tr></table></center>"; } else if($randnum1 >= 225 and $randnum1 < 250){ $article_title = "You got a Goldeen"; $article_content = "<center><table style='color: #b60400; background: black; width: 400px; border: 1px solid #b60400;'><tr><td><br><br> Now is your chance to adopt a wild Goldeen</td></tr></table></center>"; } else{ $article_title = "Not even a bite"; $article_content = "<center><table style='color: #b60400; background: black; width: 400px; border: 1px solid #b60400;'><tr><td><br><br> Too bad you got nothing...</td></tr></table></center>"; } } } Thank you so much for reading this thread, I appreciate it a lot. Hi everyone,
I am fairly new to PHP coding, and I am attempting to write a script that reads entries from a contact entry from and adds them to a database. However I keep receiving an error that states:
" Parse error: syntax error, unexpected 'name' (T_STRING), expecting ']' in C:\wamp\www\it665\addContact.php on line 16"
I have been trying to figure out what I am missing, or need to remove, and I am having the hardest time. Below is the entire code for the addContact.php script that I keep receiving this error for. I would really appreciate any feedback.
<?php 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
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 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()) ?> can't seem to find the error. helppp Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /export/SOI-50/students/m2009/abhr428/web/WebIbs/view_user.php on line 20 <?php require_once( "common.inc.php"); require_once( "config.php" ); require_once( "users.class.php" ); require_once( "LogEntry.class.php" ); $userid = isset( $_GET["userid"] ) ? (int)$_GET["userid"] : 0; if ( !$user = user::getuser( $userid) ) { displayPageHeader( "Error" ); echo "<div>User not found.</div>; displayPageFooter(); exit; } $logEntries = LogEntry::getLogEntries( $userid ); displayPageHeader( "View user: ". $user->getValueEncoded( "usr_name") ." ". $user->getValueEncoded( "usr_surname") ); ?> <dl style="width: 30em;"> <dt>Username</dt> <dd><?php echo $user->getValueEncoded( "usr_username" ) ?></dd> <dt>First name</dt> <dd><?php echo $user->getValueEncoded( "usr_name" ) ?></dd> <dt> Last name</dt> <dd><?php echo $user->getValueEncoded( "usr_surename" ) ?></dd> <dt>Joined on</dt> <dd><?php echo $user->getValueEncoded( "usr_recordtime") ?></dd> <dt>Last time active</dt> <dd><?php echo $user->getValueEncoded( "usr_lastlogintime" ) ?></dd> </dl> <h2> Access Log </h2> <table cellspacing="0" style="width":30em; border: 1px solid #667;"> <tr> <th>Web Page</th> <th>Number of visits</th> <th> Last visit</th> </tr> <?php $rowCount = 0; foreach ~( $logEntries as $logEntry ) { $rowCount++; ?> <tr<?php if ( $rowCount % 2 == 0 ) echo ' class="alt"' ?>> <td><?php echo $logEntry->getValueEncoded( "pageUrl" ) ?></td> <td><?php echo $logEntry->getValueEncoded( "numVisits") ?></td> <td><?php echo $logEntry->getValueEncoded( "lastAccess") ?> </td> </tr> <?php </table> <div style="width: 30em; margin-top: 20px; text-align: center;"> <a href="javascript:history.go(-1)">back</a> </div> <?php displayPageFooter(); ?> SET UP: Windows vista # XAMPP 1.7.3, # Apache 2.2.14 (IPv6 enabled) + OpenSSL 0.9.8l # MySQL 5.1.41 + PBXT engine # PHP 5.3.1 # phpMyAdmin After entering various different information from previous forms on different pages I finally get this error message "Parse error: syntax error, unexpected T_STRING in C:\blablah on line 31" on the following code: <?php //let's start our session, so we have access to stored data session_start(); include 'db.inc.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); //let's create the query $query = 'INSERT INTO subscriptions (name, email_address, membership_type, terms_and_conditions, name_on_card, credit_card_number, credit_card_expiration_data) VALUES ( "' . $_SESSION[$name, $db] . '", ' . $_SESSION[$email_address, $db] . '", ' . $_SESSION[$membership_type, $db] . '", ' . $_SESSION[$terms_and_conditions, $db] . '", ' . $_POST[$name_on_card, $db] . '", ' . $_POST[$credit_card_number, $db] . '", ' . $_POST[$credit_card_expiration, $db] . ')'; if (isset($query)) { $result = mysql_query($query, $db) or die(mysql_error($db)); } ?> <p>Done!</p> </body> </html> ?> Any help would be appreciated. I'm practicing this with the ambition to develop a multi-page registration using sessions for a website so even web pages that might help me with this aim would be good. I Can't find the problem. The code:
mysql_query("insert into games(week, fight, league_id)values($_REQUEST['week'],'$_REQUEST[home_team]-$_REQUEST[guest_team]',$_REQUEST['home_league'])", $Link);The error message: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING 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> Hi, I was wondering if somebody can help me with an error I am getting. Here is my code: Code: [Select] 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 { echo "<p align='center'> <a href="index.html">Home Page</a><br/> //THIS IS THE LINE THAT IS GIVING THE ERROR <a href="contact_us.html">Contact Us</a><br/> <br/> <em>Click on the links above to edit the files.</em><br/> <a href="?logout">logout</a></p>"; } } This code is within php tags is that correct? As I am coding in notepad ++ and it doesn't have any colour which makes me think something is wrong. If someone could help that would be brilliant! Thanks in advance Hey there, I was having that error message (Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in) in this line: echo "<td>" . $row['name'] . "</td>"; And fixed it with: echo "<td>" . $row[".name."] . "</td>"; It seems to work fine, but this is the right way? Thank you in advance. EDIT: Nop, it didnt do the job xD Hey guys, I am getting the same error and I can't figure out why, I've double checked all my brackets and everything. It's probably just something simple but once you've been staring at it for ages you can't see very much. My code is: Code: [Select] if (isset($_POST['Submit'])) { if (isset($_POST['username'] == '***') && ($_POST['password'] == '***')) { //THIS IS THE LINE $_SESSION['username'] = 'login'; } else { echo "<b>Your login details are not correct. Please login again</b>"; } } I've highlighted the line that the error appears on , can anybody help me? Can anyone tell me what's wrong with this particular part of my php code? $handle = fopen(''lovell.txt, ''a''); That was the line it said there was an issue with, and I'm new and can't seem to figure it out. I am getting the following error: Why a Parse error: syntax error, unexpected T_STRING on line 16. Line 16 is my sql statement and I don't know why it is has an unexpected T_string. Can you possibly help and let me know what I did wrong? Code: [Select] <?PHP $link = mysql_connect('localhost', 'root', ''); if (!$link) { //if no connection then display error die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db('movedb', $link); if (!$db_selected) { die ('Can\'t use movedb : ' . mysql_error()); } $sql= ("SELECT * FROM faq_table ORDER BY faq_subject_rank, faq_priority") or (die mysql_error()); ?> <html> <head> <title>FAQ page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="/atn.css" type="text/css"> </head> <body bgcolor="#FFFFFF" text="#000000"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <?PHP while($rows=mysql_fetch_array($sql)) { ?> <tr> <td width="15%" height="30" colspan="2"> </td> <td width="70%" height="30"> <div align="center"><font size="3" face="Arial, Helvetica, sans-serif"><strong><em><? echo .rows[faq_subject]. ?></em></strong></font></div></td> </tr> <?php } ?> </table> </body> </html> Could anyone please help me with thiss error: Parse error: syntax error, unexpected T_STRING in /home/a2256639/public_html/xboxlive/index.php on line 143 Line 143: Code: [Select] echo (">You have refered over 5 people!<br /><img src=\"images/24-0.gif\"/><img src=\"images/continue.png\"/><img src=\"images/24-0.gif\"/></a><br />");} Code: [Select] <?php $refSystem1 = mysql_query("SELECT COUNT(ref_id) FROM referralsystem WHERE ref_id='".$uId."'") or die("Error in ref :".mysql_error()); $rowRefSystem1 = mysql_fetch_array($refSystem1); if($rowRefSystem1[0] > 0){echo ("<br /><a href='Scr2.php?Ref="); echo ($rowRefSystem1[0]); [B]echo (">You have refered over 5 people!<br /><img src=\"images/24-0.gif\"/><img src=\"images/continue.png\"/><img src=\"images/24-0.gif\"/></a><br />");}[/B] ?> I want a few pictures to display when they've reffered 5 people. Please help me thanks. Hello, I have this error and I cant figure out what is causing it , anyone able to help? Error: Code: [Select] Parse error: syntax error, unexpected T_STRING in /home/******/public_html/******/manage.php on line 54 Line 45: Code: [Select] $result = mysql_query(SELECT * FROM p8_subscribers) or die(mysql_error()); Here is my code: Code: [Select] <?php include('config.php'); include('functions.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en-us" dir="ltr"> <head> <title>JneroMailer</title> <link href="./style.css" media="screen" rel="stylesheet"/> </head> <body> <div class="container"> <div id="navigation"> <ul id="menu"> <li><a href="./index.php">Home</a></li> <?php if(isset($_SESSION['loggedin'])) { echo " <li><a href='./newsletter.php'>Send Newsletter</a></li> <li><a href='./manage.php'>Manage Subscribers</a></li> <li><a href='./archive.php'>Newsletter Archive</a></li> <li><a href='./index.php?logout'>Logout</a></li>"; } ?> </ul> </div> <div id="header"> <div id="logo"></div> <form action="./index.php?login" method="post"> <div id="login"> <?php if(!isset($_SESSION['loggedin'])) { echo "Username: <input type='text' name='username' /> "; echo "Password: <input type='password' name='password' />"; echo "<input type='submit' name='login_go' value='Login' />"; } else { echo "Welcome <b>".$_SESSION['username']."</b>"; } ?> </div> </form> </div> <div id="content"> <h2>Manage Subscribers</h2> <?php if(isset($_SESSION['loggedin'])) { $result = mysql_query(SELECT * FROM p8_subscribers) or die(mysql_error()); echo "<table border='1'>"; echo "<tr>"; echo "<th>ID</th><th>Name</th><th>Email</th><th>Active</th><th>Authorization</th><th>Edit</th><th>Delete</th>"; echo "</tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr>" echo " <td>".$row['id']."</td> <td>".$row['name']."</td> <td>".$row['email']."</td> <td>".$row['active']." <a href='./activate.php?activate=".$row['id']."&auth=".$row['authorization']."'>Force Activate</a></td> <td><a href='./edit.php?sub=".$row['id']."><img src='./images/edit.png' alt='Edit' border='0' /></a></td> <td><a href='./edit.php?sub=".$row['id']."&delete=yes'><img src='./images/delete.png' alt='Delete' border='0' /></a></td> </tr>"; } echo "</table>"; } else { echo "YOU ARE NOT AUTHORIZED TO ACCESS THIS PAGE"; } ?> </div> </div> <div id="footer"> <div class="container"> Copyright 2011 <a href="http://www.JneroCorp.biz">JneroCorp</a> - JneroMailer </div></div> </body> </html> |