Re: [PHP] newbie : how to access functions in seperate files???

2001-09-03 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Aaron Moore) wrote:

 resides in line 6 of test.php where i try to call a function which is in
 function.php
 
 the test.php file :
 ___
 ?php
 require(functions.php);

snip

 function.php file :

Umm, so is the file called function.php, or is it functions.php?  'Cuz 
it's the latter that you've attempted to include...

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] newbie : how to access functions in seperate files???

2001-09-03 Thread Aaron Moore

its functions.php

as i've said my include works... because i'm able to echo from it... i just
can't access the functions.
Cc Zona [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 In article [EMAIL PROTECTED],
  [EMAIL PROTECTED] (Aaron Moore) wrote:

  resides in line 6 of test.php where i try to call a function which is in
  function.php
 
  the test.php file :
  ___
  ?php
  require(functions.php);

 snip

  function.php file :

 Umm, so is the file called function.php, or is it functions.php?  'Cuz
 it's the latter that you've attempted to include...

 --
 CC



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] newbie : how to access functions in seperate files???

2001-09-03 Thread speedboy

What do people do with required files? I have a file called config.php
which contains all my functions. It is 329526 bytes. Should I split this
up into other files? I don't think so, but what do others think?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] newbie : how to access functions in seperate files???

2001-09-03 Thread web-dev

speedboy wrote:
 
 What do people do with required files? I have a file called config.php
 which contains all my functions. It is 329526 bytes. Should I split this
 up into other files? I don't think so, but what do others think?

I too am curious about a recommended or best practice. I create a
function file that contains numerous functions for generating forms that
are used more than once in a site and it becomes large when the forms
are complex. But the alternative is to bloat the individual files by
including the function code on each page that uses it. Or, if you split
the one, large file into some number of smaller files, it increases the
administrative burden of knowing what is in each smaller file and
requiring the correct sub-file in the right context rather than
routinely requiring the one catch-all file every time one or more
function is needed.

Kris O.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] newbie : how to access functions in seperate files???

2001-09-03 Thread Lukas Smith

  What do people do with required files? I have a file called config.php
  which contains all my functions. It is 329526 bytes. Should I split this
  up into other files? I don't think so, but what do others think?

 I too am curious about a recommended or best practice.

what you want todo is split them up by purpose
so you can include as needed

also check the differences on
include (include_once) versus require (require_once)

greets,
Lukas Smith
[EMAIL PROTECTED]


DybNet Internet Solutions GbR
Alt Moabit 89
10559 Berlin
Tel. : +49 30 83 22 50 00
Fax : +49 30 83 22 50 07
www.dybnet.de [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] newbie : how to access functions in seperate files???

2001-09-02 Thread Aaron Moore

ok i have this at the top of my page:

include(/www/data/vi2/root/layout/functions.php);
include(/www/data/vi2/root/layout/config.php);
require(/www/data/vi2/root/layout/init.php);

but when I call one of the functions included in functions.php i get a
message saying :

Fatal error: Call to undefined function: get_total() in
/www/data//root/test.php on line 7


how do i get it to know that the function exists?

Thanks for your help and time.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] newbie : how to access functions in seperate files???

2001-09-02 Thread Don Read

On 03-Sep-2001 Aaron Moore wrote:
 ok i have this at the top of my page:
 
 include(/www/data/vi2/root/layout/functions.php);
 include(/www/data/vi2/root/layout/config.php);
 require(/www/data/vi2/root/layout/init.php);
 
 but when I call one of the functions included in functions.php i get a
 message saying :
 
 Fatal error: Call to undefined function: get_total() in
 /www/data//root/test.php on line 7
 
 
 how do i get it to know that the function exists?
 
 
if (function_exists('get_total'))
   echo 'got'; 
} else {
   echo 'not';
}

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] newbie : how to access functions in seperate files???

2001-09-02 Thread Aaron Moore

Its obviously not finding it... my question is why the includes don't
work???

Thanks

Aaron Moore


Don Read [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On 03-Sep-2001 Aaron Moore wrote:
  ok i have this at the top of my page:
 
  include(/www/data/vi2/root/layout/functions.php);
  include(/www/data/vi2/root/layout/config.php);
  require(/www/data/vi2/root/layout/init.php);
 
  but when I call one of the functions included in functions.php i get a
  message saying :
 
  Fatal error: Call to undefined function: get_total() in
  /www/data//root/test.php on line 7
 
 
  how do i get it to know that the function exists?
 

 if (function_exists('get_total'))
echo 'got';
 } else {
echo 'not';
 }

 Regards,
 --
 Don Read   [EMAIL PROTECTED]
 -- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] newbie : how to access functions in seperate files???

2001-09-02 Thread Chris Aitken

At 10:15 PM 2/09/2001, Aaron Moore wrote:
Its obviously not finding it... my question is why the includes don't
work???

Thanks


Are you 100% positive that the get_total() function is defined in your 
functions.php file ?

Check it, make sure there is no typos because this seems synonymous with a 
function not being in an included file anywhere, or having a typo in the 
function name defined.



Chris


--
 Chris Aitken - Administration/Database Designer - IDEAL Internet
  email: [EMAIL PROTECTED]  phone: +61 2 4628   fax: +61 2 4628 8890
  __-__
   *** Big Brother ***
It just shows that the dull will rule the world. And we will be watching it.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] newbie : how to access functions in seperate files???

2001-09-02 Thread John Monfort



A few things to consider:

 1) double check the include path.
 2) if you're not the appropriate file is being included, then user
REQUIRE, as that will stop the program.

 3) Variable Scope
Your function variables may be out of scope. Double check them, or
make them global.

 4) If you include a file from within a function, then the scope of that
file is only WITHIN that function.
{something to that line...}

   double check your variable scopes.


hope that helped.

-john



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] newbie : how to access functions in seperate files???

2001-09-02 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Aaron Moore) wrote:

 Its obviously not finding it... my question is why the includes don't
 work???

Make sure you have error_reporting set to E_ALL and display_errors turned 
on, then try running the script again.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] newbie : how to access functions in seperate files???

2001-09-02 Thread Aaron Moore

Heres what I have so far. I've put all the fiels into one folder, and i know
the paths are correct since they don't give an include error. The error
resides in line 6 of test.php where i try to call a function which is in
function.php

the test.php file :
___
?php
require(functions.php);
require(config.php);
require(init.php);

$id = get_total(news);

$row = get_newspost($id);

$row[news_subject]

?
___

function.php file :
___
php

// Returns and array to the fields of a newspost of $id
function get_newspost($id) {
 $sql = SELECT news_id, news_subject, news_news, news_date, news_image,
news_link, news_link_style FROM news WHERE news_id = '$id';

 if(!$result = mysql_query($sql, $db))
  return(ERROR);
 if(!$row = mysql_fetch_array($result))
  return(ERROR);

 return $row;
}

// Returns the total number of $type posts
function get_total($type) {
   $sql = SELECT count(*) AS total FROM $type;

   if(!$result = mysql_query($sql, $db))
 return(ERROR);

   if(!$myrow = mysql_fetch_array($result))
 return(0);

   return($myrow[total]);
}
?
___

init.php file
___
?php

global $db;

// Connect to database and create $db tag
if(!$db = @mysql_connect($dbhost, $dbuser, $dbpasswd))
 die('font size=+1An Error Occured/fonthrphpBB was unable to connect
to the database. BRPlease check $dbhost, $dbuser, and $dbpasswd in
config.php.');
if(!@mysql_select_db($dbname,$db))
 die(font size=+1An Error Occured/fonthrphpBB was unable to find the
database b$dbname/b on your MySQL server. brPlease make sure you ran
the phpBB installation script.);

?
___

config.php file  (info replaced with ### for security sorry):
___

?php

// Database Information
$dbname = ##;
$dbhost = ##;
$dbuser = ##;
$dbpasswd = ##;

?
___



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]