CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Warning: mysql_fetch_assoc():

Print topic Send  topic

Author Message
beshoo

Posts: 68
Posted: 08/27/2004, 5:04 PM

this code is garb for data base and fill the result in the list box
but when i put it as it in be4 show evint i have an error.


Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in e:\c-drive\phpdev\www\cookies\php\tree_events.php on line 29

####################
<?php
//BindEvents Method @1-D40060DD
function BindEvents()
{
global $CCSEvents;
$CCSEvents["BeforeShow"] = "Page_BeforeShow";
}
//End BindEvents Method

//Page_BeforeShow @1-D8BD2467
function Page_BeforeShow()
{
$Page_BeforeShow = true;
//End Page_BeforeShow

//Custom Code @2-BC11AA1B
// -------------------------
global $tree;

$table = "directory_categories";
$hold = array();

function menu($parent=0,$level = -1){
global $hold, $table ;

$level++;
$query = "SELECT * FROM $table WHERE category_id_parent = $parent ORDER BY category_id ASC";
$sql = mysql_query($query);
while($row = mysql_fetch_assoc($sql))
{

$hold[] = array($row['category_id'], str_repeat("-",$level). $row['category_name']);

menu($row['category_id'],$level);
}
return $hold;
}

$NewRecord1->ListBox1->Values= menu();

print_r(menu());

// -------------------------
//End Custom Code

//Close Page_BeforeShow @1-4BC230CD
return $Page_BeforeShow;
}
//End Close Page_BeforeShow


?>

####################
_________________
beshoo Love PHP and CC 4.2
View profile  Send private message
beshoo

Posts: 68
Posted: 08/27/2004, 5:55 PM

:-D thank you..... i solve the problem :)
_________________
beshoo Love PHP and CC 4.2
View profile  Send private message
DonB
Posted: 08/28/2004, 4:46 PM

Care to share the solution?

--
DonB

http://www.gotodon.com/ccbth


"beshoo" <beshoo@forum.codecharge> wrote in message
news:5412fd7e9a47fc@news.codecharge.com...
> :-D thank you..... i solve the problem :)
> _________________
> <b>beshoo Love PHP and CC 2.7</b>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

beshoo

Posts: 68
Posted: 08/28/2004, 5:35 PM

oh yes :) i will 4shur

the mean problem is the database conection and sql query.

this message :
########
mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
########
mean : your sql command dos not run as will .

so we have to make some changes to fix the problem.

1st i must put the :
$table = "directory_categories";
$hold = array();

outside of the main finction menu(). so the

//================
global $hold, $table ;
//================
will work as will :)

replaseing the
$sql = mysql_query($query);

with add a ccs new conection command.
e.g :
$db = new clsDBConnection1();
$query = "SELECT * FROM $table WHERE category_id_parent = $parent ORDER BY category_id ASC";
//$sql = mysql_query($query);
$sql = $db->query($query);

in this case the problem will solve as will.


best regards
beshoo.
_________________
beshoo Love PHP and CC 4.2
View profile  Send private message

Add new topic Subscribe to topic   


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

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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