Jump to content

Available Objects


scottybwoy

Recommended Posts

I have two files, that are practically the same, except one version has objects available in the content but the other doesn't!

 

Both scripts are being run from the same directory and use the same includes.  Please can someone compare the two to help me find the mistake is.

 

Working index.php

<?php

require_once($_SERVER["DOCUMENT_ROOT"] . "/php/data_obj.php");

$prodFocus = array(	'id'		=> 'MRI-10/100/24/RSR',
									'link'	=> 'http://www.mri.co.uk/products/Networking/10_100_24_RSR.php',
									'img'		=> 'http://www.mri.co.uk/images/MRI-10-100-24RSR.jpg',
									'pitch'	=> 'The MRI-10/100/24/RSR Ethernet Switch, is a standalone, fixed configuration, managed 10/100 switch providing workgroup connectivity for small to mid sized networks.',
									'f1'		=> '19” Standard Rack Mount Size',
									'f2'		=> 'Auto-detect Full/half duplex transfer mode on all ports',
									'f3'		=> 'Supports STP/RSTP');

$cat = $objs->products->category3;

$title = $cat->name . ' Datasheets';
$modified = '29th Jan 2008';

include($_SERVER['DOCUMENT_ROOT'] . '/head.htm');

?>

<p class='path'><a href='http://www.mri.co.uk/'>Home</a>>
<a href='http://www.mri.co.uk/support/index.php'>Technical Support</a>>
<a href='http://www.mri.co.uk/support/documentation.php'>Documentation</a>>
<a href='http://www.mri.co.uk/support/datasheets.php'>Datasheets</a>>
<span style='padding-left:5px;'><?=$cat->name?></span></p>
...
...

 

Not Working

<?php

require_once($_SERVER["DOCUMENT_ROOT"] . "/php/data_obj.php");

$prodFocus = array(	'id'		=> 'MRI-10/100/24/RSR',
									'link'	=> 'http://www.mri.co.uk/products/Networking/10_100_24_RSR.php',
									'img'		=> 'http://www.mri.co.uk/images/MRI-10-100-24RSR.jpg',
									'pitch'	=> 'The MRI-10/100/24/RSR Ethernet Switch, is a standalone, fixed configuration, managed 10/100 switch providing workgroup connectivity for small to mid sized networks.',
									'f1'		=> '19” Standard Rack Mount Size',
									'f2'		=> 'Auto-detect Full/half duplex transfer mode on all ports',
									'f3'		=> 'Supports STP/RSTP');

$cat = $objs->products->category3;
$sub_cat = $cat->sub_cats->sub_cat30;

$title = $sub_cat->name . ' Datasheets';
$modified = '29th Jan 2008';

include($_SERVER['DOCUMENT_ROOT'] . '/head.htm');

?>

<p class='path'><a href='http://www.mri.co.uk/'>Home</a>>
<a href='http://www.mri.co.uk/support/index.php'>Technical Support</a>>
<a href='http://www.mri.co.uk/support/documentation.php'>Documentation</a>>
<a href='http://www.mri.co.uk/controllers/datasheets/index.php'>Datasheets</a>>
<span style='padding-left:5px;'><?=$sub_cat->name?> Datasheets</span></p>
...
...

 

Now the object is available before the ?> in the non working file as it can be seen in the $title var used in the head template, however where the object is in use in the final line of the code posted it is unavailable, whereas it is in the first block of code.

 

I've tried setting the object as global but it doesn't change anything.  Thanks for your time.

Link to comment
Share on other sites

To see these pages go to http://www.mri.co.uk/inputoutput/datasheets/index.php for the working file and http://www.mri.co.uk/inputoutput/datasheets/pci_rs232.php for the non working version.

 

Also note that $sub_cat->name is shown in the title bar of the second file but is not shown later in the same file as <?=$sub_cat->name?>

 

Can anyone see why it becomes unavailable?  Thanks again

Link to comment
Share on other sites

Thanks Thorpe for your reply, but I had already tried that and that's the way it is done in the script that works.

 

It is really unusual behaviour as it is available in the included header file, but when that is finished parsing the rest of the script doesn't have it available.  Whereas it does in the first file?

Link to comment
Share on other sites

OK I worked it out, for some reason php4 does not like underscores in objects passed between files.

 

When I changed $sub_cat to $subcat it worked fine!!

 

Man what a headache, I don't know where to put that in the php man, so if anyone can point me in the right direction or post it there themselves would be appreciated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.