changing old script - register globals - how to convert?

From: kevin bailey (kbailey_at_freewayprojects.com)
Date: 01/31/05


Date: Mon, 31 Jan 2005 00:48:36 +0000

this old script was written when

register globals was 'on'.

now i need to convert it to run on a server with a php 4.3.6 - do i just
convert the relevant variables from

$posted_variable to $_POST['posted_variable']

i realise that many of the variables are internal to the scrit so will not
be altered.

i'm slightly concerned because some of the script refers to variables which
are used as streams and used to upload image files.

thanks for any pointers,

kev

here are the scripts from
http://www.onlamp.com/pub/a/onlamp/2002/05/09/webdb2.html?page=1

<!DOCTYPE HTML PUBLIC
  "-//W3C//DTD HTML 4.0 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <title>Browse Upload Files</title>
</head>
<body bgcolor="white">

<?php
  include 'db.inc';
  
  $query = "SELECT id, shortName, mimeName FROM files";

  if (!($connection = @ mysql_pconnect($hostName,
                                    $username,
                                    $password)))
     showerror();

  if (!mysql_select_db("files", $connection))
     showerror();
        
  if (!($result = @ mysql_query ($query, $connection)))
     showerror();
?>
    <h1>Image database</h1>

    <h3>Click here to
upload an image.</h3>
<?php
  require 'disclaimer';

  if ($row = @ mysql_fetch_array($result))
  {
?>

    <table>
    <col span="1" align="right">
    <tr>
       <th>Short description</th>
       <th>File type</th>
       <th>Image</th>

    </tr>
<?php
   do
   {
?>
    <tr>
       <td><?php echo "{$row["shortName"]}";?></td>
       <td><?php echo "{$row["mimeName"]}";?></td>
       <td><?php echo "<img src=\"view.php?file={$row["id"]}\">";?></td>
    </tr>
<?php
   } while ($row = @ mysql_fetch_array($result));
?>
    </table>
<?php
  } // if mysql_fetch_array()
  else
     echo "<h3>There are no images to display</h3>\n";
?>
</body>
</html>



Relevant Pages

  • mysqli error?
    ... I'm just setting up my php enviroment and I typed in a simple script ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • Re: How do we get there from here?
    ... >> executing on the server as a pre-processor. ... If there are client side versions of PHP, ... > name implies a static text file, is it different from a PHP script? ...
    (comp.databases.pick)
  • Re: Apache: limiting the execution place
    ... They want it so users can't use FTP, shell, or a CGI or PHP script to view, ... other users via shell, FTP, web server processes (such as PHP or CGI ...
    (Security-Basics)
  • Re: PHP chmod Newbie Question
    ... How does the server keep ... how do I create user groups for chmod to recognize? ... CHMOD is for UNIX based servers, and the PHP chmod() ... edited or removed by the PHP script, and only read by the UNIX ...
    (comp.lang.php)
  • Re: PHP in html
    ... additional calls to the server, ... to invoke a script handler for every single image. ... configuration of the webserver and the PHP interpreter. ... If you think interpreting all pages as PHP ...
    (comp.lang.php)