Dreamweaver CS3 PHP Error (Full Version)

All Forums >> [Web Development] >> Dreamweaver Help



Message


sentinel -> Dreamweaver CS3 PHP Error (5/22/2007 9:27:52)

Hey all...

I am using Dreamweaver CS3 for extracting data into a PHP page froma MySQL database. The problem I am encountering is that i can only get the first record in any table. My page will show the first row of data with the folllowing warning:

mysql_fetch_assoc(): 4 is not a valid MySQL result resource

Here is my code.

<?php require_once('Connections/hcportal.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_hcportal, $hcportal);
$query_Recordset1 = "SELECT * FROM users";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $hcportal) 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;

mysql_free_result($Recordset1);
?>
<table border="1" cellpadding="2" cellspacing="2">
  <tr>
    <td>UserID</td>
    <td>x_Firstname</td>
    <td>x_Lastname</td>
    <td>UserName</td>
    <td>x_Email</td>
    <td>EmailUse</td>
    <td>Password</td>
    <td>AddDatetime</td>
    <td>UpdateDatetime</td>
    <td>AccessLevel</td>
    <td>Admin</td>
    <td>ActiveAccount</td>
    <td>AccountExpires</td>
    <td>RemoteAddress</td>
    <td>LoginCount</td>
    <td>x_Company</td>
    <td>x_Address</td>
    <td>x_City</td>
    <td>x_State</td>
    <td>x_Zip</td>
    <td>x_Country</td>
    <td>x_Phone</td>
    <td>x_Cellphone</td>
    <td>x_Fax</td>
    <td>x_Website</td>
    <td>x_Userfound</td>
    <td>x_Spare</td>
    <td>x_RefId</td>
    <td>x_Trans_id</td>
    <td>x_Auth_Code</td>
    <td>u_id</td>
    <td>x_Sex</td>
    <td>Comments</td>
    <td>photo</td>
    <td>Groups</td>
    <td>Novell</td>
    <td>BirthdayMonth</td>
    <td>BirthdayDay</td>
    <td>About</td>
    <td>ForumCount</td>
    <td>ForumSig</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_Recordset1['UserID']; ?></td>
      <td><?php echo $row_Recordset1['x_Firstname']; ?></td>
      <td><?php echo $row_Recordset1['x_Lastname']; ?></td>
      <td><?php echo $row_Recordset1['UserName']; ?></td>
      <td><?php echo $row_Recordset1['x_Email']; ?></td>
      <td><?php echo $row_Recordset1['EmailUse']; ?></td>
      <td><?php echo $row_Recordset1['Password']; ?></td>
      <td><?php echo $row_Recordset1['AddDatetime']; ?></td>
      <td><?php echo $row_Recordset1['UpdateDatetime']; ?></td>
      <td><?php echo $row_Recordset1['AccessLevel']; ?></td>
      <td><?php echo $row_Recordset1['Admin']; ?></td>
      <td><?php echo $row_Recordset1['ActiveAccount']; ?></td>
      <td><?php echo $row_Recordset1['AccountExpires']; ?></td>
      <td><?php echo $row_Recordset1['RemoteAddress']; ?></td>
      <td><?php echo $row_Recordset1['LoginCount']; ?></td>
      <td><?php echo $row_Recordset1['x_Company']; ?></td>
      <td><?php echo $row_Recordset1['x_Address']; ?></td>
      <td><?php echo $row_Recordset1['x_City']; ?></td>
      <td><?php echo $row_Recordset1['x_State']; ?></td>
      <td><?php echo $row_Recordset1['x_Zip']; ?></td>
      <td><?php echo $row_Recordset1['x_Country']; ?></td>
      <td><?php echo $row_Recordset1['x_Phone']; ?></td>
      <td><?php echo $row_Recordset1['x_Cellphone']; ?></td>
      <td><?php echo $row_Recordset1['x_Fax']; ?></td>
      <td><?php echo $row_Recordset1['x_Website']; ?></td>
      <td><?php echo $row_Recordset1['x_Userfound']; ?></td>
      <td><?php echo $row_Recordset1['x_Spare']; ?></td>
      <td><?php echo $row_Recordset1['x_RefId']; ?></td>
      <td><?php echo $row_Recordset1['x_Trans_id']; ?></td>
      <td><?php echo $row_Recordset1['x_Auth_Code']; ?></td>
      <td><?php echo $row_Recordset1['u_id']; ?></td>
      <td><?php echo $row_Recordset1['x_Sex']; ?></td>
      <td><?php echo $row_Recordset1['Comments']; ?></td>
      <td><?php echo $row_Recordset1['photo']; ?></td>
      <td><?php echo $row_Recordset1['Groups']; ?></td>
      <td><?php echo $row_Recordset1['Novell']; ?></td>
      <td><?php echo $row_Recordset1['BirthdayMonth']; ?></td>
      <td><?php echo $row_Recordset1['BirthdayDay']; ?></td>
      <td><?php echo $row_Recordset1['About']; ?></td>
      <td><?php echo $row_Recordset1['ForumCount']; ?></td>
      <td><?php echo $row_Recordset1['ForumSig']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>



Any idea what I am doing wrong?

Thanks

Rich




sentinel -> * Solved: RE: Dreamweaver CS3 PHP Error (5/22/2007 10:05:56)

quote:

mysql_free_result($Recordset1);


I didn't realize I had freed the results before I had finished with them!




mar0364 -> RE: * Solved: RE: Dreamweaver CS3 PHP Error (5/22/2007 11:45:09)

Sorry I posted this in the wrong place.

Well I'm glad I could help. [:D]




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875