Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/07/2016, 16:48
sevillano665
 
Fecha de Ingreso: mayo-2014
Mensajes: 15
Antigüedad: 10 años
Puntos: 0
Require_once me produce "undefined variable"

Hola buenas, pues tengo un problemilla y es que no me reconoce la conexión a la base de datos en una determinada función y no sé por qué es. Ilustro para ver si alguien me puede dar una ayudita:

Esto es lo que tengo en "/Connections/conexionidiomas.php":

Código PHP:
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conexionidiomas "p:localhost:3307";
$database_conexionidiomas "idiomasbd";
$username_conexionidiomas "root";
$password_conexionidiomas "asdasdf";
$conexionidiomas mysqli_connect($hostname_conexionidiomas$username_conexionidiomas$password_conexionidiomas$database_conexionidiomas); 
y esto lo que tengo en "preguntas-frecuentes.php":

Código:
<?php require_once('Connections/conexionidiomas.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conexionidiomas, 
  								$theValue) : mysqli_escape_string($conexionidiomas,$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;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO tblfrecuentes (strPregunta,fchFecha) VALUES (%s,NOW())",GetSQLValueString($_POST['strPregunta'], "text"));

    $Result1 = mysqli_query($conexionidiomas,$insertSQL) or die(mysqli_error($conexionidiomas));
}
?>
Y estos son los problemas que me dan:

1) Notice: Undefined variable: conexionidiomas in C:\wamp64\www\idiomas\preguntas-frecuentes.php on line 10

2) Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\wamp64\www\idiomas\preguntas-frecuentes.php on line 11

Alguien que me ilumine?

Saludos!