Ad:
 
  • PHP Discussion Thread
  • Unsolved
  • Views: 407
  • PHP RSS
Similar Threads
Jun 24th, 2010
0

Code no longer works after php was upgraded to latest version

Expand Post »
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%">&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td><input name="update" type="submit" class="buttons" id="update" value="Get News to Update" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</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:

1. news.php is receiving the seq_id and is populating the drop down list with the correct values.
2. 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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mugojoe is offline Offline
2 posts
since Jun 2010
Jun 25th, 2010
0

Re: Code no longer works after php was upgraded to latest version

Try to use directly the echo statement with your javascript code

PHP Syntax (Toggle Plain Text)
  1. <?php echo $seq_id;?>
Reputation Points: 153
Solved Threads: 229
Nearly a Posting Virtuoso
rajarajan07 is offline Offline
1,398 posts
since May 2008
Jun 25th, 2010
0

Re: Code no longer works after php was upgraded to latest version

from php version ?? to php version ??
the php.net website has a long list of details on the upgrade from one version of php to the next, lilkely you can go there and find details on what syntax is changed
often an variable that was able to be accessed as $variable has been changed so that it is accessed as $_server['variable'] $_get['variable'] or some other simple change
without knowing the two versions of php incvolved we are all shooting in the dark

when submitting code wrap it in [code=language] code [/code] tags where 'language' is php|html|css|perl|javascript|sql (any language) and the code will be presented appropriately highlighted,
often people who know the solution, wont bother if they have to wade through plain text
Last edited by almostbob; Jun 25th, 2010 at 8:47 am.
Reputation Points: 402
Solved Threads: 286
Nearly a Posting Maven
almostbob is offline Offline
2,333 posts
since Jan 2009
Jun 25th, 2010
0

Re: Code no longer works after php was upgraded to latest version

Quote ...
I put print statements in update.php to see if it was receiving the seq_id from news.php and it is not.
most likely this is the "register global" problem. You should edit your code as Almostbob recommend, using $_POST[] etc.
Reputation Points: 10
Solved Threads: 5
Light Poster
farhan386 is offline Offline
39 posts
since Jul 2008
Jun 29th, 2010
0

Re: Code no longer works after php was upgraded to latest version

Sorry about not wrapping the code in tags - I will make sure to do that in the future. This was my first post.

PHP was upgraded from php4 to php5. The select queries (which populate the option_value) are working fine. I believe the root is either the variable I'm trying to pass from option_value to the Javascript pop_up window function isn't being received or the javascript function isn't passing the variable successfully to the next php page to bring up the specific record. I'm not sure how to test if the Javascript function is receiving the variable being passed from the option_value.

Obviously, I don't have much experience in this area. It's been about 5 years since I wrote the original code and haven't really worked with PHP or Javascript since.

Any direction you can give is appreciated. Thanks!

Click to Expand / Collapse  Quote originally posted by almostbob ...
from php version ?? to php version ??
the php.net website has a long list of details on the upgrade from one version of php to the next, lilkely you can go there and find details on what syntax is changed
often an variable that was able to be accessed as $variable has been changed so that it is accessed as $_server['variable'] $_get['variable'] or some other simple change
without knowing the two versions of php incvolved we are all shooting in the dark

when submitting code wrap it in [code=language] code [/code] tags where 'language' is php|html|css|perl|javascript|sql (any language) and the code will be presented appropriately highlighted,
often people who know the solution, wont bother if they have to wade through plain text
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mugojoe is offline Offline
2 posts
since Jun 2010
Jun 30th, 2010
0

Re: Code no longer works after php was upgraded to latest version

If anyone thought there was anything other than newness as the source,
ya wouldn' believe how **expletive deleted** some of the replies would be,
Reputation Points: 402
Solved Threads: 286
Nearly a Posting Maven
almostbob is offline Offline
2,333 posts
since Jan 2009
Jun 30th, 2010
0

Re: Code no longer works after php was upgraded to latest version

maybe this

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. do
  3. {
  4. ?>
Reputation Points: 10
Solved Threads: 0
Junior Poster
shadiadiph is offline Offline
106 posts
since Apr 2008
Message:
Previous Thread in PHP Forum Timeline: what's the encrypt type?
Next Thread in PHP Forum Timeline: limit hit counter php and reset the txt file generated by the counter





About Us | Contact Us | Advertise | Acceptable Use Policy
Build Custom RSS Feed


Follow us on Twitter


© 2010 DaniWeb® LLC