I have inherited a site and am trying to go from knowing zero about PHP as quickly as possible and hope you can help. We had an upgrade to our SQL database recently which changed the way SQL allows you to create columns as it moved to explicit mode. So we had to change a column that is storing the year.
- tourn_year - type year (4), Null No, Default None
I have managed to fix most of the php code we have managed to fix except this one…
The code is trying to calculate is whether the record we are reading in from our SQL DB which contains a 4 digit year <> to the current year (first paragraph below).
It is then meant to display the records it finds which have a year <> to this year into a page of that year (“previous years”) (second paragraph below). But all we get is all the records in a page dated year 0 ??
I was hoping to use the echo statement to see what year was being picked up from the query below in the first paragraph but when I add "echo $tyear; I get the “Resource id 5” ???
Any help troubleshooting this would be appreciated
mysql_select_db($database_connvbsa, $connvbsa);
$query_tyear = "SELECT YEAR (tourn_year) AS Tyear FROM tournaments WHERE YEAR(tourn_year) <> YEAR( CURDATE( ) ) GROUP BY Tyear ORDER BY Tyear DESC";
$tyear = mysql_query($query_tyear, $connvbsa) or die(mysql_error());
$row_tyear = mysql_fetch_assoc($tyear);
$totalRows_tyear = mysql_num_rows($tyear);
<table align="center" cellpadding="5" cellspacing="5">
<tr>
<td>View tournaments from previous years</td>
</tr>
<?php do { ?>
<tr>
<td align="center" class="greenbg" > <a href="aa_tourn_index_history.php?tourn_year=<?php echo $row_tyear['Tyear']; ?>"><?php echo $row_tyear['Tyear']; ? ></a></td>
</tr>
<?php } while ($row_tyear = mysql_fetch_assoc($tyear)); ?>
</table>
<p> </p>
</body>
</html>
<?php
mysql_free_result($tourn1);
mysql_free_result($tourn2);
mysql_free_result($tyear);
mysql_free_result($tourn_closed);
?>