More include issues

This is a discussion on More include issues within the PHP General forums, part of the PHP Programming Forums category; Okay, I'm stumped!!! I have all of my database connection info in a file: connection.php This info is ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-06-2007
Dan Shirah
 
Posts: n/a
Default More include issues

Okay, I'm stumped!!!

I have all of my database connection info in a file: connection.php
This info is stored in a folder: Connections
Example of connection.php:
<?php
$connection = mssql_pconnect('SERVER','user','password') or die ('server
connection failed');
$database = mssql_select_db("my_database", $connection) or die ('DB
selection failed');
?>

I am trying to include the connection.php file in all of my pages so I don't
have to hard code the info into every page.
But, my data never returns because the include apparently is not working.
If I remove the include and hard code the info, it works.

Here is an example of the include statement I am using on my pages.

<?php include '../../Connections/connection.php'; ?>

The Connections folder is two level above my form page. Example file
structure below.

ROOT
Connections
connection.php
Submit
Current_Forms
My_Form.php

I've tried ../../../Connections/connection.php,
.../../Connections/connection.php, ../Connections/connection.php but nothing
works.

Any ideas what I am doing wrong???

Reply With Quote
  #2 (permalink)  
Old 06-06-2007
Robert Cummings
 
Posts: n/a
Default Re: [PHP] More include issues

On Wed, 2007-06-06 at 13:42 -0400, Dan Shirah wrote:
> Okay, I'm stumped!!!
>
> I have all of my database connection info in a file: connection.php
> This info is stored in a folder: Connections
> Example of connection.php:
> <?php
> $connection = mssql_pconnect('SERVER','user','password') or die ('server
> connection failed');
> $database = mssql_select_db("my_database", $connection) or die ('DB
> selection failed');
> ?>
>
> I am trying to include the connection.php file in all of my pages so I don't
> have to hard code the info into every page.
> But, my data never returns because the include apparently is not working.
> If I remove the include and hard code the info, it works.
>
> Here is an example of the include statement I am using on my pages.
>
> <?php include '../../Connections/connection.php'; ?>
>
> The Connections folder is two level above my form page. Example file
> structure below.
>
> ROOT
> Connections
> connection.php
> Submit
> Current_Forms
> My_Form.php
>
> I've tried ../../../Connections/connection.php,
> ../../Connections/connection.php, ../Connections/connection.php but nothing
> works.


Yeah, the current path is your document root... so use the following:

<?php include 'Connections/connection.php'; ?>

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
Reply With Quote
  #3 (permalink)  
Old 06-06-2007
Jim Lucas
 
Posts: n/a
Default Re: [PHP] More include issues

Dan Shirah wrote:
> Okay, I'm stumped!!!
>
> I have all of my database connection info in a file: connection.php
> This info is stored in a folder: Connections
> Example of connection.php:
> <?php
> $connection = mssql_pconnect('SERVER','user','password') or die ('server
> connection failed');
> $database = mssql_select_db("my_database", $connection) or die ('DB
> selection failed');
> ?>
>
> I am trying to include the connection.php file in all of my pages so I
> don't
> have to hard code the info into every page.
> But, my data never returns because the include apparently is not working.
> If I remove the include and hard code the info, it works.
>
> Here is an example of the include statement I am using on my pages.
>
> <?php include '../../Connections/connection.php'; ?>
>
> The Connections folder is two level above my form page. Example file
> structure below.
>
> ROOT
> Connections
> connection.php
> Submit
> Current_Forms
> My_Form.php
>
> I've tried ../../../Connections/connection.php,
> ../../Connections/connection.php, ../Connections/connection.php but nothing
> works.
>
> Any ideas what I am doing wrong???
>

Set your error_reporting to E_ALL.
and set display_errors to On

Then you should be able to see all the errors.

Because, without the error messages, we are not going to be able to help you.

Might I recommend to use include_once instead. This way, it will only create one connection

--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare
Reply With Quote
  #4 (permalink)  
Old 06-06-2007
Dan Shirah
 
Posts: n/a
Default Re: [PHP] More include issues

I have error_reporting set to E_ALL and display_errors is set to On.

And no errors are displayed

My code run through as it should...passes my include statement...displays
part of the form, but when it gets to a dropdown box that is populated by
the database (Which the connection is set in the include) it returns an
empty drop down and none of the rest of my form is displayed.


On 6/6/07, Jim Lucas <lists@cmsws.com> wrote:
>
> Dan Shirah wrote:
> > Okay, I'm stumped!!!
> >
> > I have all of my database connection info in a file: connection.php
> > This info is stored in a folder: Connections
> > Example of connection.php:
> > <?php
> > $connection = mssql_pconnect('SERVER','user','password') or die ('server
> > connection failed');
> > $database = mssql_select_db("my_database", $connection) or die ('DB
> > selection failed');
> > ?>
> >
> > I am trying to include the connection.php file in all of my pages so I
> > don't
> > have to hard code the info into every page.
> > But, my data never returns because the include apparently is not

> working.
> > If I remove the include and hard code the info, it works.
> >
> > Here is an example of the include statement I am using on my pages.
> >
> > <?php include '../../Connections/connection.php'; ?>
> >
> > The Connections folder is two level above my form page. Example file
> > structure below.
> >
> > ROOT
> > Connections
> > connection.php
> > Submit
> > Current_Forms
> > My_Form.php
> >
> > I've tried ../../../Connections/connection.php,
> > ../../Connections/connection.php, ../Connections/connection.php but

> nothing
> > works.
> >
> > Any ideas what I am doing wrong???
> >

> Set your error_reporting to E_ALL.
> and set display_errors to On
>
> Then you should be able to see all the errors.
>
> Because, without the error messages, we are not going to be able to help
> you.
>
> Might I recommend to use include_once instead. This way, it will only
> create one connection
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare
>
>


Reply With Quote
  #5 (permalink)  
Old 06-06-2007
Stut
 
Posts: n/a
Default Re: [PHP] More include issues

Dan Shirah wrote:
> I have error_reporting set to E_ALL and display_errors is set to On.
>
> And no errors are displayed
>
> My code run through as it should...passes my include statement...displays
> part of the form, but when it gets to a dropdown box that is populated by
> the database (Which the connection is set in the include) it returns an
> empty drop down and none of the rest of my form is displayed.


Try outputting something in the include file. If that gets displayed
then the problem is most likely that the code you have to get the
dropdown contents is not returning anything.

-Stut

> On 6/6/07, Jim Lucas <lists@cmsws.com> wrote:
>>
>> Dan Shirah wrote:
>> > Okay, I'm stumped!!!
>> >
>> > I have all of my database connection info in a file: connection.php
>> > This info is stored in a folder: Connections
>> > Example of connection.php:
>> > <?php
>> > $connection = mssql_pconnect('SERVER','user','password') or die

>> ('server
>> > connection failed');
>> > $database = mssql_select_db("my_database", $connection) or die ('DB
>> > selection failed');
>> > ?>
>> >
>> > I am trying to include the connection.php file in all of my pages so I
>> > don't
>> > have to hard code the info into every page.
>> > But, my data never returns because the include apparently is not

>> working.
>> > If I remove the include and hard code the info, it works.
>> >
>> > Here is an example of the include statement I am using on my pages.
>> >
>> > <?php include '../../Connections/connection.php'; ?>
>> >
>> > The Connections folder is two level above my form page. Example file
>> > structure below.
>> >
>> > ROOT
>> > Connections
>> > connection.php
>> > Submit
>> > Current_Forms
>> > My_Form.php
>> >
>> > I've tried ../../../Connections/connection.php,
>> > ../../Connections/connection.php, ../Connections/connection.php but

>> nothing
>> > works.
>> >
>> > Any ideas what I am doing wrong???
>> >

>> Set your error_reporting to E_ALL.
>> and set display_errors to On
>>
>> Then you should be able to see all the errors.
>>
>> Because, without the error messages, we are not going to be able to help
>> you.
>>
>> Might I recommend to use include_once instead. This way, it will only
>> create one connection
>>
>> --
>> Jim Lucas
>>
>> "Some men are born to greatness, some achieve greatness,
>> and some have greatness thrust upon them."
>>
>> Twelfth Night, Act II, Scene V
>> by William Shakespeare
>>
>>

>

Reply With Quote
  #6 (permalink)  
Old 06-06-2007
Dan Shirah
 
Posts: n/a
Default Re: [PHP] More include issues

If I put an echo into my included file, the echo displays on the screen.

But no results are returned.

However, if I copy the data from my include file and paste it directly into
my page, I get the results.


On 6/6/07, Stut <stuttle@gmail.com> wrote:
>
> Dan Shirah wrote:
> > I have error_reporting set to E_ALL and display_errors is set to On.
> >
> > And no errors are displayed
> >
> > My code run through as it should...passes my include

> statement...displays
> > part of the form, but when it gets to a dropdown box that is populated

> by
> > the database (Which the connection is set in the include) it returns an
> > empty drop down and none of the rest of my form is displayed.

>
> Try outputting something in the include file. If that gets displayed
> then the problem is most likely that the code you have to get the
> dropdown contents is not returning anything.
>
> -Stut
>
> > On 6/6/07, Jim Lucas <lists@cmsws.com> wrote:
> >>
> >> Dan Shirah wrote:
> >> > Okay, I'm stumped!!!
> >> >
> >> > I have all of my database connection info in a file: connection.php
> >> > This info is stored in a folder: Connections
> >> > Example of connection.php:
> >> > <?php
> >> > $connection = mssql_pconnect('SERVER','user','password') or die
> >> ('server
> >> > connection failed');
> >> > $database = mssql_select_db("my_database", $connection) or die ('DB
> >> > selection failed');
> >> > ?>
> >> >
> >> > I am trying to include the connection.php file in all of my pages so

> I
> >> > don't
> >> > have to hard code the info into every page.
> >> > But, my data never returns because the include apparently is not
> >> working.
> >> > If I remove the include and hard code the info, it works.
> >> >
> >> > Here is an example of the include statement I am using on my pages.
> >> >
> >> > <?php include '../../Connections/connection.php'; ?>
> >> >
> >> > The Connections folder is two level above my form page. Example file
> >> > structure below.
> >> >
> >> > ROOT
> >> > Connections
> >> > connection.php
> >> > Submit
> >> > Current_Forms
> >> > My_Form.php
> >> >
> >> > I've tried ../../../Connections/connection.php,
> >> > ../../Connections/connection.php, ../Connections/connection.php but
> >> nothing
> >> > works.
> >> >
> >> > Any ideas what I am doing wrong???
> >> >
> >> Set your error_reporting to E_ALL.
> >> and set display_errors to On
> >>
> >> Then you should be able to see all the errors.
> >>
> >> Because, without the error messages, we are not going to be able to

> help
> >> you.
> >>
> >> Might I recommend to use include_once instead. This way, it will only
> >> create one connection
> >>
> >> --
> >> Jim Lucas
> >>
> >> "Some men are born to greatness, some achieve greatness,
> >> and some have greatness thrust upon them."
> >>
> >> Twelfth Night, Act II, Scene V
> >> by William Shakespeare
> >>
> >>

> >

>
>


Reply With Quote
  #7 (permalink)  
Old 06-06-2007
Stut
 
Posts: n/a
Default Re: [PHP] More include issues

Dan Shirah wrote:
> If I put an echo into my included file, the echo displays on the screen.
>
> But no results are returned.
>
> However, if I copy the data from my include file and paste it directly
> into my page, I get the results.


Ok, so that's confirmed that the include file is being included
properly. I think we need to see the code you're using to get the data
before we can help any more.

-Stut

> On 6/6/07, *Stut* <stuttle@gmail.com <mailto:stuttle@gmail.com>> wrote:
>
> Dan Shirah wrote:
> > I have error_reporting set to E_ALL and display_errors is set to On.
> >
> > And no errors are displayed
> >
> > My code run through as it should...passes my include

> statement...displays
> > part of the form, but when it gets to a dropdown box that is

> populated by
> > the database (Which the connection is set in the include) it

> returns an
> > empty drop down and none of the rest of my form is displayed.

>
> Try outputting something in the include file. If that gets displayed
> then the problem is most likely that the code you have to get the
> dropdown contents is not returning anything.
>
> -Stut
>
> > On 6/6/07, Jim Lucas <lists@cmsws.com <mailto:lists@cmsws.com>>

> wrote:
> >>
> >> Dan Shirah wrote:
> >> > Okay, I'm stumped!!!
> >> >
> >> > I have all of my database connection info in a file:

> connection.php
> >> > This info is stored in a folder: Connections
> >> > Example of connection.php:
> >> > <?php
> >> > $connection = mssql_pconnect('SERVER','user','password') or die
> >> ('server
> >> > connection failed');
> >> > $database = mssql_select_db("my_database", $connection) or die

> ('DB
> >> > selection failed');
> >> > ?>
> >> >
> >> > I am trying to include the connection.php file in all of my

> pages so I
> >> > don't
> >> > have to hard code the info into every page.
> >> > But, my data never returns because the include apparently is not
> >> working.
> >> > If I remove the include and hard code the info, it works.
> >> >
> >> > Here is an example of the include statement I am using on my

> pages.
> >> >
> >> > <?php include '../../Connections/connection.php'; ?>
> >> >
> >> > The Connections folder is two level above my form

> page. Example file
> >> > structure below.
> >> >
> >> > ROOT
> >> > Connections
> >> > connection.php
> >> > Submit
> >> > Current_Forms
> >> > My_Form.php
> >> >
> >> > I've tried ../../../Connections/connection.php,
> >> > ../../Connections/connection.php,

> ../Connections/connection.php but
> >> nothing
> >> > works.
> >> >
> >> > Any ideas what I am doing wrong???
> >> >
> >> Set your error_reporting to E_ALL.
> >> and set display_errors to On
> >>
> >> Then you should be able to see all the errors.
> >>
> >> Because, without the error messages, we are not going to be able

> to help
> >> you.
> >>
> >> Might I recommend to use include_once instead. This way, it

> will only
> >> create one connection
> >>
> >> --
> >> Jim Lucas
> >>
> >> "Some men are born to greatness, some achieve greatness,
> >> and some have greatness thrust upon them."
> >>
> >> Twelfth Night, Act II, Scene V
> >> by William Shakespeare
> >>
> >>

> >

>
>

Reply With Quote
  #8 (permalink)  
Old 06-06-2007
Dan Shirah
 
Posts: n/a
Default Re: [PHP] More include issues

Ask and you shall recieve!! :)

// My include statement at the beginning of the body
<?php include '../../Conn/prpr_mssql.php'; ?>

**Various plain HTML form data here**

// My dropdown box that is not getting populated
<?php
// Query the credit_card_type table and load all of the records
// into an array.
$sql = "SELECT * FROM credit_card_code_types ORDER BY
credit_card_type_desc";
$res = mssql_query($sql) or die(mssql_error());
while ($rec = mssql_fetch_assoc($res)) $credit_card_type_desc[] = $rec;

// die('<pre>'.print_r($credit_card_type_code));

foreach ($credit_card_type_desc as $c)
{
if ($c['credit_card_type_code'] == $_POST['credit_card'])
echo "<OPTION value=\"{$c['credit_card_type_code']}\"
SELECTED>{$c['credit_card_type_desc']}</OPTION>\n";
else
echo "<OPTION
value=\"{$c['credit_card_type_code']}\">{$c['credit_card_type_desc']}</OPTION>\n";
}
?>


On 6/6/07, Stut <stuttle@gmail.com> wrote:
>
> Dan Shirah wrote:
> > If I put an echo into my included file, the echo displays on the screen.
> >
> > But no results are returned.
> >
> > However, if I copy the data from my include file and paste it directly
> > into my page, I get the results.

>
> Ok, so that's confirmed that the include file is being included
> properly. I think we need to see the code you're using to get the data
> before we can help any more.
>
> -Stut
>
> > On 6/6/07, *Stut* <stuttle@gmail.com <mailto:stuttle@gmail.com>> wrote:
> >
> > Dan Shirah wrote:
> > > I have error_reporting set to E_ALL and display_errors is set to

> On.
> > >
> > > And no errors are displayed
> > >
> > > My code run through as it should...passes my include

> > statement...displays
> > > part of the form, but when it gets to a dropdown box that is

> > populated by
> > > the database (Which the connection is set in the include) it

> > returns an
> > > empty drop down and none of the rest of my form is displayed.

> >
> > Try outputting something in the include file. If that gets displayed
> > then the problem is most likely that the code you have to get the
> > dropdown contents is not returning anything.
> >
> > -Stut
> >
> > > On 6/6/07, Jim Lucas <lists@cmsws.com <mailto:lists@cmsws.com>>

> > wrote:
> > >>
> > >> Dan Shirah wrote:
> > >> > Okay, I'm stumped!!!
> > >> >
> > >> > I have all of my database connection info in a file:

> > connection.php
> > >> > This info is stored in a folder: Connections
> > >> > Example of connection.php:
> > >> > <?php
> > >> > $connection = mssql_pconnect('SERVER','user','password') or

> die
> > >> ('server
> > >> > connection failed');
> > >> > $database = mssql_select_db("my_database", $connection) or die

> > ('DB
> > >> > selection failed');
> > >> > ?>
> > >> >
> > >> > I am trying to include the connection.php file in all of my

> > pages so I
> > >> > don't
> > >> > have to hard code the info into every page.
> > >> > But, my data never returns because the include apparently is

> not
> > >> working.
> > >> > If I remove the include and hard code the info, it works.
> > >> >
> > >> > Here is an example of the include statement I am using on my

> > pages.
> > >> >
> > >> > <?php include '../../Connections/connection.php'; ?>
> > >> >
> > >> > The Connections folder is two level above my form

> > page. Example file
> > >> > structure below.
> > >> >
> > >> > ROOT
> > >> > Connections
> > >> > connection.php
> > >> > Submit
> > >> > Current_Forms
> > >> > My_Form.php
> > >> >
> > >> > I've tried ../../../Connections/connection.php,
> > >> > ../../Connections/connection.php,

> > ../Connections/connection.php but
> > >> nothing
> > >> > works.
> > >> >
> > >> > Any ideas what I am doing wrong???
> > >> >
> > >> Set your error_reporting to E_ALL.
> > >> and set display_errors to On
> > >>
> > >> Then you should be able to see all the errors.
> > >>
> > >> Because, without the error messages, we are not going to be able

> > to help
> > >> you.
> > >>
> > >> Might I recommend to use include_once instead. This way, it

> > will only
> > >> create one connection
> > >>
> > >> --
> > >> Jim Lucas
> > >>
> > >> "Some men are born to greatness, some achieve greatness,
> > >> and some have greatness thrust upon them."
> > >>
> > >> Twelfth Night, Act II, Scene V
> > >> by William Shakespeare
> > >>
> > >>
> > >

> >
> >

>
>


Reply With Quote
  #9 (permalink)  
Old 06-06-2007
Stut
 
Posts: n/a
Default Re: [PHP] More include issues

Dan Shirah wrote:
> Ask and you shall recieve!! :)
>
> // My include statement at the beginning of the body
> <?php include '../../Conn/prpr_mssql.php'; ?>
>
> **Various plain HTML form data here**
>
> // My dropdown box that is not getting populated
> <?php
> // Query the credit_card_type table and load all of the records
> // into an array.
> $sql = "SELECT * FROM credit_card_code_types ORDER BY
> credit_card_type_desc";
> $res = mssql_query($sql) or die(mssql_error());
> while ($rec = mssql_fetch_assoc($res)) $credit_card_type_desc[] = $rec;
>
> // die('<pre>'.print_r($credit_card_type_code));
>
> foreach ($credit_card_type_desc as $c)
> {
> if ($c['credit_card_type_code'] == $_POST['credit_card'])
> echo "<OPTION value=\"{$c['credit_card_type_code']}\"
> SELECTED>{$c['credit_card_type_desc']}</OPTION>\n";
> else
> echo "<OPTION
> value=\"{$c['credit_card_type_code']}\">{$c['credit_card_type_desc']}</OPTION>\n";
>
> }
> ?>


Ok, I can't see anything wrong with that. Are you absolutely sure it
works when you replace the include line with the contents of the include
file? Are you sure you're replacing it exactly?

One minor thing... that include file is not the same path and filename
you gave in your original post. You are looking at the right piece of
code yes?

One thing I'd suggest you add is a check after the mssql_query to see
how many rows were returned. Beyond that I'm stumped.

-Stut

> On 6/6/07, *Stut* <stuttle@gmail.com <mailto:stuttle@gmail.com>> wrote:
>
> Dan Shirah wrote:
> > If I put an echo into my included file, the echo displays on the

> screen.
> >
> > But no results are returned.
> >
> > However, if I copy the data from my include file and paste it

> directly
> > into my page, I get the results.

>
> Ok, so that's confirmed that the include file is being included
> properly. I think we need to see the code you're using to get the data
> before we can help any more.
>
> -Stut
>
> > On 6/6/07, *Stut* <stuttle@gmail.com <mailto:stuttle@gmail.com>

> <mailto: stuttle@gmail.com <mailto:stuttle@gmail.com>>> wrote:
> >
> > Dan Shirah wrote:
> > > I have error_reporting set to E_ALL and display_errors is

> set to On.
> > >
> > > And no errors are displayed
> > >
> > > My code run through as it should...passes my include

> > statement...displays
> > > part of the form, but when it gets to a dropdown box that is

> > populated by
> > > the database (Which the connection is set in the include) it

> > returns an
> > > empty drop down and none of the rest of my form is displayed.

> >
> > Try outputting something in the include file. If that gets

> displayed
> > then the problem is most likely that the code you have to get the
> > dropdown contents is not returning anything.
> >
> > -Stut
> >
> > > On 6/6/07, Jim Lucas < lists@cmsws.com

> <mailto:lists@cmsws.com> <mailto:lists@cmsws.com
> <mailto:lists@cmsws.com>>>
> > wrote:
> > >>
> > >> Dan Shirah wrote:
> > >> > Okay, I'm stumped!!!
> > >> >
> > >> > I have all of my database connection info in a file:

> > connection.php
> > >> > This info is stored in a folder: Connections
> > >> > Example of connection.php:
> > >> > <?php
> > >> > $connection =

> mssql_pconnect('SERVER','user','password') or die
> > >> ('server
> > >> > connection failed');
> > >> > $database = mssql_select_db("my_database", $connection)

> or die
> > ('DB
> > >> > selection failed');
> > >> > ?>
> > >> >
> > >> > I am trying to include the connection.php file in all of my

> > pages so I
> > >> > don't
> > >> > have to hard code the info into every page.
> > >> > But, my data never returns because the include

> apparently is not
> > >> working.
> > >> > If I remove the include and hard code the info, it works.
> > >> >
> > >> > Here is an example of the include statement I am using

> on my
> > pages.
> > >> >
> > >> > <?php include '../../Connections/connection.php'; ?>
> > >> >
> > >> > The Connections folder is two level above my form

> > page. Example file
> > >> > structure below.
> > >> >
> > >> > ROOT
> > >> > Connections
> > >> > connection.php
> > >> > Submit
> > >> > Current_Forms
> > >> > My_Form.php
> > >> >
> > >> > I've tried ../../../Connections/connection.php,
> > >> > ../../Connections/connection.php,

> > ../Connections/connection.php but
> > >> nothing
> > >> > works.
> > >> >
> > >> > Any ideas what I am doing wrong???
> > >> >
> > >> Set your error_reporting to E_ALL.
> > >> and set display_errors to On
> > >>
> > >> Then you should be able to see all the errors.
> > >>
> > >> Because, without the error messages, we are not going to

> be able
> > to help
> > >> you.
> > >>
> > >> Might I recommend to use include_once instead. This way, it

> > will only
> > >> create one connection
> > >>
> > >> --
> > >> Jim Lucas
> > >>
> > >> "Some men are born to greatness, some achieve greatness,
> > >> and some have greatness thrust upon them."
> > >>
> > >> Twelfth Night, Act II, Scene V
> > >> by William Shakespeare
> > >>
> > >>
> > >

> >
> >

>
>

Reply With Quote
  #10 (permalink)  
Old 06-06-2007
Jim Lucas
 
Posts: n/a
Default Re: [PHP] More include issues

Stut wrote:
> Dan Shirah wrote:
>> Ask and you shall recieve!! :)
>>
>> // My include statement at the beginning of the body
>> <?php include '../../Conn/prpr_mssql.php'; ?>
>>
>> **Various plain HTML form data here**
>>
>> // My dropdown box that is not getting populated
>> <?php
>> // Query the credit_card_type table and load all of the records
>> // into an array.
>> $sql = "SELECT * FROM credit_card_code_types ORDER BY
>> credit_card_type_desc";
>> $res = mssql_query($sql) or die(mssql_error());
>> while ($rec = mssql_fetch_assoc($res)) $credit_card_type_desc[] = $rec;
>>
>> // die('<pre>'.print_r($credit_card_type_code));
>>
>> foreach ($credit_card_type_desc as $c)
>> {
>> if ($c['credit_card_type_code'] == $_POST['credit_card'])
>> echo "<OPTION value=\"{$c['credit_card_type_code']}\"
>> SELECTED>{$c['credit_card_type_desc']}</OPTION>\n";
>> else
>> echo "<OPTION
>> value=\"{$c['credit_card_type_code']}\">{$c['credit_card_type_desc']}</OPTION>\n";
>>
>> }
>> ?>

>
> Ok, I can't see anything wrong with that. Are you absolutely sure it
> works when you replace the include line with the contents of the include
> file? Are you sure you're replacing it exactly?
>
> One minor thing... that include file is not the same path and filename
> you gave in your original post. You are looking at the right piece of
> code yes?


but he said that he echo'ed something from the include file.

Which file was it called from?

>
> One thing I'd suggest you add is a check after the mssql_query to see
> how many rows were returned. Beyond that I'm stumped.
>
> -Stut
>



I'm thinking this is a scope issue

are either of these two pieces of code being called from within a function or class?

the display code, or the include statement? was it

.../../Conn/prpr_mssql.php

or

.../../Connections/connection.php

Which file did you have the include statement in?

--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:19 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0