3

Hi I am using following code to display the table but it shows the error like this.

Warning: require(HTML/Table.php) [function.require]: failed to open stream: No such file or directory in /home/aspire/public_html/table.php on line 3

Fatal error: require() [function.require]: Failed opening required 'HTML/Table.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/aspire/public_html/table.php on line 3

This is my code. Can anyone tell me what mistake I did.

 require("HTML/Table.php");
 $tableStyle = array("bgcolor"=>"#FFFFFF", "border"=>"1", "width"=>"150",   "cellpadding"=>"1", "cellspacing"=>"2"); 
 $colA = array("field 1", "field 2", "field 3", "", "<b>TOTAL</b>");
 $a = 10;
 $b = 15;
 $c = 8;
 $total = $a+$b+$c;
 $colB = array($a, $b, $c, "", "<b>".$total."</b>");
 $table = new HTML_Table($tableStyle);
 $table->addCol($colA);
 $table->addCol($colB);
 $table->display();

Using this "php go-pear.phar" command I found the following path.

Current include path           : .:/usr/share/php:/usr/share/pear
Configured directory           : /home/aspire/pear/share/pear
Currently used php.ini (guess) : /etc/php5/cli/php.ini

So when specify the path before start my code like

 include_path=".:/usr/share/php:/usr/share/pear/";

it shows the error like

Parse error: syntax error, unexpected '=' in /home/aspire/public_html/table.php on line 2

How to solve this problem.

  • This reference is handling the error messages you encounter: [Reference - What does this error mean in PHP?](http://stackoverflow.com/q/12769982/367456) - it might be useful so that you can do some basic troubleshooting with your problem. – hakre Dec 15 '12 at 16:03

2 Answers2

1

Trying your sample code, I got the error message:

PHP Warning:  require(HTML/Table.php): failed to open stream: No such file or directory in /home/dylan/Desktop/scratch/pear_path.php on line 3
PHP Fatal error:  require(): Failed opening required 'HTML/Table.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/dylan/Desktop/scratch/pear_path.php on line 3

I resolved this and the program appears to work fine after doing:

sudo pear install HTML_Table

If you're having issues package versions you might try the pear force option.

sudo pear install -f --alldeps HTML_Table

I found this here: http://grokbase.com/p/php/pear-general/05ak6rnj7m/pear-problem-installing-db-dataobject-formbuilder-frontend

ddoxey
  • 2,013
  • 1
  • 18
  • 25
0

The correct way to set the include path is:

set_include_path(".:/usr/share/php:/usr/share/pear/");
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Ok Include path based on your suggestion but it still shows Warning: require(/HTML/Table.php) [function.require]: failed to open stream: No such file or directory in /home/aspire/public_html/table.php on line 3 Fatal error: require() [function.require]: Failed opening required '/HTML/Table.php' (include_path='.:/usr/share/php:/usr/share/pear/') in /home/aspire/public_html/table.php on line 3 – Prusothaman Varatharaj Dec 15 '12 at 07:30
  • Get rid of the `/` at the beginning, it should be `require("HTML/Table.php");`. Where is the PEAR library actually installed on your server? – Barmar Dec 15 '12 at 17:13