Problems with dynamic table
Posted: Thu Nov 05, 2009 9:50 pm
I am using the standard dreamweaver dynamic table creation tools and am querying a simple database. When I run the test in the connection editor, I get no errors and all the records are displayed. However, when I run the page in a browser window, I am getting an error:
" Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in /home/content/a/d/v/advemark/html/expenses1.php on line 78"
Here's the dreamweaver code:
The line that it seems is having the problem is <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> but I can't understand why. Can anybody help with this?
" Warning: mysql_fetch_assoc(): 3 is not a valid MySQL result resource in /home/content/a/d/v/advemark/html/expenses1.php on line 78"
Here's the dreamweaver code:
Code: Select all
<?php require_once('Connections/tester.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_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_tester, $tester);
$query_Recordset1 = "SELECT * FROM VehicleExpenses";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $tester) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?><style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="css/Level3_1.css" rel="stylesheet" type="text/css" />
<?php mysql_free_result($Recordset1);?>
<table border="0" cellpadding="5" cellspacing="1">
<tr>
<td>ExpenseID</td>
<td>ExpenseType</td>
<td>ExpenseGroup</td>
<td>ExpenseDate</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['ExpenseID']; ?></td>
<td><?php echo $row_Recordset1['ExpenseType']; ?></td>
<td><?php echo $row_Recordset1['ExpenseGroup']; ?></td>
<td><?php echo $row_Recordset1['ExpenseDate']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>