Foros del Web » Programando para Internet » PHP »

[PHP] Problema Script

Estas en el tema de [PHP] Problema Script en el foro de PHP en Foros del Web. Tengo el siguiente script de php para incluir la conexion y al momento de conectar me sale en blanco la pagina cargando solo el titulo ...
  #1 (permalink)  
Antiguo 06/02/2013, 12:11
 
Fecha de Ingreso: junio-2012
Mensajes: 77
Antigüedad: 11 años, 10 meses
Puntos: 5
[PHP] Problema Script

Tengo el siguiente script de php para incluir la conexion y al momento de conectar me sale en blanco la pagina cargando solo el titulo en algunos casos y si quito la funcion money_format todo me anda bien alguno tiene idea de lo que puede estar pasando....

gracias

Código PHP:
<?php

$HOSTNAME
="localhost";
$USERNAME="root";
$PASSWORD="";
$DATABASE="sales";
//Funcion para conectar
function conectar(){
    global 
$HOSTNAME,$USERNAME,$PASSWORD,$DATABASE;
    @ 
$idcnx=mysql_connect($HOSTNAME,$USERNAME,$PASSWORD);
    if (!
$idcnx)
    {
        echo 
"Error: No hay conexión con la base de datos.  Por favor intente más tarde.";
        exit;
    }
    
mysql_select_db($DATABASE,$idcnx);
    return 
$idcnx;
    
mysql_close($idcnx);    //cierro conexion
}
/*
That it is an implementation of the function money_format for the
platforms that do not it bear.

The function accepts to same string of format accepts for the
original function of the PHP.

(Sorry. my writing in English is very bad)

The function is tested using PHP 5.1.4 in Windows XP
and Apache WebServer.
*/

function redondeo($numero) {
    
$redondeo=round($numero 100) / 100;
    return 
$redondeo;
}

function 
seguridad($codigo)
{
    switch (
$codigo) {
        case 
1://No Autenticado
            
echo '
                    <html xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                    <title>No Autenticado</title>
                    <meta http-equiv="REFRESH" content="5; url=index.php">

                    </head>
                    <body>
                    <div align=center>
                    <?php @include "includes/logo.php";?>

                    <h1>Usted No esta Autenticado</h1><br />
                    <p>La Pagina a La Que Intenta Ingresar requiere Autenticacion.</p>
                    <p>En 5 Segundos Sera Dirigido a La pagina Principal.</p>
                    <p>Si Su Navegador No Lo Realiza Por Favor Haga Click <a href="index.php">Aqui</a></p>
                    </div>
                    </body>
                    </html>
            '
;
            break;
        case 
2://autenticado pero no permitido
            
echo '
                    <html xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                    <title>No Autorizado</title>
                    <meta http-equiv="REFRESH" content="5; url=index.php">

                    </head>
                    <body>
                    <div align=center>
                    <?php @include "includes/logo.php";?>

                    <h1>Usted No Esta Autorizado</h1><br />
                    <p>La Pagina a La Que Intenta Ingresar usted no se encuentra Autorizado.</p>
                    <p>En 5 Segundos Sera Dirigido a La pagina Principal.</p>
                    <p>Si Su Navegador No Lo Realiza Por Favor Haga Click <a href="index.php">Aqui</a></p>
                    </div>
                    </body>
                    </html>
            '
;
            break;

    }
}

function 
errorVendedor($error) {
    
$refresh='<meta http-equiv="REFRESH" content="5; url=home_vendedor.php">';

    switch (
$error) {
        case 
1:
            
$message="Usted No Posee Clientes Asignados<p>";
            
$message1="Por Favor Contacte Al Administrador</p>";
            
$error='<center><h1>'.$message.' '.$message1.'</h1></center>'.$refresh;
            echo 
$error;
            break;
        case 
2:
            
$message="No Hay Colecciones Activas";
            
$message1="Por Favor Contacte Al Administrador</p>";
            
$error='<center><h1>'.$message.' '.$message1.'</h1></center>'.$refresh;
            echo 
$error;
            break;
        case 
3:
            
$message="El Numero De Pedido Que Intenta Consultar No Existe<p>";
            
$message1="Por Favor Contacte Al Administrador</p>";
            
$error='<center><h1>'.$message.' '.$message1.'</h1></center>'.$refresh;
            echo 
$error;
            break;
        case 
4:
            
$message="Usted No Posee Pedidos Realizados<p>";
            
$message1="Por Favor Contacte Al Administrador</p>";
            
$error='<center><h1>'.$message.' '.$message1.'</h1></center>'.$refresh;
            echo 
$error;
            break;
    }
}
?>

ejemplo del index

Código PHP:
<?php session_start();?>
<?php
//Variables de Control Pedido
unset($_SESSION['idPedido']);
unset(
$_SESSION['paginaCatalogo']);
unset(
$_SESSION['fechaPedido']);
unset(
$_SESSION['paginaMaxima']);
// start session*/
@require_once './includes/cnx.php';
conectar();
//echo "<pre>". print_r($_POST, true) . "</pre>";
// set session variable that identifies valid user to 0 until user submits
// valid username and passwordusername
// a variable that will hold error message if needed
$msg '';

// check wheter user has submitted a username and/or password
if(isset($_POST['idVendedor']) or isset($_POST['clave'])) {

    
// if both username and password are submitted and not empty
    
if(isset($_POST['idVendedor']) and !empty($_POST['idVendedor']) and
    isset(
$_POST['clave']) and !empty($_POST['clave'])) {


        
$idVendedor trim($_POST['idVendedor']);
        
$clave trim($_POST['clave']);

        
$idVendedor=mysql_escape_string(addcslashes($idVendedor,"',/"));
        
$clave=mysql_escape_string(addcslashes($clave,"',/"));

        
//SHA1+MD5+SALT
        
$hpassword sha1(md5($clave.$idVendedor));
        
$query "SELECT * FROM ped_vendedor ";
        
$query .= "WHERE idvendedor='$idVendedor' AND password='$hpassword'";
        
//echo $query;
        
$result mysql_query($query);
        
$numero mysql_num_rows($result);
        
$row mysql_fetch_array($result);

        
$idVendedor $row['idvendedor'];
        
$tipo $row['tipo'];
        
//        $estado=$row['estado'];

        
if ($numero >) {

            
$_SESSION['vendedor']=$idVendedor;
            
$_SESSION['tipo']=$tipo;
            
//            $_SESSION['estado']=$estado;

            
if($_SESSION['tipo']==1)
            {
                
header("location:home_vendedor.php");
                
// redirecciona al usuario al formulario
            
}
            if (
$_SESSION['tipo']==2) {
                
header("location:home_admin.php");
            }
            
//just in case anything goes wrong from here end the script
            
die();
        }
        else {
            
$_SESSION['vendedor'] = 0;
            
$msg 'Por Favor Ingrese los datos correctamente';
        }
    }
    
// if only username or only password was submitted
    
else {

        
// again set session variable that identifies valid user to 0
        
$_SESSION['vendedor']=0;

        
// prepare error message
        
$msg 'Por Favor Ingrese los datos correctamente';
    }
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Iniciar Sesion</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="./css/menu_style.css" type="text/css" />
</head>

<body>
<?php @include 'includes/logo.php';?>
<center><?php
if(!isset($_SESSION['vendedor'])|| !isset($_SESSION['tipo']))
{
    echo 
'
<form action="" method="post">
<p>Por Favor Autentiquese</p>

<table border="0">
    <tr>
        <td>Vendedor</td>
        <td><input type="text" name="idVendedor" maxlength="30" size="30" autocomplete="OFF" placeholder="Vendedor" /></td>
    </tr>
    <tr>
        <td>Clave</td>
        <td><input type="password" name="clave" maxlength="30" size="30" autocomplete="OFF" placeholder="Clave"  pattern="\d*"/></td>
    </tr>
    <tr>
        <td colspan="2"><input type="submit" name="submit" value="Ingresar" /></td>
    </tr>
</table>
<div class="error-message">'
;
    echo 
$msg;
    echo
'</div></form>';
}
else if(isset(
$_SESSION['vendedor'])||isset($_SESSION['tipo']))
{
    switch (
$_SESSION['tipo']){
        case 
1:
            echo 
"<br/>";
            echo 
"Usted Ya Se Encuentra Identificado Por Favor Haga Click <a href=home_vendedor.php>Aqui</a>";
            break;

        case 
2:
            echo 
"<br/>";
            echo 
"Usted Ya Se Encuentra Identificado Por Favor Haga Click <a href=home_admin.php>Aqui</a>";
            break;
    }

}
?></center>

</body>
</html>
  #2 (permalink)  
Antiguo 06/02/2013, 13:12
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: [PHP] Problema Script

No veo la función money_format(), pero por los comentarios que tienes en el código deberías tener algo como:

Código PHP:
Ver original
  1. if(!function_exists('money_format')) {
  2.     function money_format(/* parámetros */) {
  3.         // Aquí el código de la función
  4.     }
  5. }

Si esa función existe y la declaras sin el if, entonces PHP dará un error y, si no tienes activo el reporte de errores, entonces sólo verás la página en blanco.

Es posible ver el error si abres el registro de errores (AKA error_log), la ubicación varía de acuerdo al hosting.

Edito para agregar:

money_format() está disponible desde PHP 4.3, por lo que no deberías tener que declararla nuevamente, ni con el if.
http://php.net/manual/es/function.money-format.php
__________________
- León, Guanajuato
- GV-Foto

Etiquetas: blanco, funcion, screen
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:16.