PHP - Class 'times_counter' Not Found
Hi guys, I am trying to calculate hours a person works by calculating the values of text fields in a form. However, when I load the page I get "Class 'times_counter' not found. Here is the calculation code" if(isset($_POST['calculate']) != ""){ class times_counter { private $hou = 0; private $min = 0; private $sec = 0; private $totaltime = '00:00:00'; public function __construct($times){ if(is_array($times)){ $length = sizeof($times); for($x=0; $x <= $length; $x++){ $split = explode(":", @$times[$x]); $this->hou += @$split[0]; $this->min += @$split[1]; $this->sec += @$split[2]; } $seconds = $this->sec % 60; $minutes = $this->sec / 60; $minutes = (integer)$minutes; $minutes += $this->min; $hours = $minutes / 60; $minutes = $minutes % 60; $hours = (integer)$hours; $hours += $this->hou % 24; $this->totaltime = $hours.":".$minutes; } } public function get_total_time(){ return $this->totaltime; } } $times = array( $mondiff->format('%H:%I'), $tudiff->format('%H:%I'), $weddiff->format('%H:%I'), $thdiff->format('%H:%I'), $fridiff->format('%H:%I'), $satdiff->format('%H:%I'), $sundiff->format('%H:%I'), ); $counter = new times_counter($times); I had this on an old project, which I no longer have but it worked then. Any ideas? Similar TutorialsSo I'm trying to mess around with the HttpRequest class and it can't be found. I looked it up and it said I have to enable the extension in the php.ini file but I couldn't find the php_http.dll extension that the website said I should be able to find and un-semicolon. What exactly is a PHP HttpRequest? It seems like a few languages have this functionality. What is possible with the PHP HttpRequest, do I need other languages to get, send or display data through HttpRequest? Thanks for any help. Hello, I am trying to implement a simple script that ZIPs up a text file. The problem is that I don't think the ZIPArchive is available on my server. Here is an example of my code: Code: [Select] <?php $zip = new ZipArchive(); $filename = "./PJR.v2.zip"; if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { exit("cannot open <$filename>\n"); } if ($handle = opendir('WORKDIR')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { $zip->addFile($entry); } } closedir($handle); } $zip->close(); ?> When I run it from the command line, I get Code: [Select] PHP Fatal error: Class 'ZipArchive' not found in /users/albert/zip_POC.v2.php on line 2 This is the version info on my server: Code: [Select] php -v PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:53) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies Is there a way that I can install that class even though I am not the 'root' user?? Hi This is a strange one, and I'm not sure whats going on here. I've tried googling the answer to no avail. Basically, I'm writing a Wordpress plugin, and here's my setup: install.php has a class called 'two_install' The main plugin file code snippet: Code: [Select] // Installation require(plugin_basename('installer.php')); // Initiate installation class $twp_install = new twp_install; This results in this on activation: Fatal error: Class 'twp_install' not found in path-on-server\wp-content\plugins\twitter_parser\twitter_parser.php on line xx Anyone got any ideas? Just a note, there is definitely a class called 'twp_install' in installer.php! Thanks in advance I am using a PHP class for a web app that works perfectly well when developing on local machine (PHP 5.2) using the NuSphere IDE. NuSphere sees the class, and when I run the app locally everything seems to work, but when i port the app to the host (Linux Ubuntu with Apache2, PHP 5.3, MySQL 5.1 ), the class is not found (using the remote host debugger). The exact mesage is: Class 'ExcelXML' not found at <line of code>. Here is the code snippet: Code: [Select] <?php function setExcelData($sql, $title, $fileName, $idref=0) { $retVal=false; //$fileName=$fileName.'.xml'; $fileName=$fileName.'.xls'; include ('ExcelXML.inc.php'); include_once $_SERVER['DOCUMENT_ROOT'].'/truck/inc/db.inc.php'; $input = ($idref==0?"blank1.xml":"blank.xml"); // create ExcelXML object $xml = new ExcelXML(); // read template file if (!$xml->read($input)) { echo "Failed to open Tempalate Excel XML file<br>"; } ... ?> Here is the class Code: [Select] <?php /** * Class ExcelXML * Provide functions to modify the content of file in Excel's XML format. * * REQUIRED: * - An ExcelXML file as template * * FEATURES: * - read, modify, and save Excel's XML file * - create download stream as Excel file format (*.xls) * * CHANGELOG: * 06-08-2008 * - Update setCellValue function * - Fix setCellValue bug * 13-07-2008 * - First created * * * @author Herry Ramli (herry13@gmail.com) * @license GPL * @version 0.1.1 * @copyright August 06, 2008 */ class ExcelXML { var $domXML; var $activeWorksheet; function ExcelXML() { } ... ?> The class is in the same folder location as the calling php file. Any ideas? I don't get it. Hi all.
Just seeing this error now.
funny enough the site have been live for about a week only to bring this error now!
Fatal error: Class 'PDO' not found in /home/mysite/public_html/includes/file.php on line 21
and this is the file.php
$database='mydb'; $user='username'; $password='password'; $dsn="mysql:host=localhost;dbname=$database"; try { $pdo = new PDO($dsn,$user,$password); // mysql } catch(PDOException $e) { die ('Failed to connect'); // Exit, displaying an error message }i just saw this today and it's on godaddy thanks hello, i am hoping someone can help, been working on my own mvc with help from tutorials, but i am stuck with this error: Fatal error: Class 'services' not found in C:\xampp\htdocs\Workspace\Cyberglide\libs\Bootstrap.php on line 27 were it says services that changes when i type a different item in the url, loads the error page but says that at the bottom of the page. hoping someone can help me where i gone wrong: Code: [Select] <?php class Bootstrap { function __construct() { $url = isset($_GET['url']) ? $_GET['url'] : null; $url = rtrim($url, '/'); $url = explode('/', $url); //print_r($url); if (empty($url[0])) { require 'controllers/index.php'; $controller = new Index(); $controller->index(); return false; } $file = 'controllers/' . $url[0] . '.php'; if (file_exists($file)) { require $file; } else { $this->error(); } $controller = new $url[0]; $controller->loadModel($url[0]); // calling methods if (isset($url[2])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}($url[2]); } else { $this->error(); } } else { if (isset($url[1])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}(); } else { $this->error(); } } else { $controller->index(); } } } function error() { require 'controllers/error.php'; $controller = new Error(); $controller->index(); return false; } hope someone can help, many thanks guys. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=315284.0 I closed everything down last night and it was all fine, website was working as normal etc, but I've turned on the Xxamp server today and I am getting this error. Seems very random as nothing has changed since it was last on? Does anyone know how to sort this out and why I'm now getting this error? Thanks! I have mysqli object in Database class base: [color=]database class:[/color] class Database { private $dbLink = null; public function __construct() { if (is_null($this->dbLink)) { // load db information to connect $init_array = parse_ini_file("../init.ini.inc", true); $this->dbLink = new mysqli($init_array['database']['host'], $init_array['database']['usr'], $init_array['database']['pwd'], $init_array['database']['db']); if (mysqli_connect_errno()) { $this->dbLink = null; } } } public function __destruct() { $this->dbLink->close(); } } Class derived is Articles where I use object dBLink in base (or parent) class and I can't access to mysqli methods (dbLink member of base class): Articles class: require_once ('./includes/db.inc'); class Articles extends Database{ private $id, .... .... $visible = null; public function __construct() { // Set date as 2009-07-08 07:35:00 $this->lastUpdDate = date('Y-m-d H:i:s'); $this->creationDate = date('Y-m-d H:i:s'); } // Setter .... .... // Getter .... .... public function getArticlesByPosition($numArticles) { if ($result = $this->dbLink->query('SELECT * FROM articles ORDER BY position LIMIT '.$numArticles)) { $i = 0; while ($ret = $result->fetch_array(MYSQLI_ASSOC)) { $arts[$i] = $ret; } $result->close(); return $arts; } } } In my front page php I use article class: include_once('./includes/articles.inc'); $articlesObj = new articles(); $articles = $articlesObj->getArticlesByPosition(1); var_dump($articles); [color=]Error that go out is follow[/color] Notice: Undefined property: Articles::$dbLink in articles.inc on line 89 Fatal error: Call to a member function query() on a non-object in articles.inc on line 89 If I remove constructor on derived class Articles result don't change Please help me Hi Can you call Class A's methods or properties from Class B's methods? Thanks. If a class has a constructor but also has a static method, if I call the static method does the constructor run so that I can use an output from the constructor in my static method? --Kenoli Ok. I know you can pass the object of a class as an argument. Example: class A { function test() { echo "This is TEST from class A"; } } class B { function __construct( $obj ) { $this->a = $obj; } function test() { $this->a->test(); } } Then you could do: $a = new A(); $b = new B($a); Ok so that's one way i know of. I also thought that you could make a method static, and do this: (assuming class A's test is 'static') class B { function test() { A::test(); } } But that is not working. I'd like to know all possible ways of accomplishing this. Any hints are appreciated. thanks I have an existing instance of my class Database, now I want to call that instance in my Session class, how would I go about doing this? I am making login system using codeigniter. When I run my code i get this error. Code: [Select] The requested URL /ci_login/user/login was not found on this server. here is my code so far user.php file which is in controller folder Code: [Select] <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class User extends CI_Controller { function __construct() { parent::__construct(); } function index() { } function login() { if($this->form_validation->run() == FALSE) { $this->load->view('view_login'); } else { echo "Successfull"; } } } view_login.php file which is in view folder Code: [Select] <html> <head> <title>Login</title> </head> <body> <h1>Please Login!</h1> <p>Use the login form below to login.</p> <div id="login_form"> <?php echo form_open(base_url(). 'user/login' ) ?> <label>Username:</label> <div> <?php echo form_input(array('id' => 'username', 'name' => 'username')); ?> </div> <label>Password:</label> <div> <?php echo form_password(array('id' => 'password', 'name' => 'password')); ?> </div> <div> <?php echo form_submit(array('name' => 'submit'),'Login'); ?> </div> <?php echo form_close(); ?> </div> </body> </html> help please how can I solve this error? Hi every1, I am quite a newbie in php so please bear with ma silly questions.. I use IIS 6.0 . I have a php file named try.php . content is as folows <html> <head>......</head> <body>........som html code here... <?php if (flag==0) { some html code } ?> ...some html code </body> </html> when i open the file it says Error Summary HTTP Error 500.0 - Internal Server Error The page cannot be displayed because an internal server error has occurred. Can anybody tell me what am i doing wrong... It happen with me almost every now and then.. Is there some conceptual mistake am doing? Please clarify.. If the same question has been discussed thousand times before, than do direct me to the proper link... Regards, Dwayne Hi Folks! New to php and introduced into it by a new found friend who is really into php. Been learning and learning and learning but not so much I am afraid. I guess books and youtubes and other tutorials are not enough so here I am, fearlessly venturing into this forum and I hope to learn much more to all ya pros out there err I mean in here. Be gentle to me please. I am not a coder but I do have logical thinking attitude and habit. I am a slow learner and close to the resignation age. But who cares, I wanna learn php, yeah!
This code works without problems:
<?php namespace NamespaceA; class A extends \NamespaceB\B {} namespace NamespaceB; class B {} But why the following code cause Fatal error: Class 'NamespaceB\B' not found in ...file? <?php namespace NamespaceA; class A extends \NamespaceB\B {} namespace NamespaceB; class B extends \NamespaceC\C {} namespace NamespaceC; class C {}And this code also works without problems: <?php namespace NamespaceA; class A extends \NamespaceB\B {} namespace NamespaceC; class C {} namespace NamespaceB; class B extends \NamespaceC\C {}Without any namespace, also Fatal error: Class 'B' not found in ...file: <?php class A extends B {} class B extends C {} class C {}Works without problems: <?php class A extends B {} class B {}And yes everything is in the same PHP file.... Fatal error: Call to undefined function curl_init() in C:\(etc etc...) Now I know the usual causes for a problem like this, but they are not solving anything. Yes, extension=php_curl.dll is uncommented in the php.ini file. Yes, phpinfo() displays the php.ini file I have been editing as the Loaded Configuration File. Yes, extension_dir is set correctly in my php.ini file (other extensions work). Yes, php_curl.dll exists in my ext/ folder. No, phpinfo() does not display anything about cURL, anywhere Where else can I look to possibly fix this? One more problem... I'm sorry if I bother u. I have: echo "Image: ".$json['Poster'].""; and if image exist I get in return URL... but if there's no image get a error: Notice: Undefined index: Poster in C:\xampp\htdocs\file.php on line 48 How can I show a message error for this? Maybe I have too many questions but it's first time when I use PHP and don't understand too much. Help is appreciated, again. Thanks! I readed about if, else... still can't solved. I think this is a PHP topic rather than Javascript. Can anyone tell me why this code cannot find the page (404 Not Found) Code: [Select] <?php if ("{$row['passState']}" == 0) { ?> <script language="javascript" type="text/javascript" > <-- var newwindow; function popupgo() { newwindow = window.open('check.php?quizTitle=<?php ".urlencode($quizTitle)."; ?>','_blank', 'scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); if (window.focus) {newwindow.focus()} } //--> </script> <?php echo "<form><input type='button' onClick='popupgo()' value='Popup'></form>"; } ?>when this test code works fine? Both files are PHP. Code: [Select] <?php ?> <head> <script language="javascript" type="text/javascript" > <-- var newwindow; function popupgo() { newwindow = window.open('check/check.php?quizTitle=<?php '.urlencode($quizTitle).'; ?>','_blank', 'scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); if (window.focus) {newwindow.focus()} } //--> </script> </head> <body> <form> <input type="button" onClick="popupgo()" value="Popup"> </form> </body> <?php ?> |