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: -
-
// get a supplier using the supplier id
-
function getSupplier($supplierID = NULL) {
-
-
// initialize the supplier to the null
-
$supplier = NULL;
-
-
// check for NULL arguments
-
if (!is_null($supplierID)) {
-
-
// get the connection to the database
-
$con = db_connect();
-
-
// sql select statement
-
$sql = "SELECT * FROM suppliers WHERE supplier_id = '" . $supplierID . "'";
-
-
// execute the query
-
$result = mysql_query($sql, $con);
-
-
if ($record = mysql_fetch_assoc($result)) {
-
-
// create empty supplier object
-
$supplier = new Supplier;
-
-
// set attributes
-
$supplier->setSupplierID($supplierID);
-
$supplier->setFirstName($record['first_name']);
-
$supplier->setLastName($record['last_name']);
-
$supplier->setOrganization($record['organization']);
-
$supplier->setPhone($record['phone']);
-
$supplier->setFax($record['fax']);
-
$supplier->setMobile($record['mobile']);
-
$supplier->setEmail($record['email']);
-
$supplier->setAddress1($record['address1']);
-
$supplier->setAddress2($record['address2']);
-
$supplier->setCity($record['city']);
-
$supplier->setState($record['state']);
-
$supplier->setCountry($record['country']);
-
$supplier->setPostcode($record['postcode']);
-
} // if
-
-
// close the database connection
-
db_close($con);
-
} // if
-
-
// return found ? populated supplier : NULL
-
return $supplier;
-
} // 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: -
-
// get an instance of a Customer using the customerID
-
function getCustomer($customerID = NULL) {
-
-
// return value
-
$customer = NULL;
-
-
// check for null arguments
-
if (!is_null($customerID)) {
-
-
// get the database connection
-
$con = db_connect();
-
-
// sql select statement
-
$sql = "SELECT * FROM customers WHERE customer_id = '" . $customerID . "'";
-
-
// execute the query
-
$result = mysql_query($sql, $con);
-
-
// check for a result
-
if ($record = mysql_fetch_assoc($result)) {
-
-
// create empty customer object
-
$customer = new Customer;
-
-
// populate attributes
-
$customer->setCustomerID($customerID);
-
$customer->setFirstName($record['first_name']);
-
$customer->setLastName($record['last_name']);
-
$customer->setOrganization($record['organization']);
-
$customer->setPhone($record['phone']);
-
$customer->setFax($record['fax']);
-
$customer->setMobile($record['mobile']);
-
$customer->setEmail($record['email']);
-
$customer->setAddress1($record['address1']);
-
$customer->setAddress2($record['address2']);
-
$customer->setCity($record['city']);
-
$customer->setState($record['state']);
-
$customer->setCountry($record['country']);
-
$customer->setPostcode($record['postcode']);
-
$customer->setTier($record['tier']);
-
} // if
-
-
// close the database connection
-
db_close($con);
-
} // if
-
-
// return found ? populated customer : NULL
-
return $customer;
-
} // getCustomer()
Anyway, I'm stumped! Help me please!
Finnian Burn
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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(); ?>
|
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 ...
|
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...
|
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")
| |
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...
|
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
|
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...
|
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';
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| | |