Please help. Is this php script wrong?

From: John Wrate (lolo8000_at_hotmail.com)
Date: 03/09/04


Date: 9 Mar 2004 14:52:45 -0800

Hi all,

I have a customer who wants his site to reside in one of my hosts. The
host I have assigned for him is a Windows NT server with the latest
binary PHP and MySQL servers.

The people that made the site are a**holes and want to host the site
themselves and are resorting to all sorts of lies about our server not
working porperly.

They sent this script. I don't know any PHP but I feel something is
not right with the script. And I get an error:

Notice: Undefined variable: ok in C:\.....\test.php on line 3

This is the test.php script:

$bdConexion=mysql_pconnect("localhost","xxxx","11122"); // usr & pswd
mysql_select_db("datos_prueba",$bdConexion);
if(!$ok){
 $sql="CREATE TABLE Empleados (ID INT PRIMARY KEY,Nombre VARCHAR (50)
, Apellidos VARCHAR (70), Edad INT(4))";
 if(!($reg=mysql_query($sql,$bdConexion)))
   echo "ERROR CREATING TABLE.";
 else
 {
?>
<form name="forma1" ENCTYPE="multipart/form-data" method="post"
action="">
Nombre:<input type="text" name="name"><br>
Apellido:<input type="text" name="last"><br>
Edad:<input type="text" name="year"><br>
Selecciona una Imagen:<input name="imagen" type="file">
<br>
<br><input type="submit" name="ok" value="Enviar"><br>
</form>
<?}
}else if($ok){
  $sql2="INSERT INTO Empleados(ID,Nombre,Apellidos,Edad) VALUES
(".'1'.",'".$name."','".$last."',".$year.")";
  if(!($reg2=mysql_query($sql2,$bdConexion)))
    echo "ERROR AL INSERTAR EN LA TABLA.".$sql2;
  $sql3="UPDATE Empleados SET Nombre='Perlita' WHERE ID=1";
  if(!($reg3=mysql_query($sql3,$bdConexion)))
     echo "ERROR AL ACTUALIZAR LA TABLA";
  $sql4="SELECT * FROM Empleados";
  if(!($reg4=mysql_query($sql4,$bdConexion)))
    echo "ERROR AL SELECCIONAR DE LA TABLA";
  ELSE{
   echo "<BR>TUS DATOS FUERON:<BR><BR>";
   IF($regis=mysql_fetch_array($reg4))
   {
      echo "Nombre:".$regis[Nombre]."<br>";
          echo "Apellido:".$regis[Apellidos]."<br>";
          echo "Edad:".$regis[Edad]."<br>";
   }
    }
  echo "Imagen=".$imagen_name;
  echo "<br>";
  $pathSeccion="../media/";
  $pathfin=$pathSeccion."1";
  echo "<BR>== GRABANDO UNA IMAGEN ==<BR>";
   if(!file_exists($pathfin))
                 {
           mkdir($pathfin,0777);
                   if($imagen!=""){
                   
            copy($imagen,$pathfin."/".$imagen_name);
                        }
                 }
  ECHO "<BR>LEYENDO LA IMAGEN<BR><br>";
           if(file_exists($pathfin))
           {
                 $dir = opendir($pathfin);
                 while($arch = readdir($dir)){
                 if($arch != '.' && $arch != '..')
                    echo "Imagen: <img src=\"".$pathfin."/".$arch."\"><br>";
                 }
                 closedir($dir);
                }
    echo "<BR><h1>==TEST OK ==</h1><BR>";
  }//ok

In the first "If" it is very strange to me to see that if the
mysql_select_db falied if(!$ok), then a table is being created! How is
that possible, and should't ok be assigned the value of the
my_select_db(xxxx,xxx) in order to test it later. Like I said, I get
the error and although the table is created the first time the
test.php script is opened/run, the data is not inserted in the second
run (after filling the form).

Any comments will be very much appreciated.

Wrate



Relevant Pages

  • Re: internet proxy
    ... Is it possible to create separate shortcuts to IE - one with 'proxy server ... This script gets used when you enable the "Automatically ... connect to the host so no proxy would get used. ...
    (microsoft.public.windowsxp.general)
  • Re: How do I insert a cgi script into Publisher page?
    ... is not where I host my website. ... If your ISP supports cgi and has a form handling program then a form ... You must tell the server what e mail address you want the form results ... any where else you so desire or an auto redirect script with a delay. ...
    (microsoft.public.publisher.webdesign)
  • Could this possibly be right?
    ... The people that made the site are a**holes and want to host the site ... themselves and are resorting to all sorts of lies about our server not ... They sent this script. ... , Apellidos VARCHAR, Edad INT)"; ...
    (alt.php)
  • Re: How do I insert a cgi script into Publisher page?
    ... If your ISP supports cgi and has a form handling program then a form created ... You must tell the server what e mail address you want the form results sent ... any where else you so desire or an auto redirect script with a delay. ... link to your host and specifically where on the host website it gives you ...
    (microsoft.public.publisher.webdesign)
  • Re: How do I insert a cgi script into Publisher page?
    ... If your ISP supports cgi and has a form handling program then a form created in publisher will function using FTP upload rather than front page server extensions to upload the pages. ... The thank you page may have a link back to the page where you came from or any where else you so desire or an auto redirect script with a delay. ... Also provide us a link to your host and specifically where on the host website it gives you the instructions for using the forms program in the cgi folder. ...
    (microsoft.public.publisher.webdesign)