Function returns "Bad result index 0"

From: Date: Sun, 29 Oct 2000 20:28:56 +0000
Subject: Function returns "Bad result index 0"
Groups: php.db 
Request: Send a blank email to php-db+get-4025@lists.php.net to get a copy of this message
I'm trying to reduce the size of one of my pages by trying my first attempt at a function. The function is: function profiles ($first, $second, $heading) { $sql="SELECT * FROM movieprofile, titles WHERE movieprofile.title_id=titles.title_id AND movieprofile.releasedate BETWEEN $first and $second"; $result = @odbc_exec($connect, $sql); $profile_id = odbc_result($result, profile_id); if ($profile_id != 0) { echo "$heading<br />"; $result = @odbc_exec($connect, $sql); while (@odbc_fetch_row($result)) { $title_name = odbc_result($result, title_name); $title_description = odbc_result($result, title_description); $profile_id = odbc_result($result, profile_id); echo ("<a href=\"/movies/profile.shtml/$profile_id\" title=\"Our profile on $title_name. $title_description\">$title_name</a><br />\n"); } } } And I'm calling it with: profiles ($today, $comingsoon, "Coming Soon"); The same coding works fine when it's not a function and returns the results between $today and $comingsoon. If I add an echo $sql; into the function for debugging it shows the right SQL statement. When I try and call the function it returns with: Warning: Bad result index 0 in movies2.shtml on line 146 In this example this is roughly in the area of: $profile_id = odbc_result($result, profile_id); if ($profile_id != 0) { Any ideas or advice? Thanks. -- Ian Evans

« previous php.db (#4025) next »