I've had a mysql database on my website for about 10 years. I recently (5 or 6 months) ago had to upgrade to version 5.x and did so without any problems. My database uses four tables and has been working fine until about a week ago. One of my tables is now returning only one record even when there are many records matching the query. I have not made any changes to the code for many years. I have been researching this problem for several hours and have not come up with any answers and so I'm posting the code here for some help. This code is querying a flat file with 11,549 records, each record containing 15 fields.
<?php
mysql_connect ('localhost:/tmp/mysql5.sock', 'my_user_name', 'my_password') or
die("Could not connect: " . mysql_error());
mysql_select_db (virtualc_sac);
$result = mysql_query ("select * from doublestar
where con = '$con' and sep > '$sep1' and sep < '$sep2'
group by 'name' order by '$order'");
echo ("<tr><td colspan='14' align='center'><font face='arial, helvetica' size='2'>
<b>Search Results for<br>
Constellation=$con and Separation > $sep1 arc minutes
and Separation < $sep2 arc minutes, Sorted by $order</b><br><br></td></tr>");
if (mysql_num_rows($result) == 0) {
echo "<tr><td width='10'></td>
<td width='470' colspan='14' align='left'><font face='arial, helvetica' size='2'>Sorry, no records were found. Try altering your selection criteria. Hitting the BACK button on your browser will show you your previous selection criteria.</td>";
} else {
while ($row = mysql_fetch_array($result)) {
{
echo "<tr>
<td width='80' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>Name
</td>
<td width='50' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>Star
</td>
<td width='50' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>RA
</td>
<td width='50' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>Dec
</td>
<td width='30' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>Comp
</td>
<td width='50' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>Mag1
</td>
<td width='50' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>Mag2
</td>
<td width='30' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>Sep
</td>
<td width='30' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>PA
</td>
<td width='60' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>U2000
</td>
<td width='30' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>Spec
</td>
<td width='240' align='left' valign='bottom'>
<font face='arial, helvetica' size='1'>Notes
</td>";
echo "<tr>
<td width='80' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["name"];
echo "</td>";
echo "<td width='50' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["star"];
echo "</td>";
echo "<td width='50' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["ra"];
echo "</td>";
echo "<td width='50' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["decl"];
echo "</td>";
echo "</td>";
echo "<td width='30' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["comp"];
echo "</td>";
echo "<td width='50' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["mag1"];
echo "</td>";
echo "<td width='50' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["mag2"];
echo "</td>";
echo "<td width='30' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["sep"];
echo "</td>";
echo "<td width='30' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["pa"];
echo "</td>";
echo "<td width='60' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["u2000"];
echo "</td>";
echo "<td width='30' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
echo $row["spec"];
echo "</td>";
echo "<td width='240' align='left' valign='top'>
<font face='arial, helvetica' size='1'>";
开发者_C百科 echo $row["notes"];
echo "</td></tr>";
}
}
}
?>
@DuaneFrybarger I would start by making sure your database is ok. Personally, my favorite tool is phpMyAdmin, and use the SQL tab to type in your query and run it. If all of the records come up as expected, then the database is ok. If not, then run a simple SELECT * ...
query to make sure all of the records are there. If all of this goes ok, then you need to go through all of your HTML again. Some other thoughts:
- your code to create the row of headings is inside the while-loop - do you want a header row for each record?
- there's an extra
</td>
as mentioned previously right afterecho $row["decl"];
- are the variables assigned earlier in your script from
$_POST
-variables?
精彩评论