473,320 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Cannot instantiate non-existent class

I'm having problems with include. I wrote a small example which shows
what's going on...

I should say that the problems started after I moved to a shared
server. All was working fine in my local server...
file test.php
---------------------------------------------------
<?php

echo '<html>';
echo '<head>';
echo '</head>';
echo '<body>';

echo "including inc.php<br>";

include("http://my_site/inc.php");

echo "inc was included<br>";

$clsIncClass = new ClsIncClass;

echo '</body>';
echo '</html>';

?>

file inc.php
---------------------------------------------------
class ClsIncClass {
function ClsIncClass() {
echo "ClsIncClass constructor<br>";
}
}
result in browser:

including inc.php
class ClsIncClass { function ClsIncClass() { echo "ClsIncClass
constructor
"; } }inc was included

Fatal error: Cannot instantiate non-existent class: clsincclass in
/home/ke000067/public_html/test1.php on line 21

Note that it seems that inc.php was included as if it were a text file,
but as you can imagine, it's not my intention...
So, i decided to change

include("http://IP_of_my_site/inc.php");

to

include($_SERVER['DOCUMENT_ROOT']."/my_site/inc.php");

but the result was

including inc.php

including inc.php

Warning: main(/opt/apache/htdocs/~ke000067/public_html/inc.php): failed
to open stream: No such file or directory in
/home/ke000067/public_html/test1.php on line 15

Warning: main(/opt/apache/htdocs/~ke000067/public_html/inc.php): failed
to open stream: No such file or directory in
/home/ke000067/public_html/test1.php on line 15

Warning: main(): Failed opening
'/opt/apache/htdocs/~ke000067/public_html/inc.php' for inclusion
(include_path='.:/opt/apache/lib/php') in
/home/ke000067/public_html/test1.php on line 15
inc was included

Fatal error: Cannot instantiate non-existent class: clsincclass in
/home/ke000067/public_html/test1.php on line 23
Anyone could give me some hints?

regards - jm

Feb 28 '06 #1
8 11190
just to add another detail, executing phpinfo I get

open_basedir =
/opt/apache/htdocs:/tmp:/opt/ferozo/suspended.page:/opt/ferozo/etc/suspension

executing
echo "Server Path: ". $_SERVER['DOCUMENT_ROOT']."<br>";
I get
Server Path: /opt/apache/htdocs

regards - jm

Feb 28 '06 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

julian_m wrote:
include("http://IP_of_my_site/inc.php");

to

include($_SERVER['DOCUMENT_ROOT']."/my_site/inc.php"); [...] Anyone could give me some hints?


Use relative paths. And never ever include anything starting with http://
(or https://, or ftp://, for that matter).

include('inc.php');
include('./inc.php');

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

Fórmula del condón: No-metil-lacolina-oxi-metil-metila-con-gomina.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFEBLmz3jcQ2mg3Pc8RAu6lAJ96DeWHAs3GDjOqy7XFfg GnVQZpFACggDf0
K64neZtGRl5h6vPovRKi/JA=
=R0rM
-----END PGP SIGNATURE-----
Feb 28 '06 #3

Iván Sánchez Ortega wrote:
julian_m wrote:
include("http://IP_of_my_site/inc.php");

to

include($_SERVER['DOCUMENT_ROOT']."/my_site/inc.php");

[...]
Anyone could give me some hints?


Use relative paths. And never ever include anything starting with http://
(or https://, or ftp://, for that matter).

include('inc.php');
include('./inc.php');


Yes, I've read previous answer from yourself (googling a little bit) in
which you said exactly the same.

The problem is that i can't include the file in the shared server, even
though I can do in my local server

the following line

include(inc.php);

works as expected in my local server, but fires up this in the shared
server

Warning: main(): open_basedir restriction in effect. File(/inc.php) is
not within the allowed path(s):
(/opt/apache/htdocs:/tmp:/opt/ferozo/suspended.page:/opt/ferozo/etc/suspension)
in /home/ke000067/public_html/test1.php on line 17

Warning: main(/inc.php): failed to open stream: Operation not permitted
in /home/ke000067/public_html/test1.php on line 17

Is there any workaround to this, or I just simply can't include *any*
file?
Note that I've not access to php.ini...

sdos - jm

Feb 28 '06 #4
kay
try first with the most simple - try including a file that is placed in
the same directory as the script, forget about classes etc. if u cant
include it - contact your ISP and ask them what to do :-)

Feb 28 '06 #5

kay wrote:
try first with the most simple - try including a file that is placed in
the same directory as the script
That's what I tried hundred times...
forget about classes etc. if u cant
include it - contact your ISP and ask them what to do :-)


They said:
'access to your file with absolute path:
"www.yoursite.com/your_file.php" '

It's really strange
isnt it?

sdos - jm

Feb 28 '06 #6
julian_m wrote:
kay wrote:
try first with the most simple - try including a file that is placed in
the same directory as the script

That's what I tried hundred times...

forget about classes etc. if u cant
include it - contact your ISP and ask them what to do :-)

They said:
'access to your file with absolute path:
"www.yoursite.com/your_file.php" '

It's really strange
isnt it?

sdos - jm


Julian,

The problem is - when you access it through http, all you get is the
HTML (if any) generated by the script. This is how it should be -
otherwise anyone would be able to access your source code!

IIWY I would go back to the host and get a better answer. If you can't
get a better answer than that, change hosts!

include('inc.php') is a very basic statement, and used *very* heavily in
PHP. If it doesn't work on your host, and they can't fix it, its time
to get a new host!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Feb 28 '06 #7

Jerry Stuckle wrote:
Julian,

The problem is - when you access it through http, all you get is the
HTML (if any) generated by the script. This is how it should be -
otherwise anyone would be able to access your source code!
Right, I undestand...
IIWY I would go back to the host and get a better answer. If you can't
get a better answer than that, change hosts!

include('inc.php') is a very basic statement, and used *very* heavily in
PHP. If it doesn't work on your host, and they can't fix it, its time
to get a new host!


Fine, that's what I was thinking right now. Thanks all you for the
help.

regads - jm

Feb 28 '06 #8
On Tue, 28 Feb 2006 11:04:59 -0800, julian_m wrote:
I'm having problems with include. I wrote a small example which shows
what's going on...

I should say that the problems started after I moved to a shared
server. All was working fine in my local server...
file test.php
---------------------------------------------------
<?php

echo '<html>';
echo '<head>';
echo '</head>';
echo '<body>';

echo "including inc.php<br>";

include("http://my_site/inc.php");

echo "inc was included<br>";

$clsIncClass = new ClsIncClass;

echo '</body>';
echo '</html>';

?>

file inc.php
---------------------------------------------------
class ClsIncClass {
function ClsIncClass() {
echo "ClsIncClass constructor<br>";
}
}
result in browser:

including inc.php
class ClsIncClass { function ClsIncClass() { echo "ClsIncClass
constructor
"; } }inc was included

Fatal error: Cannot instantiate non-existent class: clsincclass in
/home/ke000067/public_html/test1.php on line 21

Note that it seems that inc.php was included as if it were a text file,
but as you can imagine, it's not my intention...
So, i decided to change

include("http://IP_of_my_site/inc.php");

to

include($_SERVER['DOCUMENT_ROOT']."/my_site/inc.php");

but the result was

including inc.php

including inc.php

Warning: main(/opt/apache/htdocs/~ke000067/public_html/inc.php): failed
to open stream: No such file or directory in
/home/ke000067/public_html/test1.php on line 15

Warning: main(/opt/apache/htdocs/~ke000067/public_html/inc.php): failed
to open stream: No such file or directory in
/home/ke000067/public_html/test1.php on line 15

Warning: main(): Failed opening
'/opt/apache/htdocs/~ke000067/public_html/inc.php' for inclusion
(include_path='.:/opt/apache/lib/php') in
/home/ke000067/public_html/test1.php on line 15
inc was included

Fatal error: Cannot instantiate non-existent class: clsincclass in
/home/ke000067/public_html/test1.php on line 23
Anyone could give me some hints?

regards - jm


Well, I don't know about anyone else, but I put <? ?> round php code in
included files. Would this make any difference?

Steve

Mar 1 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Giles Brown | last post by:
I'm feeling quite dumb this morning. I'm trying to build a COM server DLL using py2exe and it ain't working. Here's what ain't working... setup_dll.py based on py2exe sample: """from...
8
by: Carel Lotz | last post by:
H We have ported our VB 6 application into VB .NET but are still integrating with a few COM + applications written in VB6 running on our application server (Win 2000 Server). We have the proxies...
8
by: Vijay | last post by:
Hi all, Im using gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20) on 64bit linux server im trying to compile following code --------------------sam.cpp--------------------- #include...
9
by: the_grove_man | last post by:
I guess my question can go in two directions. I create applications that run multiple queries against a database. Generally speaking in the past I have used a Data Control (calling it dat1)...
4
by: Bobby C. Jones | last post by:
I'm trying to use some classes defined in a COM component that I did not create. I have successfully created the RCW via Tlbimp.exe and referenced it in my project. All is well until I run the...
6
by: Mariano | last post by:
Hi, I have stored a menu in a database. The menu is dynamically updated and last level menu items contain the object type that should be instantiated. I am looking for a way to instantiate the...
3
by: Paul | last post by:
Hi, I'm new to .NET and I'm trying to run through the tutorial "Creating a Web Application Using VB" As I follow the directions, It seems to work just fine. I can preview the data from the...
7
by: Brian Kitt | last post by:
I frequently get the above error on my website. It happens only for short periods of times, then the error goes away. I cannot recreate this. I have an error trap that picks up this error. When...
4
by: jdhavo | last post by:
Just a quick question. Does this mean that an XmlTextWriter cannot be used in a webservice? Is there some special coding required to use this class?
4
by: Tomas | last post by:
A newbie question: How can I instantiate objects dynamically in VB.NET. E.g. I have the object 'Player' and I would like to instantiate it with the several instances (James, Gunner, etc.), without...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.