My web host recently updated their version of PHP and some of my code is no longer working. I created a band website that stores news items in a MySQL database. I created an update page (news.php) where the band can log in and add, update, or delete news. I have the following section of code in news.php which displayes news items from the table into a drop down list and calls a javascript function to pop up the news item in another window:
<form name="updateNews" method="post" onSubmit="updateWindow(this.updateNews.value)" >
<tr>
<td width="17%"><div align="right"><strong>Select news to Update:</strong></div></td>
<td width="1%"> </td>
<td width="82%"><div align="left">
<select name="updateNews" class="select">
<?php
do
{
?>
<option value="<?php echo $row_NewsUpdate['seq_id']?>"><?php echo $row_NewsUpdate['news_date']?></option>
<?php
}
while ($row_NewsUpdate = mysql_fetch_assoc($NewsUpdate));
$rows = mysql_num_rows($NewsUpdate);
if($rows > 0)
{
mysql_data_seek($NewsUpdate, 0);
$row_NewsUpdate = mysql_fetch_assoc($NewsUpdate);
}
?>
</select>
</div>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input name="update" type="submit" class="buttons" id="update" value="Get News to Update" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</form>
I have the following code to select from the database (I put xxxxx in place of real names):
mysql_select_db($database_xxxxxx, $xxxxxx);
$query_NewsUpdate = "select seq_id,news_date,news_content from news order by news_date DESC";
$NewsUpdate = mysql_query($query_NewsUpdate, $xxxxxx) or die(mysql_error());
$row_NewsUpdate = mysql_fetch_assoc($NewsUpdate);
$totalRows_NewsUpdate = mysql_num_rows($NewsUpdate);
$query_NewsDelete = "select seq_id,news_date,news_content from news order by news_date DESC";
$NewsDelete = mysql_query($query_NewsDelete, $xxxxxx) or die(mysql_error());
$row_NewsDelete = mysql_fetch_assoc($NewsDelete);
$totalRows_NewsDelete = mysql_num_rows($NewsDelete);
?>
Here is the Javascript function I'm using:
<!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>
<script language="JavaScript">
<!--
function updateWindow(seq_id)
{
newsUpdateWindow = window.open("updateNews.php?seq_id="+seq_id,"newsUpdate_window","height=500,width=600,scrollbars");
}
function deleteWindow(seq_id)
{
newsDeleteWindow = window.open("deleteNews.php?seq_id="+seq_id,"newsDelete_window","height=500,width=600,scrollbars");
}
//-->
</script>
A couple of things I checked:
- news.php is receiving the seq_id and is populating the drop down list with the correct values.
- I put print statements in update.php to see if it was receiving the seq_id from news.php and it is not.
This code worked great until php was updated on the server. I'm not sure why seq_id is no longer being passed to update.php.
Any thoughts on what may be happening? I really appreciate any help.