Page 1 of 2

php includes or SSI

Posted: Fri 30. Apr 2004, 06:22
by eglwolf
I have some snippets of code I want use include in certain areas, and I want to use either php includes, or SSI. but no matter what I try and code it with neither one show up.

What and I missing on this?

Posted: Fri 30. Apr 2004, 09:13
by pSouper
go on be a devil and give us a little more to go on ;)
can you post the code or a desensitised example of the code?

Re: php includes or SSI

Posted: Fri 30. Apr 2004, 09:37
by kpimichael
eglwolf wrote:I have some snippets of code I want use include in certain areas, and I want to use either php includes, or SSI. but no matter what I try and code it with neither one show up.

What and I missing on this?
It is something simple... just recheck the tags and pathing... remember that you have to put the whole path in if you are not keeping the code where Oliver does. I use it all the time... It is a great feature... Here is an example

Code: Select all

{PHP:/home/stuff/public_html/system/where.php}
Hope this helps.

Posted: Fri 30. Apr 2004, 13:15
by machrobby
if I insert this tag...

Code: Select all

{PHP:where.php}
in which folder i must put where.php file ??

Posted: Fri 30. Apr 2004, 13:21
by pSouper
the root dir

I believe ALL replacement tags with the exception of the {IMAGE:} family of repTags are reletive to the root dir.

{IMAGE:} Family are reletive to the PICTURES dir

Posted: Fri 30. Apr 2004, 13:28
by machrobby
i have included {PHP:my_external.php} in a content;
my_external.php in root dir;

Warning: include_ext_php(my_external.php) [function.include-ext-php]: failed to create stream: No such file or directory in /home/web/www.sporteconomy.it/website/include/inc ... nc.inc.php on line 1062

Warning: include_ext_php() [function.include-ext-php]: Failed opening 'my_external.php' for inclusion (include_path='.:/usr/share/php/PEAR') in /home/web/www.sporteconomy.it/website/include/inc ... nc.inc.php on line 1062

:(

Posted: Fri 30. Apr 2004, 13:30
by pSouper
try stripping the _ from the name
this may be automatically stripped in the processing of the replacement tag and therefore returning a file not found error

Posted: Fri 30. Apr 2004, 13:48
by machrobby
nothing
... Failed opening 'myexternal.php' ...
:cry:

Posted: Fri 30. Apr 2004, 13:52
by pSouper
I wonder if your external.php is doing something that phpwcms doesn't like it
to as a {PHP:} included file.

if you link to the file from an article it works as a self contained thing right?

Posted: Fri 30. Apr 2004, 15:02
by eglwolf
Perfect, that is exactly what I needed - thanks!

Posted: Tue 4. May 2004, 08:56
by Haaid
I am struggeling with the same problem; I have included a quotes script which should be called from the directory.

Code: Select all

{PHP:/home/.kale/salonphi/salonphilosophique.net/wcms/quotes/quotation.php}
I included the above in my template but I get an error saying:

Code: Select all

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/.kale/salonphi/salonphilosophique.net/wcms/quotes/quotation_includes.php on line 30
Error:
This file is something which is called from the quotation.php file but when pointing my browser to the quotationfile directly, i do not get an error, only when including the file through the template.

any clues/pointers?

Posted: Tue 4. May 2004, 10:39
by pSouper
would you post or pm the code?

Posted: Wed 5. May 2004, 10:37
by Haaid
code of exactly which php file?


cheers,

K.

Posted: Wed 5. May 2004, 10:51
by pSouper
quotation.php

Posted: Wed 5. May 2004, 11:00
by Haaid

Code: Select all

<?php

############################################################################
############################################################################
##                                                                        ##
## This script is copyright Rupe Parnell (Starsol.co.uk) 2004.            ##
##                                                                        ##
## Distribution of this file, and/or any other files in this package, via ##
## any means, withour prior written consent of the author is prohibited.  ##
##                                                                        ##
## Starsol.co.uk takes no responsibility for any damages caused by the    ##
## usage of this script, and does not guarantee compability with all      ##
## servers.                                                               ##
##                                                                        ##
## Please use the contact form at                                         ##
## http://www.starsol.co.uk/scripts/contact.php if you need any help or   ##
## have any questions about this script.                                  ##
##                                                                        ##
############################################################################
############################################################################

require ('quotation_includes.php');

connect_to_mysql();

$how_many = mysql_num_rows(mysql_query("SELECT quotation FROM ".$db_prefix."quotations"));
$how_many_minus_one = $how_many - 1;

$random = rand(0,$how_many_minus_one);

$rq = mysql_fetch_array(mysql_query("SELECT quotation FROM ".$db_prefix."quotations LIMIT ".$random.", 1"));

$rq[quotation] = nl2br($rq[quotation]);

mysql_close();

$output = NULL;

$output = "<font style='font-family: ".$font_face."; font-size: ".$font_size."pt; color: ".$font_colour.";'>";

if ($bold){
	$output = $output . "<b>";
}
if ($italic){
	$output = $output . "<i>";
}
if ($underline){
	$output = $output . "<u>";
}

$output = $output . $rq[quotation];

if ($underline){
	$output = $output . "</u>";
}
if ($italic){
	$output = $output . "</i>";
}
if ($bold){
	$output = $output . "</b>";
}
$output = $output . "</font>";

echo $output;

?>