2uzhan.com
Advertisement
Now Place:2uzhan.com » Warning: 3 is not a valid ODBC result resource. What can I do? ODBC Conection is fine

Warning: 3 is not a valid ODBC result resource. What can I do? ODBC Conection is fine

PHP @ December 30, 1969   Views:0

Greetings,

I'm relatively new to PHP though I'm moving though it pretty quick. Though none of that is important, eh?

I've come across an error, which I don't know how to solve. Its message is quite straight forward, but I don't know how to handle it.

The message is this:

"Warning: 2 is not a valid ODBC result resource in c:\apache\htdocs\everything\aisling\menu.php on line 37"

What happens is that it outputs one section fine without complication, then for the second this error shows. What should happen is that 4 sections, excluding the ones I cut out in the code, should output.

For those who need to see the code to figure it out I'll attempt to past it in here, if it doesn't work email me and I'll send it.

The Code:

[?php
function MenuSectionOutput($MenuID) {
$cnx = odbc_connect( 'aislingdsndesigns' , '', '' );
if (!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}
$cur= odbc_exec( $cnx, "select * from Menu order by LID" );
if (!$cur) {
Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
}
while( odbc_fetch_row( $cur ) ) {
$Title= odbc_result( $cur, 2 );
$SectionID= odbc_result( $cur, 3 );
$LID= odbc_result ( $cur, 4 );
$PID= odbc_result ( $cur, 5 );
if ($MenuID == $SectionID){
if ($PID == "0"){
} else{
echo "[tr]
[td][a href=\""; echo $_SERVER['PHP_SELF'];
echo "?PageID=$PID\" onMouseOver=\"self.status='Aisling Designs.cjb.net - $Title'; return true\" onMouseOut=\"self.status=''\"]$Title[/a][/td]
[/tr]";
};
};
}
odbc_close( $cnx);
}
function MenuOutput() {
$cnx = odbc_connect( 'aislingdsndesigns' , '', '' );
if (!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}
$cur= odbc_exec( $cnx, "select * from MenuSection" );
if (!$cur) {
Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
}
while( odbc_fetch_row( $cur ) ) { +-+-+-+-+ Line 37 +-+-+-+-+
$MenuID= odbc_result( $cur, 1 );
$MenuTitle= odbc_result( $cur, 2 );
if ($MenuID == "5" or $MenuID == "6") {
} else {
echo "[div align=\"left\" class=\"nav\"]
[table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"]
[tr]
[td]"; if ($MenuTitle == ""){}else {echo "[span class=\"navTitle\"]$MenuTitle[/span]";}; echo"[/td]
[/tr]";
MenuSectionOutput($MenuID);
echo"[/table]
[/div]";
};
}
odbc_close( $cnx);
}

MenuOutput();
?]

I've also marked line 37 with "+-+-+-+-+ Line 37 +-+-+-+-+".

If it didn't come out alright then let me know and I'll email you the script. If you notice the "MenuSectionOutput($MenuID);" above located in "function MenuOutput()", if I take it out then the sections display fine, though without the contents of each.

Any help on this would be greatly appreciated.

--------------Solutions-------------

Tags:
© 2018 2uzhan.com Contact