PDA

View Full Version : calling snippets error


msoo
3rd of April 2004 (Sat), 14:23
Can someone tell me what is wrong with my setup for snippets to work? I keep getting this error when I run the snippets.

Warning: main(): stream does not support seeking in /nfs/home/soocool2/public_html/index_main.php on line 115


index_main.php is where I call the snippet.

- MS

Pekka
3rd of April 2004 (Sat), 14:38
See http://drupal.org/node/view/5385

msoo
4th of April 2004 (Sun), 03:00
Hi Pekka,

Can you explain a bit more? I reread the page a few times and I'm still unsure what I need to do to get rid of the error that I got... :-(

- MS

Pekka
4th of April 2004 (Sun), 07:14
Of course.

When you call snippets from your OWN server and fileopen wrappers are not set (see below), you must change the call

include("http://www.mysite.com/gallery/snippets.php?foo=1");

to

include("gallery/snippets.php?foo=1");

which means you need to use RELATIVE PATH from the folder you are calling from to the snippet code folder. Above example e.g. assumes that the script calling the snippet is one branch higher than gallery folder.

When you need to call the snippets from OUTSIDE of your own server, you will need to enable 'allow_url_fopen' directive (fileopen wrappers) in PHP which enables doing includes via http addresses.

One way to do this is to add to your htaccess file the line:

php_value allow_url_fopen 1

or set it directly in php.ini under "Fopen wrappers" section.

msoo
4th of April 2004 (Sun), 16:06
I just tried that, changing the snippet call to a relative path. It gave me this error this time...and without any images showing:

=============================================
Warning: main(gallery/snippets.php?get=random_photos&amount=4&exhibition =all&border=2&bordercolor=CCCCCC&viewas=image): failed to open stream: No such file or directory in /nfs/home/soocool2/public_html/index_main.php on line 116

Warning: main(): Failed opening 'gallery/snippets.php?get=random_photos&amount=4&exhibition =all&border=2&bordercolor=CCCCCC&viewas=image' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /nfs/home/soocool2/public_html/index_main.php on line 116
=============================================

This is how I call the snippet,

<?php include("gallery/snippets.php?get=random_photos&amount=4&exhibition =all&border=2&bordercolor=CCCCCC&viewas=image");
?>

This is the "before" call, which gave me the "stream does not support seeking" error.

<?php include("http://www.soocool.com/gallery/snippets.php?get=random_photos&amount=4&exhibition =all&border=2&bordercolor=CCCCCC&viewas=image");
?>

I've called the support@lunarpages.com to ask them to do the htaccess include as you suggested. Or can I do this myself (create the .htaccess file somewhere)?

- MS

Pekka
4th of April 2004 (Sun), 16:10
Try


include("/nfs/home/soocool2/public_html/gallery/snippets.php?get=random_photos&amount=4&exhibition =all&border=2&bordercolor=CCCCCC&viewas=image");

And yes, you can create .htaccess file yourself on most servers.

msoo
4th of April 2004 (Sun), 17:31
Thanks Pekka,
I tried /nfs/home/soocool2/public_html/snippets.php?...
and even /home/soocool2/public_html/snippets.php?...

Neither works.

I searched in google for a workaround and found that using @include will suppress the error message and make the absolute path work (without the error message). So, I'll try this for now until someone comes up with the solution or why my damn thing doesn't work...

- MS