Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2007, 03:00 PM
Registered User
 
Join Date: Aug 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default My redirect still don't working right

Hello everybody

Few days ago I ask why my page don't redirect to other one.

User sdi126 tell me that Header function's syntax was wrong.

That was true, but I found sometime interesting

This is my complete code, I create a file named Bases.php, this is a class to access a database, here is it


Bases.php

<?php
class Base{

      var $Host;
      var $Usuario;
      var $Clave;
      var $DB;
      var $Ors;
      var $Coneccion;

      function Base($Host,$Usuario,$Clave,$DB) {
               $this->Host = $Host;
               $this->Usuario = $Usuario;
               $this->Clave = $Clave;
               $this->DB = $DB;
      }

      function AbrirDB(){
          if (!($this->Coneccion=mysql_connect($this->Host, $this->Usuario, $this->Clave))){
              //echo ("<P> No se puede conectar a la BD <BR>");
              exit();
           }

           if (!mysql_select_db($this->DB)) {
              //echo ("<P>No se puede seleccionar la BD<BR>");
              exit();
           }
      }

     function &execute($sql){
               if(!($this->Ors = mysql_query($sql))){
                  // echo "No se puede ejecutar el sql <p>";
                   return FALSE;
               }
               return TRUE;
      }

      function &fetch(){
               return mysql_fetch_array($this->Ors);
      }

      function &row(){
          return mysql_num_rows($this->Ors);
      }

      function &CerrarDB(){
              if (mysql_close($this->Coneccion))
                  return TRUE;
          return FALSE;
      }
}
?>


And here is the page where I Include Bases.php


Incluir.php
<?php
  include ("./Include/Bases.php");
  require './Include/Configuracion.ini';

    extract($_GET);
    extract($_POST);
    //echo "<PRE> GET :";print_r($_GET);echo "POST :";print_r($_POST);echo "</PRE>";
    $base = new Base($Host,$Usuario,$Clave,$BD);
    $base->AbrirDB();
    if (isset($_POST["Accion"])){
        if($Accion=="Agregar"){
            $DirArchivo=$_FILES["TxtArchivo"]["name"];
            $Sql= "INSERT INTO TableroCorreos (Contacto,Email,Adjunto,Observaciones,Procesado) Values('$TxtContacto','$TxtCorreo','$DirArchivo',' TxtNota',0)";
            $base->execute($Sql);
            $Accion='';
        }
    }

    $base->CerrarDB();
    header('Location: 192.168.1.100/UtilitarioCorreos.php');
?>

And Here is the interesting:

This page don't redirect, but if I don't include the Bases.php file and I comment out the lines which use the functions in this file, my page redirect correctly.

I'm still looking for a explanation.


Someone would can Help me????
Since now Thank's


 
Old September 24th, 2007, 02:57 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post
Default

ludigova,
You need to add exit function after your header:

    $base->CerrarDB();
    header('Location: 192.168.1.100/UtilitarioCorreos.php');
    exit;
?>

Hope it works.
jmaronilla



 
Old September 29th, 2007, 04:37 PM
Registered User
 
Join Date: Aug 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello jmaronilla thanks for answer me

But it doesn't works


I think there is something wrong in my Bases.php file, but I can't find what could be


Thanks again

 
Old October 5th, 2007, 06:15 PM
Authorized User
 
Join Date: Sep 2007
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

You missing a curly brace {
on your last function

 function &CerrarDB(){
              if (mysql_close($this->Coneccion))
                  return TRUE;
          return FALSE;
      }


should be

 function &CerrarDB(){
              if (mysql_close($this->Coneccion)){
                  return TRUE;
          return FALSE;
      }



http://mynameissteve.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
window.opener working .... not working alyeng2000 Javascript How-To 5 January 5th, 2007 08:05 AM
Web.Config..Working or Not Working peace95 ASP.NET 1.0 and 1.1 Basics 1 September 18th, 2006 06:53 AM
header redirect not working guillermo Beginning PHP 2 June 23rd, 2006 05:33 AM
Local COM working , but not working at Web Serv nagen111 .NET Web Services 3 February 19th, 2005 04:22 AM
Get Working Copy... not working Enkiel Classic ASP Basics 0 April 21st, 2004 01:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.