Question

This may be a register_globals = on issue or url rewriting problem. I eliminated the url rewriting possibility by using basic php linking syntax. I tried several patches to emulate register_globals being on but to no avail. The site was functioning normally until last week when the php.ini file was updated. It is an Apache server with php 5.4.23. Basically I have a catalog page which displays a list of works called from a mysql database. When the user clicks the link, it brings the user to the appropriate item page. The catalog list displays correctly but the links do not function anymore and there is not error displayed. It always links to the first item of the mysql request and not the link that is requested even though the url that is displayed is correct. Here is the code to connect to the database:

<?php
$db = mysql_connect("localhost", "user", "pw"); 
mysql_select_db("database_name",$db); 
$sqlNum = 'SELECT * FROM callejas ORDER BY engname ';
$sql = 'SELECT * FROM callejas ORDER BY engname LIMIT '.(($page-1)).",".(1);
$resultNum = mysql_query($sqlNum);
$numRows = mysql_num_rows($resultNum);
$sqlnext = 'SELECT * FROM callejas ORDER BY engname LIMIT ' .(($page)).",".(1);
$sqlpre = 'SELECT * FROM callejas ORDER BY engname LIMIT ' .(($page-2)).",".(1);
//sommaire
$req = 'SELECT * FROM callejas ORDER BY engname  '; 
$result = mysql_query($req); 
$result1 = mysql_num_rows($result);
$milieu =  $result1 / 2;
$mil = (int)$milieu ;
$left = 'SELECT * FROM callejas ORDER BY `engname`  ASC LIMIT 0,'.($mil);
$right = 'SELECT * FROM callejas ORDER BY `engname`  ASC LIMIT '.($mil).",".($result1);
?>

Here is part of the catalog.php file which functions correctly except for the link

    <?
include ("connecttodatabase.php");
$i=1;
$j=0;
?>
<!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>
</head>
<body>
<div align="right" id="left" style="position:absolute; width:200px; height:388px; z-index:42; left: 6px; top: 170px;" class="interline30"> 
<?
$leftres = mysql_query($left);
function StandardizeString($img)
{
      $img = strtr($img,
             'ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ',
             'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy' );
      $img = preg_replace('/[\'"]/', '',$img); // Eliminate all quotes
      $img = preg_replace('/[^a-zA-Z0-9]+/', '-', $img); // Remove all spaces
      $img = trim($img, '_'); // Remove any leading or trailing underscored
      // Return the result
      return $img;
  }
while(($myrow = mysql_fetch_array($leftres)))
{
$img= $myrow['engleg'] ;
$little = "".$myrow['little'];
$tittle = StandardizeString($img); 
?>
<div align="center"
<?
echo  "id=\"$i\"";
?>
style="position:absolute; width:153px; z-index:49; left: 207px;top: 
<?
echo "$j px;"
?> 
visibility: hidden;"> 
<?
echo "<img src= \"{$little}\" title= \"{$img}\"  alt= \"{$img}\">";
?>
</div>
<?
echo "<p><a href='works.php?tittle=$tittle&page=$i' 
$img</a></p>";
$i++;
$j = $j+30;
}
?>
</div>
</body>

I have not been able to see what is wrong. This code has functioned for several years and after reading about the differences between php 5.3 and 5.4 I don't see any code that is deprecated but I do know that register_globals was on.

Was it helpful?

Solution

Hum...register_globals is DEPRECATED since PHP 5.3.0 and REMOVED in PHP 5.4"

Your problem lies certainly in this script : works.php

Please consider this quick and dirty fix : register_globals fix

OTHER TIPS

The below lines in your code not closed. You can fix it by closing it with semi colon.

<?
echo "$j px;";
?> 

also follow this SO answer to run your script like register global is enabled. https://stackoverflow.com/a/16706242/817365

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top