PHP - I Found A Php 'extends' Bug....
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.... Similar TutorialsI was wondering if there was a class that I could extend that extends the main class in php. For example all of the classes that I am creating will extend the core class or will be extending a class that extends from the core class. However if the class doesnt exist then it will throw an error. What I would like to do is be able to handle this error instead of just throwing the error so I was hoping that there was a class that I could extend the core class from to handle these errors. This way I can use the magic method __get() to handle the error. If there is another way to go about this please let me know so that I can look into that solution. hi phpfreaks I have an class that is called "connDatabase" what I want to do with it is either extend it or implement it. But I don't know which one to use. The other issue I have is say class "a" has three vars that the that the construct needs to obstantiate and "connDatabase" needs three of its own. How do I obstantiate? thanks for any help If I have a base class MyBase: Code: [Select] class MyBase { public $user_id = NULL; public function __construct() { $this->user_id = "justin"; } } Then I have a class which inherits the base class MyClass: Code: [Select] class Test extends MyBase { public static function get_user_id() { echo parent::$user_id; } } Finally calling it: Code: [Select] echo Test::get_user_id(); First question, do I have to create an instance of MyBase, or when Test extends MyBase will it instanciate it automatically and call the MyBase constructor? Second, I am getting the error: PHP Fatal error: Access to undeclared static property: MyBase::$user_id 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? 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 ?> I'm trying to show my friend my website and it's not letting him or me view it. I am using my own IP-address. (dashed out for security, but it is correct) http://--.---.--.---/index-1.php When he and I type this into our browser, we can an error called "Resource Not Found". But, when I use localhost address, it works fine. http://localhost/index-1.php Does anyone know what is wrong? Do I need to open a specific port? USING XAMPP. 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!
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 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. 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? 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 Hi New to php code, been trown in at the deep end. Keep getting error message Warning: preg_replace(): No ending delimiter it is to do with these 3 lines only $is_sera = preg_replace("'","\"", $is_sera); $is_sera = preg_replace("%","", $is_sera); $is_sera = preg_replace("\?","", $is_sera); can any one tell me what the ending delimiter error means/is thanks in advance Hi,
any body can help, i got 404 message and i dont know the exact way on how to resolve it.
i have url login page like this :
http://localhost/prok/run32.phpand now if the user get correct username and password, page will load or redirect in this but in this link i get 404 message http://localhost/prok/index.php/dashboard/catalogplease take a look my way of coding. #routes.php $route['default_controller'] = 'Login'; $route['404_override'] = ''; $route['dashboard/(:any)'] = 'dashboard/Catalog'; #controllers/login.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Login extends CI_Controller { function __construct() { parent::__construct(); $this->load->helper('url'); } public function index() { $this->load->view('login'); $array = array(); if(isset($_POST['submit'])) { $username = $this->security->xss_clean($this->input->post('username')); $password = $this->security->xss_clean($this->input->post('password')); if(empty($username)) { $array[] = "<p>Please fill-in required field!</p>"; } else { $username = mysql_real_escape_string($username); } if(empty($password)) { $array[] = "<p>Please fill-in required field!</p>"; } else { $password = mysql_real_escape_string($password); } if(sizeof($array) > 0) { foreach($array as $val); { echo "<p>$val</p>"; } } else { $this->load->model('login_process'); $result = $this->login_process->validated(); if(!$result) { echo "<p> Invalid usernamessssss and password.</p><br />"; } else { #$this->load->view('dashboard/catalog','refresh'); redirect('dashboard/catalog','refresh'); } } } } } #controllers/dashboard/catalog.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Catalog extends CI_Controller { public function index() { $this->load->view('dashboard/catalog'); } }please advise, what im doing wrong. Thanks advance I am following a tutorial on how to make a simple PHP shopping cart at: http://v3.thewatchmakerproject.com/journal/276/ I have discovered a problem with the code where a } is not closed. Quote $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } Should the } go on the end of the code or is it suppose to go else where within it? http://bayarearcsociety.com/prototype/index.php When I click the Home link in the nav panel I get these errors Code: [Select] Warning: include(/content/pages/testpage.php) [function.include]: failed to open stream: No such file or directory in /home/bayare27/public_html/prototype/content/maincontent.php on line 7 Warning: include() [function.include]: Failed opening '/content/pages/testpage.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/bayare27/php') in /home/bayare27 /public_html/prototype/content/maincontent.php on line 7 index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" > <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-language" content="en" /> <link type="text/css" rel="stylesheet" href="css/reset.css" /> <link type="text/css" rel="stylesheet" href="css/960.css" /> <link type="text/css" rel="stylesheet" href="css/custom.css" /> <title></title> </head> <body> <div id="wrapper" class="container_12"> <div id="header" class="grid_12"> <div id="left-header" class="grid_5 alpha"></div> <div id="newsflash" class="grid_7 omega"><?php include('content/newsflash.php'); ?></div> </div> <div id="leftmenu" class="grid_3"><?php include('content/menu.php'); ?></div> <div id="maincontent" class="grid_9"><?php include('content/maincontent.php'); ?></div> <div id ="footer" class="grid_12"><?php include('content/footer.php'); ?></div> </div><!-- end wrapper --> </body> </html> menu.php <?php ?> <div class="content"> <ul id="menu"> <li><a href="<?php echo htmlentities($_SERVER['SCRIPT_NAME']); ?>?page=testpage"><span>Home</span></a></li> <!-- Tried both these $_SERVER['PHP_SELF'] and $_SERVER['SCRIPT_NAME']--> <li><a href=""><span>About us</span></a></li> <li><a href=""><span>Schedule</span></a></li> <li><a href=""><span>Media</span></a></li> <li><a href=""><span>Products</span></a></li> <li><a href=""><span>Miscellaneous</span></a></li> </ul> </div> testpage.php <?php ?> <p> lalalaa </p> The file structure on the server is: prototype content - I know these are ok pages - testpage.php is in this file css - I know these are ok images - I know this one is ok Just don't know what to do next. Thanks I apologize, I thought I was posting in php. I assume you will move it. So 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 have a system worked out where I have 2 columes for friends in my database (login_info). One of these is requests and the other is friends. Each request/friend is seperated with a underscore (_). I use the explode() function to seperate the friends/requests into a array. My only problem is I want to display the a different text if the user has sent a requests or is already friends with the user. I tried to do this using the array_search() function and converting it into a boolean (with the boolean cast). It doesn't seem to be working. Code: [Select] <?php $query = mysql_query('SELECT friends, requests FROM login_info WHERE user = \' ' .$userget .'\''); $friend = mysql_fetch_assoc($query); $req = explode('_', $friend['requests']); $friends = explode('_', $friend['friends']); if((bool)array_search($userget, $friends) && (bool)checkarray($userget, $req)) { echo '<a href="?p=add&user='.$userget .'"> Add As Friend </a>'; } if((bool)array_search($userget, $req)) { echo 'Friend Request Pending'; } if((bool)array_search($userget, $friends)) { echo $userget .'Is Your Friend' .$user_log .'!'; } ?> Any help? My Project: Online school note sharing for my university. How: You upload your note(s) get credits and with those credits buy other notes to download. Problem: Whats to stop someone from uploading a note they have downloaded. Security: Currently I have all notes go through an approval system where a staff member views the note sees if it is a legit note then approves it granting the user credits and making the note downloadable. So does anyone have any theories about how I could stop someone from uploading a file that they have uploaded before or have downloaded? timestamps on files md5checksums anything I need to find a way to fix this error and I have no idea. 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? |