Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

T_VARIABLE error

Status
Not open for further replies.

trufla

Programmer
Aug 9, 2004
31
GB
Hello, can any help?

I have this piece of code

$_POST['form_products']));

and it keeps returning the error:

Parse error: parse error, unexpected T_VARIABLE.

I have looked at php.net but It doesn't really explain what T_VARIABLE is, so I am confused about what action to take.


 
you need to post more than that, just looking at that line shows two superflous ))'s
 
And, if that's all there is, then you are only stating a variable name. PHP is expecting something to be done with it, like:

$x = $_POST['form_products'];

PHP doesn't expect just a variable name, hence the "unexpected T_VARIABLE" message.
 
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>choose multiple products</title>
</head>
<body>
<?php
if (isset($_POST['form_products'])){
if(!empty($_SESSION['products'])){
$products = array_unique(
array_merge(unserialize($_SESSION['products'])
$_POST['form_products']));
}
$_SESSION['products'] = serialize($products);
print "</p> Your products have been registered!</p>";
}
?>


<form method="POST" action="<?php $_SERVER['PHP_SELF']?>">
<P> Select some products: <br>
<select name="form_products[]" multiple size=3>
<option>sonic screwdriver</option>
<option>Hal 2000</option>
<option>Tradis</option>
<option>Orac</option>
<option>Transporter bracelet</option>
</select>
</form>
<br><br>
<a href="listing16.5.php">content page</a>
</body>
</html>
 
yep, the line just don't make sence, you have to set it to something e.g. $_POST['fred']=45 or read it e.g $age=$_POST['fred']
 
sorry take it back, it's the line where you use array_merge. You need a comma (,) before the $_POST
Code:
array_merge(unserialize($_SESSION['products']),
$_POST['form_products']));
 
yeah, I've found that an error saying anything like t_variable, or t_function is something where you've left out a comma, a quote, a semicolon, or some other piece of syntax. A T_whatever (as I understand it) is a user-defined whatever. I have no idea how to use\make them, but that seems to be what PHP calls whatever it doesn't understand. look for open braces, extra quotes, syntax errors, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top