Re: [PHP-DB] referencing external functions

2005-02-15 Thread Bastien Koert
You can have that happen even with this code. If they limit the 
max_connections, then the only thing you can do is to manage the connections 
the best you can. OPen and close then for the bare minimum time. Create the 
SQL, then open the connection, process it, get the resultback and close the 
link.

bastien
From: "J. Connolly" <[EMAIL PROTECTED]>
To: PHP list 
Subject: Re: [PHP-DB] referencing external functions
Date: Tue, 15 Feb 2005 14:35:21 -0500
Thanks Bastian,
I did not understand that require and include are not considered arguments. 
When i removed the parentheses everything was ok. I was also having a 
problem because my hosting company shut down my database for having too 
many connections...
jzf

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] referencing external functions

2005-02-15 Thread J. Connolly
Thanks Bastian,
I did not understand that require and include are not considered 
arguments. When i removed the parentheses everything was ok. I was also 
having a problem because my hosting company shut down my database for 
having too many connections...
jzf

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] referencing external functions

2005-02-15 Thread Bastien Koert
the error tells me that the files are not in the same dir...I have run into 
this one as well and it was always that case.

Your usage is off though...What you need to do is to include the 
functions.php page and then call a particular function..also any error 
handling should be with the function itself

I handle mine a little differentlytry this:

//echo "commnecing connection to local db";
	if (!($conn=mysql_connect($host, $username, $pwd)))  {
	printf("error connecting to DB by user = $username and pwd=$pwd");
	exit;
	}
	$db3=mysql_select_db($dbname,$conn) or die("Unable to connect to local 
database");

	$result = mysql_query($sql) or die ("Can't connect because ". 
mysql_error());

return $result;
}//end function
?>
Then I include the function like this
require("conn.php");
$sql = "select * from table";
$result = conn($sql); //runs the query and passes back the result
if ($result){
//do something here
}
?>
In your case...i changed your code somewhat

function links() {
//global $link;
$sql = "select * from jozef_links";
$link = connect(); //call the connect function to create the link
$result = mysql_query($sql, $link) or die (mysql_error());
echo "";
while ($array = mysql_fetch_array($result)) {
  $id = $array['link_name'];
  $url= $array['link_url'];
  echo "$id\n";
}
echo "";
}
?>

bastien
From: "J. Connolly" <[EMAIL PROTECTED]>
To: PHP list 
Subject: [PHP-DB] referencing external functions
Date: Tue, 15 Feb 2005 12:45:29 -0500
Sorry if this is a duplicate. I accidentally sent to the listserve from the 
wrong address.

I am having trouble calling external functions. I am trying to use this to 
clean up the code in the display. I have this as the function.php


function links() {
global $link;
$sql = "select * from jozef_links";
$result = mysql_query($sql, $link) or die (mysql_error());
echo "";
while ($array = mysql_fetch_array($result)) {
  $id = $array['link_name'];
  $url= $array['link_url'];
  echo "$id\n";
}
echo "";
}
?>
and am trying to use it in this links3.php

but I keep getting the error message
*Warning*: main(1): failed to open stream: No such file or directory in 
*C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*
*Warning*: main(): Failed opening '1' for inclusion 
(include_path='.;c:\php4\pear') in 
*C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*

Can anyone explain what is wrong. Both files are in the same directory and 
and both have the normal permissions set to access.
Thanks,
jzf

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] referencing external functions

2005-02-15 Thread Matt M.
> and am trying to use it in this links3.php
> 
>  include('functions.php') or die (mysql_error());
> ?>
> 
> but I keep getting the error message
> *Warning*: main(1): failed to open stream: No such file or directory in
> *C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*
> *Warning*: main(): Failed opening '1' for inclusion
> (include_path='.;c:\php4\pear') in
> *C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*
> 
> Can anyone explain what is wrong. Both files are in the same directory
> and and both have the normal permissions set to access.

try the absolute path and try require_once() instead of include().

Also "or die (mysql_error());" is not going to get you anything.  That
is the text of the error message from previous MySQL operation.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] referencing external functions

2005-02-15 Thread J. Connolly
Sorry if this is a duplicate. I accidentally sent to the listserve from 
the wrong address.

I am having trouble calling external functions. I am trying to use this 
to clean up the code in the display. I have this as the function.php


function links() {
global $link;
$sql = "select * from jozef_links";
$result = mysql_query($sql, $link) or die (mysql_error());
echo "";
while ($array = mysql_fetch_array($result)) {
  $id = $array['link_name'];
  $url= $array['link_url'];
  echo "$id\n";
}
echo "";
}
?>
and am trying to use it in this links3.php

but I keep getting the error message
*Warning*: main(1): failed to open stream: No such file or directory in 
*C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*
*Warning*: main(): Failed opening '1' for inclusion 
(include_path='.;c:\php4\pear') in 
*C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*

Can anyone explain what is wrong. Both files are in the same directory 
and and both have the normal permissions set to access.
Thanks,
jzf

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php