Skip to main content
Participating Frequently
November 8, 2012
Answered

Getting wrong data from mysql query

  • November 8, 2012
  • 1 reply
  • 2775 views

The database I built for the website in question, http://www.socalda.org contains meeting infomation, General meeting info, location, focus, and contact.  There are different recordsets for different pages. 

I have pages for meetings on days of the week, time of day, and counties and cities. 

I just entered a new meeting to my database and it seems that the contact info is not coming out correctly. 

I thought it was pulling the wrong contact info but I am now satisfied that what is actually happening is the layout on my pages, for the results,  is bad. 

When I test this SQL query both in PHPMyAdmin and Dreamweaver it works fine.  When I pull the page up It only shows 9 records. 

I have upped the repeat to 20 in the Server Behaviors tab and it is still the same. 

Here is the code for this page:

<?php require_once('Connections/connda.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $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_wed_meet = 20;
$pageNum_wed_meet = 0;
if (isset($_GET['pageNum_wed_meet'])) {
  $pageNum_wed_meet = $_GET['pageNum_wed_meet'];
}
$startRow_wed_meet = $pageNum_wed_meet * $maxRows_wed_meet;

mysql_select_db($database_connda, $connda);
$query_wed_meet = "SELECT mstr_meeting.NAME, mstr_meeting.ROOM_NAME, TIME_FORMAT(mstr_meeting.start_time,'%l:%i %p') AS TIME, mstr_meeting.DURATION, mstr_meeting.DAY_OF_WEEK, mstr_meeting.MEETING_NOTES, mstr_location.BUILDING_NAME, mstr_location.STREET_ADDRESS, mstr_location.CITY, mstr_location.ZIP_CODE, mstr_location.SPEC_DIRECTIONS, mstr_location.MAP_URL, mstr_contact.CNCT_FNAME, mstr_contact.CNCT_PHONE, group_concat(mstr_feature.DESCR) AS DESCR

FROM (((((mstr_meeting INNER JOIN mstr_location ON mstr_meeting.LID = mstr_location.LID)

LEFT JOIN mstr_meeting_contact ON mstr_meeting.MID = mstr_meeting_contact.MID)

LEFT JOIN mstr_contact ON mstr_meeting_contact.CID = mstr_contact.CID)

LEFT JOIN mstr_meeting_feature ON mstr_meeting.MID = mstr_meeting_feature.MID)

LEFT JOIN mstr_feature ON mstr_meeting_feature.FID = mstr_feature.FID)

LEFT JOIN mstr_days ON mstr_meeting.DAY_OF_WEEK = mstr_days.DAY

WHERE mstr_meeting.DAY_OF_WEEK = 'WE'

GROUP BY mstr_meeting.NAME, mstr_meeting.ROOM_NAME, mstr_meeting.start_time, mstr_meeting.DURATION, mstr_meeting.DAY_OF_WEEK, mstr_meeting.MEETING_NOTES, mstr_location.BUILDING_NAME, mstr_location.STREET_ADDRESS, mstr_location.CITY, mstr_location.ZIP_CODE, mstr_location.SPEC_DIRECTIONS, mstr_location.MAP_URL, mstr_contact.CNCT_FNAME, mstr_contact.CNCT_PHONE ORDER BY mstr_days.NO, mstr_meeting.start_time, mstr_meeting.NAME ";


$query_limit_wed_meet = sprintf("%s LIMIT %d, %d", $query_wed_meet, $startRow_wed_meet, $maxRows_wed_meet);
$wed_meet = mysql_query($query_limit_wed_meet, $connda) or die(mysql_error());
$row_wed_meet = mysql_fetch_assoc($wed_meet);

if (isset($_GET['totalRows_wed_meet'])) {
  $totalRows_wed_meet = $_GET['totalRows_wed_meet'];
} else {
  $all_wed_meet = mysql_query($query_wed_meet);
  $totalRows_wed_meet = mysql_num_rows($all_wed_meet);
}
$totalPages_wed_meet = ceil($totalRows_wed_meet/$maxRows_wed_meet)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Wednesday DA  Meetings</title>
<link href="styles/daone.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
/* Give the menu bar a width and set the margins to "auto"
* so that the browser does the centering.
*/

ul.MenuBarHorizontal {
width: 50.2em;
margin: auto;
}
/* Center the text within all menu item links.
*/

ul.MenuBarHorizontal a {
text-align: center;
background-color:#FC9;
}

/* Set the the alignment back to left for any
* menu item links that are in a sub menu.
*/

ul.MenuBarHorizontal ul a {
text-align: left;
}
-->
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
</style>

</head>

<body >


<div id="container">
  <div id="banner"><img src="images/newheadercb2.png" alt="socalda" width="1101" height="180"  /></div>
  <div id="main_image">
  <?php include("includes/menu.php"); ?>
 
  </div><br /><br /><br />
  <div id="meeta_col"><h2 align="center">Meeting Lists</h2>
  <?php include("includes/menu2.php"); ?>
    </div>
  <div id="meetb_col"><h2 align="center">Wednesday Meetings</h2>
     <table  class="myTable">
      <tr>
        <th>NAME</th>
        <th>ROOM</th>
        <th>TIME</th>
        <th>LENGTH</th>
        <th>DAY</th>
        <th>NOTES</th>
        <th>BUILDING</th>
        <th>ADDRESS</th>
        <th>CITY</th>
        <th>ZIP</th>
        <th>DIRECTIONS</th>
        <th>MAP</th>
        <th>CONTACT</th>
        <th>PHONE</th>
        <th>DESCR</th>
      </tr>
      <?php do { ?>
        <tr>
          <td><?php echo $row_wed_meet['NAME']; ?></td>
          <td><?php echo $row_wed_meet['ROOM_NAME']; ?></td>
          <td><?php echo $row_wed_meet['TIME']; ?></td>
          <td><?php echo $row_wed_meet['DURATION']; ?></td>
          <td><?php echo $row_wed_meet['DAY_OF_WEEK']; ?></td>
          <td><?php echo $row_wed_meet['MEETING_NOTES']; ?></td>
          <td><?php echo $row_wed_meet['BUILDING_NAME']; ?></td>
          <td><?php echo $row_wed_meet['STREET_ADDRESS']; ?></td>
          <td><?php echo $row_wed_meet['CITY']; ?></td>
          <td><?php echo $row_wed_meet['ZIP_CODE']; ?></td>
          <td><?php echo $row_wed_meet['SPEC_DIRECTIONS']; ?></td>
          <td><?php echo $row_wed_meet['MAP_URL']; ?></td>
          <td><?php echo $row_wed_meet['CNCT_FNAME']; ?></td>
          <td><?php echo $row_wed_meet['CNCT_PHONE']; ?></td>
          <td><?php echo $row_wed_meet['DESCR']; ?></td>
        </tr>
        <?php } while ($row_wed_meet = mysql_fetch_assoc($wed_meet)); ?>
    </table>
<br /><br />
  <hr />
  </div>
</div>


</body>

</html>
<?php
mysql_free_result($wed_meet);
?>

I actually should have 10 rows for meetings on Wednesday but still only get nine. 

The funny part is the record that shows up in Dreamweaver test and PHPMyAdmin below the newly inserted record has there contact showing up in the newly inserted meeting info but that meeting does not show up at all.  It keeps it to nine records.  

So the rows in the browser are overlapping for some reason? 

I have deleted the new entries and reinserted them to no avail.  It still only shows 9 rows.  I actually had the rows set to all records and have played with that but it didn't do anything. 

If anyone has any pointers to where I can go get info on this issue I would appreciate it. 

Thanks. 

This topic has been closed for replies.
Correct answer bregent

This is the result from phpMySQL:

Abundance and Visions: There is enoughNULL7:30 AM60WENULLRadford Hall13627 1/2 Victory BlvdVan Nuys91401Behind Tequila's Restaurant<a href="http://maps.yahoo.com/#mvt=m&lat=34.18683...Susan(323) 839-8550Focus on Vision work
"DA Women Stepping Together"Conference Room12:00 PM60WENULLWestminster Presbyterian Church1757 N. Lake AvePasadena91104enter on Atchison St (1 block south of Woodbury)<a href="http://maps.yahoo.com/#mvt=m&lat=34.17590...Rene(626) 253-2851NULL
818 Artist BDAIn the New room12:00 PM60WE*First Meeting starts November 21Faith Presbyterian Church5000 Colfax Ave.Valley Village91601NE Corner of Colfax and Addison just south of Magn...<a href="http://maps.yahoo.com/#tt=&q=5000+Colfax+...Randi(760) 641-5847NULL
Wed Noon BDA MeetingCommunity RM off pkg level 112:00 PM90WEAt far west side of P1 through door with DA sign o...Sunset Plaza8000 W Sunset Blvd (at Cresent Heights)Los Angeles9002590 min free parking with validation from merchant,...<a href="http://maps.yahoo.com/maps_result?ed=z1mM...Wally(310) 659-8188NULL
Third Step Focus/SpeakerNULL6:30 PM60WEHancock ParkWilshire United Methodist Church711 S Plymouth (at Wilshire)Hancock Park90005-3722Large Church parking lot available<a href="http://maps.yahoo.com/py/maps.py?BFCat=&P...NULLNULLNULL
Asked and AnsweredNULL7:00 PM90WESpeaker, Q&A, and SharingNational Council of Jewish Women Building543 N Fairfax AveLos Angeles90036Third and Fairfax<a href="http://maps.google.com/maps?f=q&source=s_...Tim(323) 848-8992speaker shares expericence, strength, and hope
Currency of HopeNULL7:00 PM90WESD University HeightsUniversity Heights4545 Park Blvd, Suite 105San Diego92116NULL<a href="http://maps.yahoo.com/#q=4545+Park+Blvd%2...Chris619-260-8009NULL
Debtors with Time Issues2087:00 PM90WENULLGlendale Presbyterian Church125 S Louise (at Harvard)Glendale91205Two blocks E of Brand; one block N of Colorada; ac...<a href="http://maps.yahoo.com/py/maps.py?BFCat=&P...Katie310.592.6477time issues focus,Snacks
Long Beach Self-Employed Group (DA/BDA)Patio room next to main meeting hall.7:00 PM75WENULLMemorial West Alano Club(MWA)835 E. 33rd StreetLong Beach90755Directly across from Target. Enter from rear park...<a href="http://maps.yahoo.com/#mvt=m&lat=33.81723...Stewart(562) 884-6010business owners / self employed focus / all DA mem...
Living in the Light Visions MeetingsSmall Meeting Room7:30 PM60WENULLRadford Hall13627 1/2 Victory BlvdVan Nuys91401Behind Tequila's Restaurant<a href="http://maps.yahoo.com/#mvt=m&lat=34.18683...Jean(310) 909-9780Focus on Vision work

This is the output on the webpage:

NAMEROOMTIMELENGTHDAYNOTESBUILDINGADDRESSCITYZIPDIRECTIONSMAPCONTACTPHONEDESCR
Abundance and Visions: There is enough7:30 AM60WERadford Hall13627 1/2 Victory BlvdVan Nuys91401Behind Tequila's RestaurantMapSusan(323) 839-8550Focus on Vision work
"DA Women Stepping Together"Conference Room12:00 PM60WEWestminster Presbyterian Church1757 N. Lake AvePasadena91104enter on Atchison St (1 block south of Woodbury)MapRene(626) 253-2851
818 Artist BDAIn the New room12:00 PM60WE*First Meeting starts November 21Faith Presbyterian Church5000 Colfax Ave.Valley Village91601NE Corner of Colfax and Addison just south of Magnolia.MapRandi(760) 641-5847
Wed Noon BDA MeetingCommunity RM off pkg level 112:00 PM90WEAt far west side of P1 through door with DA sign on it.Sunset Plaza8000 W Sunset Blvd (at Cresent Heights)Los Angeles9002590 min free parking with validation from merchant, free parking on Laurel Ave. MapWally(310) 659-8188
Third Step Focus/Speaker6:30 PM60WEHancock ParkWilshire United Methodist Church711 S Plymouth (at Wilshire)Hancock Park90005-3722Large Church parking lot availableMap
Asked and Answered7:00 PM90WESpeaker, Q&A, and SharingNational Council of Jewish Women Building543 N Fairfax AveLos Angeles90036Third and FairfaxMapTim(323) 848-8992speaker shares expericence, strength, and hope
Currency of Hope7:00 PM90WESD University HeightsUniversity Heights4545 Park Blvd, Suite 105San Diego92116MapChris619-260-8009
Debtors with Time Issues2087:00 PM90WEGlendale Presbyterian Church125 S Louise (at Harvard)Glendale91205Two blocks E of Brand; one block N of Colorada; across from public library; park on Louise across from church.MapKatie310.592.6477time issues focus,Snacks
Long Beach Self-Employed Group (DA/BDA)Patio room next to main meeting hall.7:00 PM75WEMemorial West Alano Club(MWA)835 E. 33rd StreetLong Beach90755Directly across from Target. Enter from rear parking lotMapStewart(562) 884-6010business owners / self employed focus / all DA members welcome,Speaker on 2nd and 4th week.
Living in the Light Visions MeetingsSmall Meeting Room7:30 PM60WERadford Hall13627 1/2 Victory BlvdVan Nuys91401Behind Tequila's RestaurantMapJean(310) 909-9780Focus on Vision work

I just copied and pasted the results from the webpage and it all shows up!  Except you cannot see the white sections on the webpage. 


OK, sounds like something in the data interfering with the HTML. Can you render the page in a browser, and then post the broswer source code to this thread?

1 reply

Participating Frequently
November 9, 2012

What happens if you enter 11 records? Does it output 9 or 10? This will tell you if you have an off-by-one coding error. Can you use mysql_num_rows (or equivalent) to see how many rows the query is actually returning?

dlojAuthor
Participating Frequently
November 9, 2012

I tried 11 records and it did nothing. I am not quite sure where to put the mysql_num_rows in my code.

When I run the query in Dreamweaver (test of the recordset) it returns 10 rows and the same for PHPMy Admin which is what it is supposed to do. So I am thinking it is the either the Dreamweaver version of the PHP/MYSql query and/or Dreamweaver is messing up somehow.

It happens in all browsers.

As is obvious I am rather new to PHP/MYSql and Dreamweaver itself. I was thinking I might need to write the query code myself and not use the Dreamweaver recordset appliance to pull the data.

Participating Frequently
November 10, 2012

I apologize I misspoke when I said nothing happens.  What happens when I enter 11 records only 9 come back.  I should have said nothing changes.

The record missing is the fourth one.  Except the contact from the 4th one takes the place of the contact of the new one I entered.  Number 3 record. 

I have tried a lot of different ways to try and see mysql_num_rows but a number never shows up.

I even lowered the repeat region to 3 and nothing changed still 9 with the record 3 mixing it up with record 4 in the contact region. 

Upon further investigation when I add a:

$results = $mysql_num_rows($query_wed_meet);

echo "the number of rows are:".$results;

The recordset in the bindings panel disappears. 

Now i am really lost.  oh boy.


>The recordset in the bindings panel disappears.

That's expected. When you modify DW generated code, DW no longer recognizes it. Just run the page and get the results - then you can undo your mods. Getting the row count will help determine whether you have a query problem or an output problem.