Page 1 of 1

Not a valid MySQL result resource

Posted: Fri Mar 12, 2004 2:40 pm
by saltriver
I got this error on the following page:
Warning: 2 is not a valid MySQL result resource in /home/slacker/saltrivergraphics.com/phptest4.php on line 31
http://saltrivergraphics.com/phptest4.php

I think I might be doing the repeat region wrong, since this is as far as I've gotten so far. Could someone take a look at the code and please tell me where I went wrong. I tried putting a ; at the end of line 2, but that didn't work.
Working w/ DWMX, MAC 10.2.8, databases by myphpadmin through my host. DW seems to be connecting fine.

Steve McIntyre



<?php require_once('Connections/slacker_music.php'); ?>
<?php
$maxRows_rsAll = 15;
$pageNum_rsAll = 0;
if (isset($HTTP_GET_VARS['pageNum_rsAll'])) {
$pageNum_rsAll = $HTTP_GET_VARS['pageNum_rsAll'];
}
$startRow_rsAll = $pageNum_rsAll * $maxRows_rsAll;


mysql_select_db($database_slacker_music, $slacker_music);
$query_rsAll = "SELECT * FROM selections";
$query_limit_rsAll = sprintf("%s LIMIT %d, %d", $query_rsAll, $startRow_rsAll, $maxRows_rsAll);
$rsAll = mysql_query($query_limit_rsAll, $slacker_music) or die(mysql_error());
$row_rsAll = mysql_fetch_assoc($rsAll);

if (isset($HTTP_GET_VARS['totalRows_rsAll'])) {
$totalRows_rsAll = $HTTP_GET_VARS['totalRows_rsAll'];
} else {
$all_rsAll = mysql_query($query_rsAll);
$totalRows_rsAll = mysql_num_rows($all_rsAll);
}
$totalPages_rsAll = ceil($totalRows_rsAll/$maxRows_rsAll)-1;
?>

<p>A List of My Music</p>
<?php do { ?>
<p>&nbsp;
<?php
mysql_free_result($rsAll);
?>
<?php } while ($row_rsAll = mysql_fetch_assoc($rsAll)); ?>
<p>and then some</p>
<p>&nbsp; </p>

Posted: Fri Mar 12, 2004 3:28 pm
by penguinboy
put

Code: Select all

or die(mysql_error());
after every mysql function.

Now I'm getting a parse error

Posted: Sat Mar 13, 2004 7:34 pm
by saltriver
I added "or die(mysql_error());" after all of the mysql lines, and now I'm getting this error:

Parse error: parse error, expecting `';'' in /home/slacker/saltrivergraphics.com/phptest4.php on line 31

Is this the process of debugging?

Here is the updated code:

<?php require_once('Connections/slacker_music.php'); ?>
<?php
$maxRows_rsAll = 15;
$pageNum_rsAll = 0;
if (isset($HTTP_GET_VARS['pageNum_rsAll'])) {
$pageNum_rsAll = $HTTP_GET_VARS['pageNum_rsAll'];
}
$startRow_rsAll = $pageNum_rsAll * $maxRows_rsAll;

mysql_select_db($database_slacker_music, $slacker_music) or die(mysql_error());
$query_rsAll = "SELECT * FROM selections";
$query_limit_rsAll = sprintf("%s LIMIT %d, %d", $query_rsAll, $startRow_rsAll, $maxRows_rsAll);
$rsAll = mysql_query($query_limit_rsAll, $slacker_music) or die(mysql_error());
$row_rsAll = mysql_fetch_assoc($rsAll) or die(mysql_error());

if (isset($HTTP_GET_VARS['totalRows_rsAll'])) {
$totalRows_rsAll = $HTTP_GET_VARS['totalRows_rsAll'];
} else {
$all_rsAll = mysql_query($query_rsAll) or die(mysql_error()); ;
$totalRows_rsAll = mysql_num_rows($all_rsAll) or die(mysql_error());
}
$totalPages_rsAll = ceil($totalRows_rsAll/$maxRows_rsAll)-1;
?>

<p>A List of My Music</p>
<?php do { ?>
<p>&nbsp;
<?php
mysql_free_result($rsAll) or die(mysql_error());
?>
<?php } while ($row_rsAll = mysql_fetch_assoc($rsAll)) or die(mysql_error()); ?>
<p>and then some</p>
<p>&nbsp; </p>

Posted: Sat Mar 13, 2004 10:09 pm
by allenmak
Hello, saltriver
for Line 31, you have a WHILE statement, it contains just the conditions, but no followup scripts.
I guess you shouldn't have ";" at there. :o

Code: Select all

<?php } while (($row_rsAll = mysql_fetch_assoc($rsAll)) or die(mysql_error())) {
//something more here
}?>

something more here?

Posted: Sun Mar 14, 2004 12:57 am
by saltriver
I'm guessing I should put something similar to the if/else in this spot. Maybe a while/then? Since I'm doing this by hand now (instead of using Dreamweaver), could you give me something (anything) to plug in there? Please? This is my first venture into this (database, php, mysql) and at this point I'm desparate to just get something other than an error to show up.

Thanks

I figured it out

Posted: Sun Mar 14, 2004 3:41 pm
by saltriver
I was doing the Repeat Region thing wrong in DW. Actually I was also doing the Binding thing wrong too. I wasn't inserting the Recordset correctly, so I had no chance of getting the Repeat Region to work. Once I figured out that I had to see something like "{rshierdgoons.Player}