Hi,
I just want to make a resultpage to show all the records in the database. I used Dreamweaver but I recieved everytime i preview the page the following error:
Warning: mysql_fetch_assoc(): 2 is not a valid MySQL result resource in c:\phpdev\www\signalbn\leden\php\display_members.php on line 71
See my code below:
<?php require_once('../../Connections/localhost.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_DISPLAY_MEMBERS = 10;
$pageNum_DISPLAY_MEMBERS = 0;
if (isset($GET['pageNum_DISPLAY_MEMBERS'])) {
$pageNum_DISPLAY_MEMBERS = $GET['pageNum_DISPLAY_MEMBERS'];
}
$startRow_DISPLAY_MEMBERS = $pageNum_DISPLAY_MEMBERS * $maxRows_DISPLAY_MEMBERS;
mysql_select_db($database_localhost, $localhost);
$query_DISPLAY_MEMBERS = "SELECT leden.nummer, leden.naam, leden.voorletters, leden.tussenvoegsels, leden.registratienummer FROM leden";
$query_limit_DISPLAY_MEMBERS = sprintf("%s LIMIT %d, %d", $query_DISPLAY_MEMBERS, $startRow_DISPLAY_MEMBERS, $maxRows_DISPLAY_MEMBERS);
$DISPLAY_MEMBERS = mysql_query($query_limit_DISPLAY_MEMBERS, $localhost) or die(mysql_error());
$row_DISPLAY_MEMBERS = mysql_fetch_assoc($DISPLAY_MEMBERS);
if (isset($GET['totalRows_DISPLAY_MEMBERS'])) {
$totalRows_DISPLAY_MEMBERS = $GET['totalRows_DISPLAY_MEMBERS'];
} else {
$all_DISPLAY_MEMBERS = mysql_query($query_DISPLAY_MEMBERS);
$totalRows_DISPLAY_MEMBERS = mysql_num_rows($all_DISPLAY_MEMBERS);
}
$totalPages_DISPLAY_MEMBERS = ceil($totalRows_DISPLAY_MEMBERS/$maxRows_DISPLAY_MEMBERS)-1;
mysql_free_result($DISPLAY_MEMBERS);
?>
<table border="0">
<tr>
<td>nummer</td>
<td>naam</td>
<td>voorletters</td>
<td>tussenvoegsels</td>
<td>registratienummer</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_DISPLAY_MEMBERS['nummer']; ?></td>
<td><?php echo $row_DISPLAY_MEMBERS['naam']; ?></td>
<td><?php echo $row_DISPLAY_MEMBERS['voorletters']; ?></td>
<td><?php echo $row_DISPLAY_MEMBERS['tussenvoegsels']; ?></td>
<td><?php echo $row_DISPLAY_MEMBERS['registratienummer']; ?></td>
</tr>
<?php } while ($row_DISPLAY_MEMBERS = mysql_fetch_assoc($DISPLAY_MEMBERS)); ?>
</table>
Who can help me to fix this. THANKS!