zero-perfoliate
zero-perfoliate

Author Topic: help with moving PHP code  (Read 759 times)

Offline jeffbw

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
help with moving PHP code
« on: November 02, 2008, 06:58:17 AM »
I have a webpage that executes some PHP code that displays images on the page. It works without any error messages.  I copied this PHP code and placed it on a second page. When I access that page the images appear as I wanted but I get the following two warning messages.


Warning: mysql_select_db() [function.mysql-select-db]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /home/www/happylabels/classes/db/class.DbManager.php on line 37

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/www/happylabels/classes/db/class.DbManager.php on line 37


If I then go to the original page (source of the copied code) it also displays the images (without error messages as expected).  Then return to my new second page with the copied code everything works without warning messages.  As far as I can tell the only thing that is different between the two pieces of code is where in the directory structure it is being executed from.  The original code is being executed from within a directory called HOME. The copied code is executed from the root above HOME. 

I'm not very knowledgeable about how this site was built and I am no expert at PHP or MySQL. But I would appreciate some direction if someone here can assist.

Thanks

icestormz

  • Guest
Re: help with moving PHP code
« Reply #1 on: November 02, 2008, 01:45:39 PM »
Can i Please have a look at the code you are trying to move original code and moved code

Offline jeffbw

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
Re: help with moving PHP code
« Reply #2 on: November 03, 2008, 02:51:14 PM »
Icestormz.  Thanks for responding.  Here is a copy of the MOVED Code:

<?php      
      
print("<div id=\"products\">");
         
print("<h2 class='heading_dark'>Samples of Happy Labels Personalized Stationery</h2>");
         
 include("./classes/products/class.product_manager.php");
   
   $prod_manager = new ProductManager();
   $products = array(
        "'SLA1100'",
        "'SLA1102'",
        "'SNC0100'",
        "'SNC0114'",
        "'SLA1101'",
        "'SGT1101'",
        "'SNC0112'",
        "'SNC0115'"
          );
                   
   $prod_manager->getProductsById($products);
   $prod_manager->listProducts();
         
   print("</div>");
?>

It is identical to original COPIED code except the include statement.
The include statement in the original copied code looks like this:
                 include("../classes/products/class.product_manager.php");

I made this change because the new location is being executed from the root directory instead of within the HOME directory (beneath root) where the original code is executed.

DbManager gets involved as a REQUIRE ONCE from product_manager.php.

icestormz

  • Guest
Re: help with moving PHP code
« Reply #3 on: November 06, 2008, 06:59:21 PM »
its possible that you might have to make some changes to
DbManager as well