Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Error when installing site using php5.1.4


cactustactical

Recommended Posts

Posted

Ran into an error when moving a site from php 4 to php5.1.4. The error is:

Fatal error: Using $this when not in object context in C:\Program Files\Apache Group\Apache2\htdocs\osc\categories.php on line 61.

 

We have a page which goes through a manufacturers table to display Manufacturers Names within Category types.

In the following short example, the bolded lines are categories, non bold are manufacturers.

 

Aftermarket Accessories

 

Daniel Defense

 

GG&G light accessories

 

GG&G attachment devices

 

Specter Gear Buttstock Pouches

 

 

Accessories

 

Accu Wedge

 

Magazines

 

Arrendondo

 

The code worked fine under php 4, when moving to php 5.14, we are getting the following error message:

 

Fatal error: Using $this when not in object context in C:\Program Files\Apache Group\Apache2\htdocs\osc\categories.php on line 61

 

 

Code is as follows:

 

// SELECT ALL MANUFACTURERS (product class - mfg table)

$categories_query = tep_db_query("select manufacturers_id, manufacturers_name FROM " . TABLE_MANUFACTURERS . " ORDER BY manufacturers_name ASC");

 

// FOR EACH PRODUCT CLASS

$this->data = array();

echo "<table>";

while ($categories = tep_db_fetch_array($categories_query))

{

// FIND ALL MANUFACTURERS WITH PRODUCT IN THIS CLASS (search items flagged with product class)

// DISPLAY MANUFACTURER AND DESCRIPTION (category)

 

$link_page = 'index.php?manufacturers_id=' . $categories['manufacturers_id'];

 

// echo '<tr><td width="35%"><a class=CategoryNavigation href="' . tep_href_link($link_page, '', 'SSL') . '">' . $categories['manufacturers_name'] . '</a><br></td></tr><tr><td class=mfgheaderNavigation width="65%"></td></tr>';

 

echo '<tr><td width="35%"><a class=CategoryNavigation href="' . tep_href_link($link_page, '') . '">' . $categories['manufacturers_name'] . '</a><br></td></tr><tr><td class=mfgheaderNavigation width="65%"></td></tr>';

 

// QUERY FOR ALL MFGS FOR THIS MFG CATEGORY

$filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name, cd.categories_description from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . $categories['manufacturers_id'] . "' order by cd.categories_name";

$filterlist_query = tep_db_query($filterlist_sql);

 

if (tep_db_num_rows($filterlist_query) > 1)

{

// echo '<tr><td class=mfgheaderNavigation align="left" class="main">';

 

while ($filterlist = tep_db_fetch_array($filterlist_query))

{

 

$link_mfg = 'index.php?cPath=' . $filterlist['id'] . '&filter_id=' . $categories['manufacturers_id'];

 

echo '<tr><td class=mfgheaderNavigation width="35%"><li><a class=mfgheaderNavigation href="' . tep_href_link($link_mfg, '') . '">' . $filterlist['name'] . "</a></li></td>";

echo '<td class=mfgheaderNavigation width="65%"></td></tr>';

echo '</td></tr></ul>' . "\n";

}

else

{

echo '<tr><td> </td></tr>';

}

}

echo "</table>";

?>

 

 

This is way above my pay grade, so if anyone has any idea or has ran into this before, please let me know. I searched quite a bit thru the forums and haven't found anything similiar.

 

 

thanks

Posted

Try commenting out $this in the file and see if that helps. I had that problem ages ago but not sure how I fixed it.

 

Think that this is how I sorted it.

Posted

Mark,

thanks for the suggestion. Commenting out that line eliminated the error message.

 

I sure would llike to know what the differences are between php 4 and php 5 to cause these errors. We are setting up a test site using php 5 and the number of errors that are popping up is disillusioning. If a person has a site running on php4 and their ISP "upgrades" to php 5, there are going to be a lot of unhappy people.

Posted

I agree Bob.

 

My host is sticking with 4 for the time being for that reason. It is not only osCommerce they are having problems with I believe.

 

Mind you, I use 5 on my test server at home and don't seen to have too many probs, except for the $this thing and register globals of course.

 

Glad you got it sorted.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...