Re: You will all probably laugh at this. [message #172495 is a reply to message #172493] |
Mon, 21 February 2011 11:29 |
sheldonlg
Messages: 166 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 2/21/2011 6:15 AM, Rob Bradford wrote:
> On Feb 21, 11:05 am, "Álvaro G. Vicario"
> <alvaro.NOSPAMTH...@demogracia.com.invalid> wrote:
>> El 21/02/2011 11:58, Rob Bradford escribi /wrote:
>>
>>
>>
>>> I can't get a call to an external php scrip to execute, it jst lists
>>> the code in the page rather than run it. If I place the code directly
>>> into the page it runs fine. As the code is a db connect string I dont
>>> want in an external php that is called as an when required.
>>
>>> Within the base page I have tried:
>>
>>> <?php
>>> include("con.php");
>>> other php in-line code
>>> ?>
>>
>>> and
>>
>>> <?php
>>> require("con.php");
>>> other php in-line code
>>> ?>
>>
>>> All that happens is it echo's the contents of con.php then the rest
>>> fails as there is no db connection. I'm fairly new to this, but not
>>> programming. To be honest the google pages I have pulled up have been
>>> no help, has anyone any idea what I am doing wrong.
>>
>> You don't post the contents of "con.php" but I'd dare say you are
>> omitting the PHP delimiters:<?php ... ?>
>>
>> When a file is included, parsing drops out of PHP mode and into HTML
>> mode at the beginning of the target file, and resumes again at the end.
>> For this reason, any code inside the target file which should be
>> executed as PHP code must be enclosed within valid PHP start and end tags.
>>
>> http://es2.php.net/manual/en/function.include.php
>>
>> --
>> --http://alvaro.es- lvaro G. Vicario - Burgos, Spain
>> -- Mi sitio sobre programaci n web:http://borrame.com
>> -- Mi web de humor satinado:http://www.demogracia.com
>> --
>
> That was it, I knew it had to be something stupid! I was foolish
> enough to think that having invoked the<?php code block the include
> would be interpreted as php implicitly.
>
> Thanks for helping out while I still have some hair on my head.
>
> Rob.
....also get into the habit of using require_once or include_once instead
of require or include unless you specifically want to include it in more
than one place in the script.
--
Shelly
|
|
|