Welcome Guest, Not a member yet? Register   Sign In
Can't include a file in my view!
#1

[eluser]markanderson993[/eluser]
Hello there CodeIgniter experts! I hope my question is simple!

Why can't I include an external file in my view?! Here is what I'm doing...

Code:
<?php include("..../cgi-bin/filechucker.cgi?userdir=" . $this->vbuser->fetch_info('username') ."&suid;=".$this->vbuser->fetch_info('userid'). "&".$_SERVER['QUERY_STRING']); ?>

I keep getting the same message though!


Quote:A PHP Error was encountered

Severity: Warning

Message: include(..../cgi-bin/filechucker.cgi?userdir=anderma&suid=1&uploaderWink [function.include]: failed to open stream: No such file or directory

Filename: uploader/uploader_view.php

Line Number: 9

Does anybody know why?!!! Your help is greatly appreciated!!!
#2

[eluser]Spockz[/eluser]
what does '..../' mean? Go down up two directories? (That would be '../../')
#3

[eluser]markanderson993[/eluser]
Thank you Spockz for your speedy reply Smile I tried changing the directory to
Code:
<?php include("../../cgi-bin/filechucker.cgi?userdir=" . $this->vbuser->fetch_info('username') ."&suid;=".$this->vbuser->fetch_info('userid'). "&".$_SERVER['QUERY_STRING']); ?>
but I still received the same error Sad

It seems that whatever I do, I can't ever reach the cgi-bin directory.

My website structure is as follows:

- Root
- index.php
- cgi-bin (folder)
- system
... - views
- upload (folder)
- upload_view.php (the file in use)

It seems that no matter what I do I can never access the cgi-bin from there. This is so frustrating!
#4

[eluser]Spockz[/eluser]
You need to go up three levels in that schema before you can reach the cgi-bin. Smile Try:

Code:
include dirname(__FILE__).'/../../../cgi-bin.etc..';
#5

[eluser]markanderson993[/eluser]
This is proving to be very difficult! I tried your suggestion but I was still given an error

Quote:Message: include(/home/scorebee/mysite.com.com/system/application/views/uploader/../../../cgi-bin/filechucker.cgi?userdir=anderma&suid=1&uploaderWink [function.include]: failed to open stream: No such file or directory

Filename: uploader/uploader_view.php

This is the code I used:

Code:
<?php include dirname(__FILE__)."/../../../cgi-bin/filechucker.cgi?userdir=" . $this->vbuser->fetch_info('username') ."&suid;=".$this->vbuser->fetch_info('userid'). "&".$_SERVER['QUERY_STRING']; ?>

Line Number: 9
#6

[eluser]Michael Wales[/eluser]
Many... that's getting ugly - maybe wrap it in realpath() so you know you are getting an absolute path name (rather than a relative from the current directory).
#7

[eluser]Spockz[/eluser]
Ah, that's a different structure than mentioned in your tree. I think your tree should look like
Code:
4-Root
   - index.php
   - cgi-bin
3  - system
2    - application
1      - views
         - uploader
           - uploader_view.php

So you need to go 4 times up. Maybe it's easier to do something like:
Code:
include BASEPATH.'/../cgi-bin.etc...';

It isn't relative so you can use it anywere. And it might even by handier if you'd define this in your index.php
Code:
define('CGIPATH', dirname(__FILE__).'/cgi-bin');
#8

[eluser]markanderson993[/eluser]
Thanks for all your input so far, it's been very helpful.

I believe my structure tree is identical to yours (if you mean to have index, cgi-bin, and system all in the same folder).

I liked your idea of including a CGI constant variable and I added that to the index.php page

I also changed the include path in my upload_view.php to

Code:
<?php include CGIPATH. "/filechucker.cgi?userdir=" . $this->vbuser->fetch_info('username') ."&suid;=".$this->vbuser->fetch_info('userid'). "&".$_SERVER['QUERY_STRING']; ?>

However I was still given an error.

Quote:A PHP Error was encountered

Severity: Warning

Message: include(/home/scorebee/mysite.com/cgi-bin/filechucker.cgi?userdir=anderma&suid=1&uploaderWink [function.include]: failed to open stream: No such file or directory

Filename: uploader/uploader_view.php

Line Number: 9

It seems like it won't even accept an absolute URL. What is going on!?!?!?!
I'm getting really really frustrated! Again, thanks so much for your help so far!

Note: I hope this gives you some understanding of the situation, when I copy and paste the .../cgi-bin/... URL from the error into the browser I receive the actual page. But when I try and access it through an include in the upload_view.php I always receive an error.

Perhaps the folder is not properly chmodded?

- Pianoman933
#9

[eluser]Spockz[/eluser]
What's the error? Do those files really exist?

Oh wait a second. Get rid of the ?.. part. You are including a file and not requesting it through the http side of apache. Wink And that's the one who parses the ? (Actually it's php but okay.)
#10

[eluser]markanderson993[/eluser]
Thank you I was able to get a bit of progress! Isn't there ANY way I can pass $_GET variables into the CGI script though?




Theme © iAndrew 2016 - Forum software by © MyBB