954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Code no longer works after php was upgraded to latest version

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:

Select news to Update:
 


<?php
do
{
?>
<?php echo $row_NewsUpdate['news_date']?>
<?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);
}
?>


 
 

 
 
 

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:

mugojoe
Newbie Poster
2 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Try to use directly the echo statement with your javascript code

<?php echo $seq_id;?>
rajarajan07
Nearly a Posting Virtuoso
1,447 posts since May 2008
Reputation Points: 167
Solved Threads: 239
 

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

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 
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.

farhan386
Light Poster
44 posts since Jul 2008
Reputation Points: 10
Solved Threads: 7
 

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!

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

mugojoe
Newbie Poster
2 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

If anyone thought there was anything other than newness as the source,
ya wouldn' believe how **expletive deleted** some of the replies would be,

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

maybe this

<?php
do
{
?>
shadiadiph
Junior Poster
119 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You