FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » You will all probably laugh at this.
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
You will all probably laugh at this. [message #172490] Mon, 21 February 2011 10:58 Go to next message
Rob Bradford is currently offline  Rob Bradford
Messages: 5
Registered: February 2011
Karma: 0
Junior Member
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.

Rob.B
Re: You will all probably laugh at this. [message #172492 is a reply to message #172490] Mon, 21 February 2011 11:05 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
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
--
Re: You will all probably laugh at this. [message #172493 is a reply to message #172492] Mon, 21 February 2011 11:15 Go to previous messageGo to next message
Rob Bradford is currently offline  Rob Bradford
Messages: 5
Registered: February 2011
Karma: 0
Junior Member
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.
Re: You will all probably laugh at this. [message #172495 is a reply to message #172493] Mon, 21 February 2011 11:29 Go to previous message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: about memory usage with php application
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 23:58:03 GMT 2024

Total time taken to generate the page: 0.04167 seconds