Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help

Status
Not open for further replies.

asiamom2

Technical User
Mar 14, 2001
1
US


Hey, my code is posted below. Running this page returns this error:

"Warning: 0 is not a Sybase result index in"

The error message also gives a line number which corresponds to this
line:
while($row = sybase_fetch_row($q)) {

What does this error message mean? How do i fix it?

TIA!

===========================================================
<?php

include(&quot;./includes/connect.inc&quot;);
include(&quot;./includes/head.inc&quot;);

?><H4>Book Library Test</H4>
<table>
<?php


if (!$conn) {
echo &quot;Could not open database.&quot;;
exit;
}

$q = &quot;EXEC wb_getBooks @sSort = 'Author'&quot;;

if (!$q) {
echo &quot;An error occured.\n&quot;;
exit;
}

while($row = sybase_fetch_row($q)) { //this is the error line
echo&quot;<tr>&quot;;

while(list($k, $v) = each($row)) {
echo &quot;<td>$v</td>&quot;;
}

echo &quot;</TR>&quot;;
}
?>

</table>

<?php
include(&quot;./includes/foot.inc&quot;);
?>
 
Hi,
I'm using MySql, but i guess the error is the same. This error occures because your $q is empty.
Try this,
.....
$q = &quot;EXEC wb_getBooks @sSort = 'Author'&quot;;

if (!$q) {
echo &quot;An error occured.\n&quot;;
exit;
}

$number=sybase_num_rows($q); /* this returns the number of Datasets */
if ($number > 0){
while($row = sybase_fetch_row($q)) { //this is the error line
echo&quot;<tr>&quot;;
}
......

I hope this helps !

Dietmar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top