I'm confused.
I have a script that wants to pull data from different databases. I started writing it so it'd open one db, get the info, close it, open the next one, get the data, close it, and so on. But I realized I was just doing the same thing over and over so I wrote the actions as functions and put them in an include file.
the result looks like this:
require_once('db_logins.php');
require_once('db_get_all_functions.php');
## collect product data for the form
get_product_data();
## now get vendor data
get_vendor_data();
etc...
this is returning absolutely nothing.
so i returned the functions to the script exactly as written in the function, and it works:
require_once('db_logins.php');
require_once('db_get_all_functions.php');
## collect product data for the form
products_db_login();
$findproducts=mysql_query("select * from [product db]") or die('error: '.mysql_error());
if($findproducts){
while($row=mysql_fetch_array($findproducts)){
$product_data[]=$row;
}
}
## now get vendor data
vendors_db_login();
$findvendors=mysql_query("select * from [vendor db]") or die('error: '.mysql_error());
if($findvendors){
while($row=mysql_fetch_array($findvendors)){
$vendor_data[]=$row;
}
}
...and it works fine.
So, why can't I include that database stuff in a function? what did I do wrong there?