Skip to main content
Participant
July 18, 2018
Question

Problema con página web hecha con Dreamweaver

  • July 18, 2018
  • 0 replies
  • 295 views

Hola:

He hecho una página con Dreamweaver que tiene una zona de acceso privado para que el administrador del sitio pueda añadir contenidos que se ven en la parte pública. La pruebo en local y todo funciona bien. He trabajado usando las paletas de Bases de Datos, Vinculaciones y Comportamientos del Servidor cambiando todo después para MySQLi (comprobando que funciona bien en mi servidor local MAMP). También actualicé los datos de las conexiones con la bbdd remota (se conecta bien) y subí los archivos correspondientes a mi hosting. La cuestión es que me encuentro con un problema. Mi archivo de acceso se llama: MCC_aeb.php. Cuando se accede a la url en la que está MCC_aeb.php, aparecen estos 2 mensajes de error que hacen referencia a mi servidor local:

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /homepages/27/d741383808/htdocs/admin/MCC_aeb.php on line 64

Warning: mysqli_error() expects parameter 1 to be mysqli, null given in /homepages/27/d741383808/htdocs/admin/MCC_aeb.php on line 64

¡Pero los archivos están en el servidor remoto!

Pego a continuación el código de conexión a la bbdd:

<?php

$host_name_remota = 'mihostname';

$database_remota = 'mibbdd';

$user_name_remota = 'miusuario';

$password_remota = 'mipassword';

$connect = mysqli_connect($host_name_remota, $user_name_remota, $password_remota, $database_remota);

if (mysqli_connect_errno()) {

die('<p>Error al conectar con servidor MySQL: '.mysqli_connect_error().'</p>');

} else {

echo '<p>Se ha establecido la conexión al servidor MySQL con éxito.</p >';

}

?>

Ahora copio el código del archivo en el que está el formulario de acceso:

[code]<?php

error_reporting(E_ALL);

ini_set('display_errors', '1');

?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  }

 

  if (PHP_VERSION >= 7) { // SI la versión de PHP es mayor o igual a 7.

global $remota;        // Hago global la variable

  }

// global $remota;

//$theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($remota, $theValue) : mysqli_escape_string($remota,$theValue);

  switch ($theType) {

case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

case "long":

case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

case "double":

      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

      break;

case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}

?>

<?php

// *** Validate request to login to this site.

if (!isset($_SESSION)) {

session_start();

}

$loginFormAction = $_SERVER['PHP_SELF'];

if (isset($_GET['accesscheck'])) {

$_SESSION['PrevUrl'] = $_GET['accesscheck'];

}

if (isset($_POST['mail'])) {

$loginUsername=$_POST['mail'];

$password=$_POST['csign'];

$MM_fldUserAuthorization = "";

$MM_redirectLoginSuccess = "edicion.php";

$MM_redirectLoginFailed = "MCC_error.php";

$MM_redirecttoReferrer = false;

 

 

  $LoginRS__query=sprintf("SELECT u_email, u_password FROM usuarios WHERE u_email=%s AND u_password=%s",

GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

  

  $LoginRS = mysqli_query($remota, $LoginRS__query) or die(mysqli_error($remota));

$loginFoundUser = mysqli_num_rows($LoginRS);

  if ($loginFoundUser) {

$loginStrGroup = "";

   

            if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}

//declare two session variables and assign them

$_SESSION['MM_Username'] = $loginUsername;

$_SESSION['MM_UserGroup'] = $loginStrGroup;                 

    if (isset($_SESSION['PrevUrl']) && false) {

      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];           

    }

header("Location: " . $MM_redirectLoginSuccess );

  }

  else {

header("Location: ". $MM_redirectLoginFailed );

  }

}

?>

<?php require_once('../Connections/remota.php'); ?>

<!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=UTF-8" />

<title>MCC_aeb</title>

<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />

<style type="text/css">

@1552174 url("../estilos/MCC_desktop_02.css")screen and (min-width:1024px);

@1552174 url("../estilos/MCC_tablet_02.css")screen and (min-width:768px) and (max-width:1023px);

@1552174 url("../estilos/MCC_movil_02.css")screen and

(max-width:767px);

.centrado-porcentual {

position: absolute;

left: 50%;

top: 50%;

            width:400px;

            height:auto;

transform: translate(-50%, -50%);

-webkit-transform: translate(-50%, -50%);

}

.centrado-porcentual img{

            padding-left:25px;

            padding-bottom:50px;

}

table{

            margin-top: 50px 0;

            widith:400px;           

}

td{

            padding:20px 10px;

}

input{

            font-size:1.1em;

}

.espaciar_btn{

            margin: 0 20px;

}

</style>

</head>

<body>

            <div class="centrado-porcentual">

            <img src="../imgs/Logo_MCC_RGB.jpg" alt="Logo" style="margin:0 auto ;" />

                        <div style="padding:20px; margin-top:30px auto; border:#9CB65F dotted 1px; text-align:center;">

                        <form id="Acceso" name="Acceso" method="POST" action="<?php echo $loginFormAction; ?>">

                       

                        <table width="400" border="0" cellspacing="0" cellpadding="6">

            <tr>

                        <td width="133" align="right" valign="top">Correo electrónico</td>

                        <td width="243" align="left" valign="top">

                                    <label for="mail"></label>

                                    <input name="mail" type="text" id="mail" size="20" />

                        </td>

            </tr>

            <tr>

                        <td align="right" valign="top">Contraseña</td>

                        <td align="left" valign="top">

                                    <label for="csign"></label>

                                    <input name="csign" type="password" id="csign" size="15" />

                        </td>

            </tr>

            <tr>

                        <td colspan="2" align="center" valign="top">

                        <input name="Acceder" type="submit" value="Acceder" class="espaciar_btn" /> <input name="Restablecer" type="reset" value="Restablecer" class="espaciar_btn"/>

                        </td>

                        </tr>

</table>

</form>

                        </div>

</div>

</body>

</html>[/code]

    This topic has been closed for replies.