Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/11/2011, 20:54
jenju302
 
Fecha de Ingreso: julio-2009
Ubicación: colombia
Mensajes: 7
Antigüedad: 14 años, 9 meses
Puntos: 0
problema al conectar la base de datos.

Buenas noches soy nueva en esto, estoy trabajando en un proyecto echo con la ayuda de dreamweaver, me funciona bien en el servidor local de xampp, pero cuando le hago las pruebas en el servidor de miarroba, me carga los formularios, pero cuando le doy enviar, ninguno me funciona, no me conecta la base de datos y me sale este error...

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/webcindario/p/e/petweb/registrar_usuario.php on line 79

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/webcindario/p/e/petweb/registrar_usuario.php on line 80

El codigo de la linea 79 y 80 es este..

mysql_select_db($database_registro_usuarios, $registro_usuarios);
$LoginRS=mysql_query($LoginRS__query, $registro_usuarios) or die(mysql_error());


y el codigo completo cabe aclarar que lo cree con la ayuda de dreamwaver, por el tiempo que dispongo... MUCHAS GRACIAS A TODOS LOS QUE ME PUEDAN AYUDAR...


<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conexion_petweb = "mysql.webcindario.com";
$database_conexion_petweb = "petweb";
$username_conexion_petweb = "******";
$password_conexion_petweb = "******";
$conexion_petweb = mysql_pconnect($hostname_conexion_petweb, $username_conexion_petweb, $password_conexion_petweb) or trigger_error(mysql_error(),E_USER_ERROR);
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

// *** Comprobar si nombre de usuario existe
$error = array();
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
// comprobar nombre
if (empty($_POST['nombre']) || empty($_POST['apellidos'])) {
$error['nombre'] = 'Por favor escribe tanto el nombre como los apellidos';
}
// configura un indicador que asume que la contraseña es correcta
$contbien = true;
// eliminar espacios en blanco
$_POST['contrase'] = trim($_POST['contrase']);
// si menos de 6 caracteres, creamos una alerta y configuramos indicador como false
if (strlen($_POST['contrase']) < 6) {
$error['contrase_tam'] = 'Tu contraseña debe tener al menos 6 caracteres';
$contbien = false;
}
// si no concuerda, crea una alerta y configura indicador a false
if ($_POST['contrase'] != trim($_POST['conf_cont'])) {
$error['contrase'] = 'Tu contraseña y la confirmacion no coiciden';
$contbien = false;
}
// si la contraseña es correcta, la encriptamos
if ($contbien) {
$_POST['contrase'] = sha1($_POST['contrase']);
}
// expresión regular para identificar caracteres ilegales en la dirección email
$comprobarEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
if (!preg_match($comprobarEmail, trim($_POST['email']))) {
$error['email'] = 'Por favor escribe una dirección email válida';
}
// comprobar nombre usuario
$_POST['nombreusuario'] = trim($_POST['nombreusuario']);
$loginUsername = $_POST['nombreusuario'];
if (strlen($loginUsername) < 6) {
$error['tama'] = 'Por favor selecciona un nombre de usuario que tenga al menos 6 caracteres';
}
$LoginRS__query = sprintf("SELECT nombreusuario FROM usuarios WHERE nombreusuario=%s", GetSQLValueString($loginUsername, "text"));
mysql_select_db($database_registro_usuarios, $registro_usuarios);
$LoginRS=mysql_query($LoginRS__query, $registro_usuarios) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

//Si el nombre de usuario ya se encuentra en la base de datos - no se puede añadir el nombre de usuario solicitado
if($loginFoundUser){
$error['nombreusuario'] = "$loginUsername ya está en uso. Por favor elige un nombre de usuario diferente.";

}
}

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

if (!$error) {
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO usuarios (nombre, apellidos, email, nombreusuario, contrase, admin_priv) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['apellidos'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['nombreusuario'], "text"),
GetSQLValueString($_POST['contrase'], "text"),
GetSQLValueString($_POST['admin_priv'], "text"));
echo "SE A GUARDADO EL NUEVO REGISTRO";

mysql_select_db($database_registro_usuarios, $registro_usuarios);
$Result1 = mysql_query($insertSQL, $registro_usuarios) or die(mysql_error());

}

// si el registro ha sido insertado, limpiar el array $_POST
$_POST = array();
}
?>
<!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>Registro Usuarios</title>
</head>

<body>
<h1>Registro Usuarios </h1>
<p>&nbsp;</p>
<?php
if ($error) {
echo '<ul>';
foreach ($error as $alerta) {
echo "<li class='warning'>$alerta</li>\n";
}
echo '</ul>';
// remove escape characters from POST array
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);

}
}
?>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nombre:</td>
<td><input value="<?php if (isset($_POST['nombre'])) {
echo htmlentities($_POST['nombre']);} ?>" name="nombre" type="text" id="nombre" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Apellidos:</td>
<td><input value="<?php if (isset($_POST['apellidos'])) {
echo htmlentities($_POST['apellidos']);} ?>" type="text" name="apellidos" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input value="<?php if (isset($_POST['email'])) {
echo htmlentities($_POST['email']);} ?>" type="text" name="email" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nombre Usuario:</td>
<td><input value="<?php if (isset($_POST['nombreusuario'])) {
echo htmlentities($_POST['nombreusuario']);} ?>" type="text" name="nombreusuario" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Contrase&ntilde;a:</td>
<td><input type="password" name="contrase" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Conf. Contrase&ntilde;a</td>
<td valign="baseline"><input name="conf_cont" type="password" id="conf_cont" size="32" /></td>
</tr>
<tr valign="baseline">
<td align="right" valign="middle" nowrap="nowrap">Admin_priv:</td>
<td valign="baseline"><table>
<tr>
<td><input <?php if ($_POST && !(strcmp($_POST['admin_priv'],"s"))) {echo "checked=\"checked\"";} ?> type="radio" name="admin_priv" value="s"/>
S&iacute;</td>
</tr>
<tr>
<td><input <?php if (($_POST &&!(strcmp($_POST['admin_priv'],"n")))||!$_POST) {echo "checked=\"checked\"";} ?> type="radio" name="admin_priv" value="n" />
No</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insertar registro" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>

Última edición por jenju302; 14/11/2011 a las 21:02