PHP - Remove Unexpected T_string Error
hi
i m adding the last field to my query but getting unexpected t_string error $order_detail="insert into detail_table(unique_id,order_id, customer_name, customer_login_id, order_date, product_name, quantity, shipping, price,total_cost,compatibility) values('$unique_id',$order_id,'$username','$log_id','$shop_date','".$row['product_name'] . "' , " . $row['quantity'] . "," . $row['shipping_cost'] . ",". $row['price'] .",". $row['total_cost']. ",". '". $row['compatibility'] . "'. ")"; mysql_query($order_detail); help me remove it vineet Similar TutorialsParse 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>
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){ 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 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 I am in a beginners php class. I am writing a function library right now. I keep getting an unexpected T_STRING error on line 44. Can anyone see an error in any of these lines? function getAirline ($destination) { if ($destination == "Barcelona") return Web Airlines; //This is line 44 elseif ($destination == "Cairo") return PHP Air; elseif ($destination == "Rome") return Air Java; elseif ($destination == "Santiago") return SQL Air; elseif ($destination == "Tokyo") return Object Oriented Airlines; } I have looked really carefully at this code and can't uderstand why i am getting the unexpected T_STRING error: Code: [Select] $qq = "select * from pts where v1 like '$lname%' and user_id = '". $userarray['id'] ."'"; $rr = mysql_query($qq) or die (mysql_error()); In the pts table there is a field called v1 and user_id. Also the value of $lname is often blank but that shouldn't give me an error right? Hey all, Relative newbie here. I am trying to create a script that generates a random image (and the associated title) from my mySQL database. The code doesn't seem to be working as the image is blank and the title does not appear either. A new set of eyes may be able to find the problem. Thanks! Code: [Select] <?php include 'open.php'; include 'opendb.php'; $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS 'offset' FROM 'recipes' "); $offset_row = mysql_fetch_object( $offset_result ); $offset = $offset_row->offset; $result = mysql_query( " SELECT * FROM 'recipes' LIMIT $offset, 1 " ); print "<table width=\"366\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"; print "<tr>"; print "<td class=\"recipe_head\">Healthy Lifestyle Gourmet Recipes</td>"; print "<tr>"; print "<td class=\"recipe_title\">{$result['title']}</td>"; print "</tr>"; print "<tr>"; print "<td><image src=\"{$result['image_path'].$result['image_name']}\" height=\"{$result['image_height']}\" width=\"{$result['image_width']}\" /></td>"; print "</tr></table>"; mysql_close(); ?> 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? 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 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() ; 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 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. 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>"; |