473,722 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parse error: syntax error, unexpected T_ENCAPSED_AND_ WHITESPACE

2 New Member
I need some help with an error I'm getting using php 5.2.5 running on linux.

I receive an error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/inventoryContro l/supplier.php on line 26 (line number changed to match code tags)

The code is as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. // get a supplier using the supplier id
  3. function getSupplier($supplierID = NULL) {
  4.  
  5.     // initialize the supplier to the null
  6.     $supplier = NULL;
  7.  
  8.     // check for NULL arguments
  9.     if (!is_null($supplierID)) {
  10.  
  11.         // get the connection to the database
  12.         $con = db_connect();
  13.  
  14.         // sql select statement 
  15.         $sql = "SELECT * FROM suppliers WHERE supplier_id = '" . $supplierID . "'";
  16.  
  17.         // execute the query
  18.         $result = mysql_query($sql, $con);
  19.  
  20.         if ($record = mysql_fetch_assoc($result)) {
  21.  
  22.             // create empty supplier object
  23.             $supplier = new Supplier;
  24.  
  25.             // set attributes
  26.             $supplier->setSupplierID($supplierID);
  27.             $supplier->setFirstName($record['first_name']);
  28.             $supplier->setLastName($record['last_name']);
  29.             $supplier->setOrganization($record['organization']);
  30.             $supplier->setPhone($record['phone']);
  31.             $supplier->setFax($record['fax']);
  32.             $supplier->setMobile($record['mobile']);
  33.             $supplier->setEmail($record['email']);
  34.             $supplier->setAddress1($record['address1']);
  35.             $supplier->setAddress2($record['address2']);
  36.             $supplier->setCity($record['city']);
  37.             $supplier->setState($record['state']);
  38.             $supplier->setCountry($record['country']);
  39.             $supplier->setPostcode($record['postcode']);
  40.         } // if
  41.  
  42.         // close the database connection
  43.         db_close($con);
  44.     } // if
  45.  
  46.     // return found ? populated supplier : NULL
  47.     return $supplier;
  48. } // getSupplier()
The bit that's dying is any/all of the $supplier->setBlah($recor d['...']);

Strangely, I have code that is exactly the same in multiple software systems, including this one that are basically identical without the problem. Example of code without parse error:

Expand|Select|Wrap|Line Numbers
  1.  
  2. // get an instance of a Customer using the customerID
  3. function getCustomer($customerID = NULL) {
  4.  
  5.      // return value
  6.     $customer = NULL;
  7.  
  8.      // check for null arguments
  9.     if (!is_null($customerID)) {
  10.  
  11.         // get the database connection
  12.         $con = db_connect();
  13.  
  14.         // sql select statement
  15.         $sql = "SELECT * FROM customers WHERE customer_id = '" . $customerID . "'";
  16.  
  17.         // execute the query
  18.         $result = mysql_query($sql, $con);
  19.  
  20.         // check for a result 
  21.         if ($record = mysql_fetch_assoc($result)) {
  22.  
  23.             // create empty customer object
  24.             $customer = new Customer;
  25.  
  26.             // populate attributes
  27.             $customer->setCustomerID($customerID);
  28.             $customer->setFirstName($record['first_name']);
  29.             $customer->setLastName($record['last_name']);
  30.             $customer->setOrganization($record['organization']);
  31.             $customer->setPhone($record['phone']);
  32.             $customer->setFax($record['fax']);
  33.             $customer->setMobile($record['mobile']);
  34.             $customer->setEmail($record['email']);
  35.             $customer->setAddress1($record['address1']);
  36.             $customer->setAddress2($record['address2']);
  37.             $customer->setCity($record['city']);
  38.             $customer->setState($record['state']);
  39.             $customer->setCountry($record['country']);
  40.             $customer->setPostcode($record['postcode']);
  41.             $customer->setTier($record['tier']);
  42.         } // if
  43.  
  44.         // close the database connection
  45.         db_close($con);
  46.     } // if
  47.  
  48.     // return found ? populated customer : NULL
  49.     return $customer;
  50. } // getCustomer()

Anyway, I'm stumped! Help me please!

Finnian Burn
Jul 9 '08 #1
2 3241
pbmods
5,821 Recognized Expert Expert
Heya, Finnian.

I see this sometimes when I mistype a single quote when I need a double quote or vice versa.

Also make sure you don't have an errant quote or backtick (`) somewhere where it doesn't belong.
Jul 9 '08 #2
fburn
2 New Member
Heya, Finnian.

I see this sometimes when I mistype a single quote when I need a double quote or vice versa.

Also make sure you don't have an errant quote or backtick (`) somewhere where it doesn't belong.
I've only used single quotes for associative array access and no backticks anywhere. Any other ideas?

I've also cut-and-pasted the code that works ($customer->setBlah[...]) to the supplier method/object and simply renamed the object reference from $customer to $supplier in each instance it is used and still continue to get the error.

Could it be an actual bug in the parsing engine for PHP?

Finnian
Jul 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
19027
by: Ehartwig | last post by:
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After submitting user information into my creation script, I get the following error from the page that is suppose to insert the user data into the database, create a code, then send an email out for verification. Parse error: parse error, unexpected $end in...
6
489
by: Ben Allen | last post by:
Hi, Im currently getting the error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/midwestm/public_html/support/tutorials.php on line 15. When running the script below, I believe the error has only started to occur since we made the move to a server with global variables switched off. <?php ob_start(); ?>
8
46196
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine where the inital " started? I find myself adding /* */ blocks or cutting/pasting sections of code out in order to find where the error occured. Wouldn't it it be nice if the warning message included the line in teh source where the initial quote ...
5
13169
by: Anna MZ | last post by:
I am new to php and have written the following mysql code to enter the details of a new user in the admin subdomain of my website: $sql = "INSERT INTO 'users' ('userid', 'username', 'upassword') VALUES ('$_POST', '$_POST', '$_POST') mysql_query($sql)"; When I view the code in Internet Explorer I get the following error message: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or...
1
2330
epots9
by: epots9 | last post by:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/xxx.php on line xxx I get that message when i try to run my script, but if i disable an if statement (code below) then my code functions correctly... if($specs == "DT") { $angle = $specs; $rating = $specs; if($angle == "00" || $angle == "30")
3
6099
by: basswhizz | last post by:
Hi everyone im a high school student and I'm having trouble with one of my projects could you please help!! I'm getting this error message. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in C:\wamp\www\dwalk96\sign-up.php on line 26 Here is all the code of the file. <?php // Connects to your Database mysql_connect("aldridge3", "root", "") or die(mysql_error()); mysql_select_db("dwalk96") or...
2
3226
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString", $formName); // 06-22-07 - the next commands try to import all the functions that the
15
2093
by: micky125 | last post by:
Lo all, Ive been getting the error message Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/moneill/public_html/input.html on line 248 so ive checked me code over and over again but cant find whats wrong. So getting a annoyed I commented it to move on to next error but the same error message comes up. And when i remove the code completely the error message remains on...
68
11160
mideastgirl
by: mideastgirl | last post by:
I keep getting this error and I cannot figure it out. My curly brackets are closed, and I am using the correct tags for <?php to open and ?> to close my code. Can someone please help me! Here is my code: <?php //Connect To Database $hostname='mideasthonors2.db.4381361.hostedresource.com'; $username='**************'; $password='***********'; $dbname='mideasthonors2';
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9238
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.