Can anyone help please?

The following code has been working fine for years. Server upgraded to php5 and now it shows the 'else' part of the statement (i.e. list of orders), but when an order ref is clicked, it just returns to the list, without processing the 'then' part of the statement (we have the same basic problem with two other php forms).

What's going on! Temporarily we had to go back to a different server and earlier version of php, but I would have thought that this simple code should have been compatible.

What do we need to change?

Code snipit follows

$db = mysql_connect(".com", "name","pword");
mysql_select_db("name",$db);
if ($id)
{ ?>
[display a form]
<?php
}
else
{
$sql="SELECT REF,SENT FROM DBNAME WHERE (FIELDNAME IS NOT NULL)";
$result=mysql_query($sql);
$rows = mysql_numrows($result);

       ?>

<p>Orders</p>
<table width="75%" border="1">
<?php
for ($counter = 0; $counter < $rows; $counter++) {

?>
<tr>
<td>
<?php

printf("<a href=\"?id=%s\">%s</a>",mysql_result($result,$counter,"ref"),mysql_result($result,$counter,"ref"));

?> </td>
</tr>
</table>
<?php
}
}
?>

    What is $id? If it is an incoming variable, then you should read up on the problems posed by register_globals, then change your code to use say $_POST['id'].

      Write a Reply...