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>
<?php
mysql_free_result($rsAll);
?>
<?php } while ($row_rsAll = mysql_fetch_assoc($rsAll)); ?>
<p>and then some</p>
<p> </p>
Not a valid MySQL result resource
Moderator: General Moderators
-
penguinboy
- Forum Contributor
- Posts: 171
- Joined: Thu Nov 07, 2002 11:25 am
put
after every mysql function.
Code: Select all
or die(mysql_error());Now I'm getting a parse error
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>
<?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> </p>
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>
<?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> </p>
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.
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.
Code: Select all
<?php } while (($row_rsAll = mysql_fetch_assoc($rsAll)) or die(mysql_error())) {
//something more here
}?>something more here?
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
Thanks
I figured it out
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}