PHP - Parse Syntax Error Unexpected 'name' (t_string)
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
Similar TutorialsI 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
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){ 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 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? 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 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 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. Well I see a tutorial of Ajax tabs system, but it uses html code to display the tab instead of php. Therefore, I made a tiny bit of changes, but got this weird T_STRING error on line111, where $text is defined. Here is the script I currently have: Code: [Select] <style type="text/css"> body { font-family: Arial; font-size: 12px; } .container { float: left; width: 400px; border: 1px solid #000000; } .navcontainer ul { background-color: #5F707A; border-bottom:1px solid #DFDFDF; border-top:1px solid #DFDFDF; float:left; font-family:arial,helvetica,sans-serif; font-size:12px; margin:0pt; padding:0pt; width:100%; } .navcontainer ul li { display: inline; text-align: center; } .navcontainer ul li a:hover { background-color:#CCCCCC; color:#FFFFFF; } .navcontainer ul li a { border-right:1px solid #DFDFDF; background-color: #BBBBBB; font-weight: bold; color:#FFFFFF; float:left; padding:10px; text-decoration:none; width: 50px; } .navcontainer ul li a.current { border-right:1px solid #f00; background-color: #f00; font-weight: bold; color:#fff; float:left; padding:10px; text-decoration:none; width: 50px; } #tabcontent { min-height: 200px; padding-top: 80px; padding-left: 10px; } #preloader { position: absolute; top: 150px; left: 100px; z-index: 100; padding: 5px; text-align: center; background-color: #FFFFFF; border: 1px solid #000000; } </style> <script type="text/javascript" src="jquery-1.2.3.pack.js"></script> <script type="text/javascript"> function loadTabContent(tabUrl){ $("#preloader").show(); jQuery.ajax({ url: tabUrl, cache: false, success: function(message) { jQuery("#tabcontent").empty().append(message); $("#preloader").hide(); } }); } jQuery(document).ready(function(){ $("#preloader").hide(); jQuery("[id^=tab]").click(function(){ // get tab id and tab url tabId = $(this).attr("id"); tabUrl = jQuery("#"+tabId).attr("href"); jQuery("[id^=tab]").removeClass("current"); jQuery("#"+tabId).addClass("current"); // load tab content loadTabContent(tabUrl); return false; }); }); </script> <?php $text="<div class="container"> <div class="navcontainer"> <ul> <li><a id="tab1" href="tabs.php?id=1">Google</a></li> <li><a id="tab2" href="tabs.php?id=2">Yahoo</a></li> <li><a id="tab3" href="tabs.php?id=3">Hotmail</a></li> <li><a id="tab4" href="tabs.php?id=4">Twitter</a></li> </ul> </div> <div id="preloader"> <img src="loading.gif" align="absmiddle"> Loading... </div> <div id="tabcontent"> Simple AJAX Tabs </div> </div>"; echo $text; ?> Can anyone of you please tell me how to fix this problem? Thanks. Parse error: syntax error, unexpected T_STRING in /home/****/public_html/ts3O/cron.php on line 61 Hi guys, first time here, hoping I could get some help on something. Having a bit of a hard time :/ Here is the area of code. try { $ts = TeamSpeak3::factory("serverquery://".$c->tsname.":".$c->tspass."@".$c->tshost.":".$c->tsport."/"); $virt = $ts->serverGetByPort($c->tscport); if ($c->usesta == true) { $virt->serverGroupClientDel($c->stagroup,$cid); } else { $virt->clientdbdelete cldbid=($cid); //LINE 61 } } Below is the version used before... The problem with this however is it's the wrong command. The command (output) I need is "clientdbdelete cldbid=$cid" e.g. "clientdbdelete cldbid=49". But the old line 61 that doesn't generate an error's output is "serverGroupClientDel 2,49" try { $ts = TeamSpeak3::factory("serverquery://".$c->tsname.":".$c->tspass."@".$c->tshost.":".$c->tsport."/"); $virt = $ts->serverGetByPort($c->tscport); if ($c->usesta == true) { $virt->serverGroupClientDel($c->stagroup,$cid); } else { $virt->serverGroupClientDel($c->group,$cid); //LINE 61 } } Hi I'm getting a problem that I can't fix. Help would be preciated. Quote print "<table cellspacing='0' cellpadding='0' class='menu'>"; print "<tr>"; >>>>>> print "<td onmouseover="showmenu('requests')" onmouseout="hidemenu('requests')">Requestz"; print "<form action='home.php' method='post'>"; print "<input type='hidden' name='confirmed' value='1'>"; print "<table cellspacing='0' cellpadding='0' class='menu' id='requests'>"; while($Row = mysql_fetch_array($Result8)){ print "<tr>"; print "<td align='left' valign='top' class='menu'><a href='home.php?id=$Row[requester]'>$Row[fname] $Row[lname]</td>"; print "<td align='left' valign='top'><input type='submit' value='Accept'></td>"; print "</tr>"; } print "</table>"; print "</form>"; print "</td>"; print "</tr>"; print "</table>"; 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> Hi, I tried to edit a website that was created a few years ago by a developer. This is done through wordpress. I changed an image address in the code, and on posting got the following: Parse error : syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /homepages/1/d191432458/htdocs/ShropshireHypnobirthing/wp-content/themes/shropshire-hypnobirthing/header.php on line 155 The change I made was on line 194 (highlighed in bold) - and the only change was to change the file from “shropshire-hypnobirthing.png” to “shropshire-hypnobirthing-new.png” When it threw up this error, I immediately changed it back. What is confusing me is that it shows up as line 155 being the error, which was not touched: The line that was changed: <img src="<?php bloginfo('template_directory'); ?>/images/shropshire-hypnobirthing.png" alt="<?php bloginfo('name'); ?> - <?php bloginfo('description'); ?>" /> And the line that is throwing up the error (plus the line before and after):
case is_home() || is_page(‘4’): If anyone could shine any light on this, I’d be massively appreciative, as the whole website is currently inaccessible! Thanks, Tom 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> greetings guys, can someone tell me what is error in this code? i constantly getting this error " Parse error: syntax error, unexpected T_STRING in C:\wamp\www\diplomski\dodaj_podprojekat.php on line 37"! the code is Code: [Select] $nesto=$_SESSION['tema']; $q = "SELECT * FROM projekat WHERE naziv ='$nesto'"; $r = mysql_query($q) or die mysql_error() ; $y = mysql_fetch_object($r); and line in witch is error is $r = mysql_query($q) or die mysql_error() ; |