CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 strange value cannot pass to another function

Print topic Send  topic

Author Message
wanaka
Posted: 05/11/2002, 7:27 AM

I have two function the first function will pass the $fldcust_id to the second function. The problem is the second function cannot see the value but if I do an echo in the second fuction the $fldcust_id value is shown. Because I cannot pass the the value I get the error in my SQL.

WHERE cust_id=()Database error: Invalid SQL: SELECT distinct contact.contact_type_id, type_long_desc FROM contact left join contact_category on contact.contact_type_id=contact_category.contact_type_id WHERE cust_id=()

function customer_show()
{

global $db;
global $scustomerErr;
global $sFileName;
global $styles;
$sWhere = "";
$sOrder = "";
$sSQL = "";
$HasParam = false;

$transit_params = "";
$form_params = "";

$sOrder = " order by c.cust_name Asc";


$sSQL = "select c.cust_id as c_cust_id, " .
"c.cust_name as c_cust_name " .
" from customer c ";
$sWhere="where c.cust_name<>'e-service' AND c.cust_name<>'e-ontap'";
$sSQL .= $sWhere . $sOrder;
$db->query($sSQL);
$next_record = $db->next_record();


while($next_record )
{
$fldcust_id = $db->f("c_cust_id");
$fldcust_name = $db->f("c_cust_name");
$next_record = $db->next_record();
{
echo "$fldcust_name<br>";
echo "$fldcust_id";
contact_type_show($fldcust_id);
}
}
}

function contact_type_show($fldcust_id)
{

global $db;

$sSQL = "SELECT distinct contact.contact_type_id, type_long_desc FROM contact left join contact_category on contact.contact_type_id=contact_category.contact_type_id ";
$sOrder = "";
$sWhere = "WHERE cust_id=(".$fldcust_id.")";
echo "$sWhere";

$sSQL .= $sWhere . $sOrder;

$db->query($sSQL);
$next_record = $db->next_record();

while($next_record )
{

$fldcontact_type_id = $db->f("contact_type_id");
$fldtype_long_desc = $db->f("type_long_desc");
$next_record = $db->next_record();
echo "$fldtype_long_desc";
}

}
catalyse
Posted: 05/11/2002, 3:39 PM

Correct me if I'm wrong, but it looks to me like you are going to get strange results anyway as the 2nd function is using the same $db. As such, the while loop in the first function (which asssumes it still has the results of the first SELECT) will be trashed. The second function should have:

$db2 = new DB_Sql();
$db2->Database = DATABASE_NAME;
$db2->User = DATABASE_USER;
$db2->Password = DATABASE_PASSWORD;
$db2->Host = DATABASE_HOST;
$db2->query($sSQL);

This way the original $db will be intact when the function returns. It may not be relevant, but it may be causing odd side effects.

Neil.
Brent
Posted: 05/11/2002, 9:42 PM

You need to echo the $fldcust_id in the contact_type_show procedure
to be sure it wasn't passed correctly.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.