From: David McGlone on
I've checked and checked and re-checked and I can't figure out what I've done
wrong. I'm getting a parse error:

Parse error: syntax error, unexpected T_VARIABLE in
/home/david/www/Joe/current/presentation/smarty_plugins/function.load_products_list.php
on line 27.

Can anyone spot my error? I'd appreciate the help.

Here is the function.load_products_list.php file:

1. <?php
2. function smarty_function_load_products_list($params, $smarty)
3. {
4. $products_list = new $ProductsList();
5. $products_list->init();
6.
7. //assign the template variable
8. $smarty->assign($params['assign'], $products_list);
9. }
10.
11. //Manage the products list
12. class ProductsList
13. {
14. public $mProducts;
15. public $mSelectedProduct;
16.
17. private $mBoCatalog;
18.
19. //constructor initializes business tier object
20. //and reads query string parameter
21. function __construct()
22. {
23. //creating the middle tier object
24. $this->mBoCatalog = new BoCatalog();
25. //if ProductID exists in the query string, we're viewing a product.
26. if(isset($_GET['ProductID']))
27. $this->mSelectedProduct = (init)$_GET['ProductID'];
28. else
29. $this->mSelectedProduct = -1;
30 }
31.
32. //calls business tier to read products list and create the links
33. function init()
34. {
35. //get list of products from business tier
36. $this->mProducts = $this->mBoCatalog->GetProducts();
37. //create the product links
38. for($i = 0; $i < count($this->mProducts); $i++)
39. $this->mProducts[$i]['onclick'] = "index.php?ProductID=" .
40. $this->mProducts[$i]['product_id'];
41. }
42. }
43. ?>

Just in case Im going to include the template file:

{*products_list.tpl*}

{load_products_list assign="products_list"}

{*start products_list*}
<p>Products</p>
{*loop through the list of products*}
{section name=i loop=$products_list->mProducts}
{if ($products_list->mSelectedProduct ==
$products_list->mProducts[i].product_id)}
{assign var=class_d value="ProductSelected"}
{else}
{assign var=class_d value="ProductUnselected"}
{/if}
{*generate a link for a new product in the list*}
<a href="{$products_list->mProducts[i].onclick}">
$raquo; {$products_list->mProducts[i].make}</a>
{/section}


--
Blessings,
David M.
From: Ashley Sheridan on
On Wed, 2010-05-05 at 12:55 -0400, David McGlone wrote:

> I've checked and checked and re-checked and I can't figure out what I've done
> wrong. I'm getting a parse error:
>
> Parse error: syntax error, unexpected T_VARIABLE in
> /home/david/www/Joe/current/presentation/smarty_plugins/function.load_products_list.php
> on line 27.
>
> Can anyone spot my error? I'd appreciate the help.
>
> Here is the function.load_products_list.php file:
>
> 1. <?php
> 2. function smarty_function_load_products_list($params, $smarty)
> 3. {
> 4. $products_list = new $ProductsList();
> 5. $products_list->init();
> 6.
> 7. //assign the template variable
> 8. $smarty->assign($params['assign'], $products_list);
> 9. }
> 10.
> 11. //Manage the products list
> 12. class ProductsList
> 13. {
> 14. public $mProducts;
> 15. public $mSelectedProduct;
> 16.
> 17. private $mBoCatalog;
> 18.
> 19. //constructor initializes business tier object
> 20. //and reads query string parameter
> 21. function __construct()
> 22. {
> 23. //creating the middle tier object
> 24. $this->mBoCatalog = new BoCatalog();
> 25. //if ProductID exists in the query string, we're viewing a product.
> 26. if(isset($_GET['ProductID']))
> 27. $this->mSelectedProduct = (init)$_GET['ProductID'];
> 28. else
> 29. $this->mSelectedProduct = -1;
> 30 }
> 31.
> 32. //calls business tier to read products list and create the links
> 33. function init()
> 34. {
> 35. //get list of products from business tier
> 36. $this->mProducts = $this->mBoCatalog->GetProducts();
> 37. //create the product links
> 38. for($i = 0; $i < count($this->mProducts); $i++)
> 39. $this->mProducts[$i]['onclick'] = "index.php?ProductID=" .
> 40. $this->mProducts[$i]['product_id'];
> 41. }
> 42. }
> 43. ?>
>
> Just in case Im going to include the template file:
>
> {*products_list.tpl*}
>
> {load_products_list assign="products_list"}
>
> {*start products_list*}
> <p>Products</p>
> {*loop through the list of products*}
> {section name=i loop=$products_list->mProducts}
> {if ($products_list->mSelectedProduct ==
> $products_list->mProducts[i].product_id)}
> {assign var=class_d value="ProductSelected"}
> {else}
> {assign var=class_d value="ProductUnselected"}
> {/if}
> {*generate a link for a new product in the list*}
> <a href="{$products_list->mProducts[i].onclick}">
> $raquo; {$products_list->mProducts[i].make}</a>
> {/section}
>
>
> --
> Blessings,
> David M.
>


Line 27 is this:

$this->mSelectedProduct = (init)$_GET['ProductID'];

Shouldn't it be (int) not (init)?

Thanks,
Ash
http://www.ashleysheridan.co.uk


From: Dan Joseph on
On Wed, May 5, 2010 at 12:55 PM, David McGlone <david(a)dmcentral.net> wrote:

> 26. if(isset($_GET['ProductID']))
> 27. $this->mSelectedProduct = (init)$_GET['ProductID'];
>
>
You've got (init) instead of (int). Its always those little characters
causing trouble!

--
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month. Promo
Code "NEWTHINGS" for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry
From: Peter Lind on
On 5 May 2010 18:55, David McGlone <david(a)dmcentral.net> wrote:
> I've checked and checked and re-checked and I can't figure out what I've done
> wrong. I'm getting a parse error:
>
> Parse error: syntax error, unexpected T_VARIABLE in
> /home/david/www/Joe/current/presentation/smarty_plugins/function.load_products_list.php
> on line 27.
>
> Can anyone spot my error? I'd appreciate the help.
>
> Here is the function.load_products_list.php file:
>
> 1. <?php
> 2. function smarty_function_load_products_list($params, $smarty)
> 3. {
> 4.      $products_list = new $ProductsList();
> 5.      $products_list->init();
> 6.
> 7.      //assign the template variable
> 8.      $smarty->assign($params['assign'], $products_list);
> 9. }
> 10.
> 11. //Manage the products list
> 12. class ProductsList
> 13. {
> 14.     public $mProducts;
> 15.     public $mSelectedProduct;
> 16.
> 17.     private $mBoCatalog;
> 18.
> 19.     //constructor initializes business tier object
> 20.     //and reads query string parameter
> 21.     function __construct()
> 22.     {
> 23.             //creating the middle tier object
> 24.             $this->mBoCatalog = new BoCatalog();
> 25.             //if ProductID exists in the query string, we're viewing a product.
> 26.             if(isset($_GET['ProductID']))
> 27.             $this->mSelectedProduct = (init)$_GET['ProductID'];

pretty sure (init) is not a valid cast ...

Regards
Peter

--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>
From: David McGlone on
On Wednesday 05 May 2010 12:51:00 Ashley Sheridan wrote:
> On Wed, 2010-05-05 at 12:55 -0400, David McGlone wrote:
> > I've checked and checked and re-checked and I can't figure out what I've
> > done wrong. I'm getting a parse error:
> >
> > Parse error: syntax error, unexpected T_VARIABLE in
> > /home/david/www/Joe/current/presentation/smarty_plugins/function.load_pro
> >ducts_list.php on line 27.
> >
> > Can anyone spot my error? I'd appreciate the help.
> >
> > Here is the function.load_products_list.php file:
> >
> > 1. <?php
> > 2. function smarty_function_load_products_list($params, $smarty)
> > 3. {
> > 4. $products_list = new $ProductsList();
> > 5. $products_list->init();
> > 6.
> > 7. //assign the template variable
> > 8. $smarty->assign($params['assign'], $products_list);
> > 9. }
> > 10.
> > 11. //Manage the products list
> > 12. class ProductsList
> > 13. {
> > 14. public $mProducts;
> > 15. public $mSelectedProduct;
> > 16.
> > 17. private $mBoCatalog;
> > 18.
> > 19. //constructor initializes business tier object
> > 20. //and reads query string parameter
> > 21. function __construct()
> > 22. {
> > 23. //creating the middle tier object
> > 24. $this->mBoCatalog = new BoCatalog();
> > 25. //if ProductID exists in the query string, we're viewing a product.
> > 26. if(isset($_GET['ProductID']))
> > 27. $this->mSelectedProduct = (init)$_GET['ProductID'];
> > 28. else
> > 29. $this->mSelectedProduct = -1;
> > 30 }
> > 31.
> > 32. //calls business tier to read products list and create the links
> > 33. function init()
> > 34. {
> > 35. //get list of products from business tier
> > 36. $this->mProducts = $this->mBoCatalog->GetProducts();
> > 37. //create the product links
> > 38. for($i = 0; $i < count($this->mProducts); $i++)
> > 39. $this->mProducts[$i]['onclick'] = "index.php?ProductID=" .
> > 40. $this->mProducts[$i]['product_id'];
> > 41. }
> > 42. }
> > 43. ?>
> >
> > Just in case Im going to include the template file:
> >
> > {*products_list.tpl*}
> >
> > {load_products_list assign="products_list"}
> >
> > {*start products_list*}
> > <p>Products</p>
> > {*loop through the list of products*}
> > {section name=i loop=$products_list->mProducts}
> > {if ($products_list->mSelectedProduct ==
> > $products_list->mProducts[i].product_id)}
> > {assign var=class_d value="ProductSelected"}
> > {else}
> > {assign var=class_d value="ProductUnselected"}
> > {/if}
> > {*generate a link for a new product in the list*}
> > <a href="{$products_list->mProducts[i].onclick}">
> > $raquo; {$products_list->mProducts[i].make}</a>
> > {/section}
> >
> >
> > --
> > Blessings,
> > David M.
>
> Line 27 is this:
>
> $this->mSelectedProduct = (init)$_GET['ProductID'];
>
> Shouldn't it be (int) not (init)?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

WOW!!!! I have spent at least 4 hours reading and re-reading it and it took
you 3 seconds.

That was the problem. How, how, how could I have overlooked that so many
times????

Thank you Ashley, I should have asked you 3 hours ago. ;-)
--
Blessings,
David M.
 |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: strtotime woes
Next: Inconsistent json_decode() results