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:
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:
Anyway, I'm stumped! Help me please!
Finnian Burn
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:
Code:
// 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()
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:
Code:
// 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
Comment