I have some errors regarding files that I have just uploaded to the server, but I can't figure out where the errors are. The error and warning I am getting are pasted below. But I uploaded all the files. Is there something that I am doing wrong?
Warning: require_once(__DIR__idiorm.php) [function.require-once]: failed to open stream: No such file or directory in /usr/local/apache2/htdocs/demo/includes/main.php on line 7
Fatal error: require_once() [function.require]: Failed opening required '__DIR__idiorm.php' (include_path='.:../PEAR-1.1') in /usr/local/apache2/htdocs/demo/includes/main.php on line 7
Post your code. I don't use PHP much anymore, but it looks like your code might be trying to open a file with the physical __DIR__ in the filename (hence why it is saying it cannot find the file).
It all depends on how you're concatenating the information in your code.
Post your code. I don't use PHP much anymore, but it looks like your code might be trying to open a file with the physical __DIR__ in the filename (hence why it is saying it cannot find the file).
It all depends on how you're concatenating the information in your code.
Thanks for your response to my post. The file are very many. I got them from a tutorial on the net about how to create a user register/Sign up/LOGIN page. However, this is the code for the page that gave me the error and warning messages.
[QUOTE]
<?php
require_once 'includes/main.php';
/*--------------------------------------------------
Handle visits with a login token. If it is
valid, log the person in.
---------------------------------------------------*/
if(isset($_GET['tkn'])){
// Is this a valid login token?
$user = User::findByToken($_GET['tkn']);
if($user){
// Yes! Login the user and redirect to the protected page.
$user->login();
redirect('protected.php');
}
// Invalid token. Redirect back to the login form.
redirect('index.php');
}
/*--------------------------------------------------
Handle logging out of the system. The logout
link in protected.php leads here.
---------------------------------------------------*/
if(isset($_GET['logout'])){
$user = new User();
if($user->loggedIn()){
$user->logout();
}
redirect('index.php');
}
/*--------------------------------------------------
Don't show the login page to already
logged-in users.
---------------------------------------------------*/
if(!isset($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
throw new Exception('Please enter a valid email.');
}
// This will throw an exception if the person is above
// the allowed login attempt limits (see functions.php for more):
rate_limit($_SERVER['REMOTE_ADDR']);
// Record this login attempt
rate_limit_tick($_SERVER['REMOTE_ADDR'], $_POST['email']);
<input type="text" placeholder="your@email.com" name="email" autofocus />
<p>Enter your email address above and we will send <br />you a login link.</p>
The error you've posted is for your includes/main.php file, is that the file you've posted?
If it is, then your require_once will not work, because:
#1 You're including itself, which is redunant.
#2 You're not including itself properly. You're saying to go to includes/includes/main.php instead of includes/main.php.
If this is not your main.php code, please post it.
The error you've posted is for your includes/main.php file, is that the file you've posted?
If it is, then your require_once will not work, because:
#1 You're including itself, which is redunant.
#2 You're not including itself properly. You're saying to go to includes/includes/main.php instead of includes/main.php.
If this is not your main.php code, please post it.
Hello,
As always your reply was much appreciated. That was not actually the main.php file that I sent before. I am sending you the main.php file now please.
[QUOTE]
<?php
// Set the database connection to UTF-8
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
/**
* Configure the session
*/
session_name('tzreg');
// Uncomment to keep people logged in for a week
// session_set_cookie_params(60 * 60 * 24 * 7);
session_start();
/**
* Other settings
*/
// The "from" email address that is used in the emails that are sent to users.
// Some hosting providers block outgoing email if this address
// is not registered as a real email account on their system, so put a real one here.
$fromEmail = 'info@company.com';
if(!$fromEmail){
// This is only used if you haven't filled an email address in $fromEmail
$fromEmail = 'noreply@'.$_SERVER['SERVER_NAME'];
}
The online PHP document has this to say about __DIR__
Originally Posted by php.net
__DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory. (Added in PHP 5.3.0.)
I don't see anything glaringly wrong with the code. Are you sure your idiorm.php file is in the same folder as your main.php file?
Yes, the two files are in the same folder.
I ckecked the version of PHP that my server is using and it shows 'PHP Version 5.2.9'. Which means, it may not be the right one. How can I correct this error it is driving me mad please?
I have added the original ZIP File with all the files to this post please? Like I mentioned earlier, I got the code from a tutorial. I have checked the ZIP file and it has no viruses in it please.
As techgnome said, you need PHP 5.3 to run __DIR__. If you want the same functionality, you'll need to replace "__DIR__" with "dirname(__FILE__)".
However, if it is possible, I would definitely recommend upgrading to a higher version of PHP. PHP 5.3 was released back in 2010, so you're fairly far behind.
However, depending on how much you have running on PHP 5.2.9, you may also get some errors during the upgrade.
As techgnome said, you need PHP 5.3 to run __DIR__. If you want the same functionality, you'll need to replace "__DIR__" with "dirname(__FILE__)".
However, if it is possible, I would definitely recommend upgrading to a higher version of PHP. PHP 5.3 was released back in 2010, so you're fairly far behind.
However, depending on how much you have running on PHP 5.2.9, you may also get some errors during the upgrade.
Thanks for your quick response. I pay for my shared hosting server and the company happens to be using old technologies for its shared hosting customers. I would have loved to upgrade, but I have no much control over their server.
When you say "you'll need to replace "__DIR__" with "dirname(__FILE__)". I an kind of confused. What exactly do you mean by that please? Looking at my previous code of the attachment, how do I do that?
If the code you've grabbed has __DIR__ in it, there is a good chance it is meant to be run in PHP 5.3 and not 5.2. You're probably going to have to fix a lot of issues if you're going to convert it to run on 5.2.
Ok.... now that is a completely new issue... the files are now being included... they're being found... now the issue is some class isn't being init properly... not sure if it's how you're using ORM ... or something in the ORM class itself.
Ok.... now that is a completely new issue... the files are now being included... they're being found... now the issue is some class isn't being init properly... not sure if it's how you're using ORM ... or something in the ORM class itself.
-tg
Hello Again,
Thanks all for your help so far. I was actually looking for PHP/MySQL code to create a Login/Register page. Can you direct me to any good code that I can grab and use, please?
From what I can tell, idiorm uses PDO, do you have PDO installed?
Thanks again I haven't got PDO installed. That could certainly be anong the reasons why it is not working yet. But I will appreciate another code for the purpose of registering and logging in on a website please.