Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/08/2008, 06:13
n3ron
 
Fecha de Ingreso: agosto-2008
Mensajes: 6
Antigüedad: 15 años, 8 meses
Puntos: 0
Error mysql_num_rows.

En primero lugar dar las gracias por adelantado.

He mirado temas parecidos por el foro pero no consigo que funcione asi que he decidido publicar el código a ver si alguien me puede echar una mano.

Al enviar el formulario me sale el siguiente error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxx/registro.php on line 60

El código es el siguiente

Código PHP:
if($_POST[registrar]) {
if(empty($_POST[nick]) || empty($_POST[Password]) || empty($_POST[email])) {
?> 
<table width="467" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="42" valign="top" background="imagenes/tabla1.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="16" colspan="2"></td>
        </tr>
        <tr> 
          <td width="6%">&nbsp;</td>
          <td width="94%"><font color="#FFCC00"><strong>Registro de nuevo usuario</strong></font></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td background="imagenes/tabla2.gif"><table width="440" border="0" align="center" cellpadding="4" cellspacing="2">
        <tr> 
          <td><p align="center"><font face="Tahoma" style="font-size: 8pt" color="#FFFFFF"> 
              <strong><font color="#EEEEEE">Lo sentimos pero su registro no se 
              ha completado porque hay campos obligatorios sin completar. Por 
              favor, rell&eacute;nalos</font></strong></font></p></td>
        </tr>
        <tr> </tr>
      </table></td>
  </tr>
  <tr> 
    <td><img src="imagenes/tabla3.gif" width="467" height="21"></td>
  </tr>
</table>
<?
}
else {



if (!
ini_get('register_globals')) {
    
$superglobales = array($_SERVER$_ENV$_FILES$_COOKIE$_POST$_GET);
    if (isset(
$_SESSION)) {
        
array_unshift($superglobales$_SESSION);
    }
    foreach (
$superglobales as $superglobal) {
        
extract($superglobalEXTR_SKIP);
    }
}



$db_host="x";
$db_user="x";
$db_pass="x";
$db_name="x";


$admin_email="xxx";


$comprobar mysql_query("select * from usuarios where nick='$_POST[nick]' or email='$_POST[email]'");
if(
mysql_num_rows($comprobar) != 0) {
?>
<table width="467" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="42" valign="top" background="imagenes/tabla1.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="16" colspan="2"></td>
        </tr>
        <tr> 
          <td width="6%">&nbsp;</td>
          <td width="94%"><font color="#FFCC00"><strong>Registro de nuevo usuario</strong></font></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td background="imagenes/tabla2.gif"><table width="440" border="0" align="center" cellpadding="4" cellspacing="2">
        <tr> 
          <td><p align="center"><font face="Tahoma" style="font-size: 8pt" color="#FFFFFF"> 
              <strong><font color="#EEEEEE">Lo sentimos pero hay otro usuario 
              registrado con su mismo nick o email. Introduzca una cuenta diferente</font></strong></font></p></td>
        </tr>
        <tr> </tr>
      </table></td>
  </tr>
  <tr> 
    <td><img src="imagenes/tabla3.gif" width="467" height="21"></td>
  </tr>
</table>
<?

$fecha 
date("M d, Y"); $Password md5($_POST[Password]);


if (!
ini_get('register_globals')) {
    
$superglobales = array($_SERVER$_ENV$_FILES$_COOKIE$_POST$_GET);
    if (isset(
$_SESSION)) {
        
array_unshift($superglobales$_SESSION);
    }
    foreach (
$superglobales as $superglobal) {
        
extract($superglobalEXTR_SKIP);
    }
}



$db_host="localhost";
$db_user="xxx";
$db_pass="xxx";
$db_name="xxx";


$admin_email="xxxx";




include(
"foro/config.php");
$idddd mysql_query("SELECT MAX(user_id) AS total FROM phpbb_users");
$row mysql_fetch_array($idddd);
$user_id $row[total] + 1;
$reg_date time();


mysql_query("INSERT INTO phpbb_users (user_id, username, user_regdate, user_password, user_email, user_active) values ('$user_id','$_POST[nick]','$reg_date','$Password','$_POST[email]','1')");
mysql_query("insert into usuarios (nick,contrasena,email,fecha,sexo,web,avatar) values ('$_POST[nick]','$Password','$_POST[email]','$fecha','$_POST[sexo]')");
?>
<table width="467" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="42" valign="top" background="imagenes/tabla1.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="16" colspan="2"></td>
        </tr>
        <tr> 
          <td width="6%">&nbsp;</td>
          <td width="94%"><font color="#FFCC00"><strong>Registro de nuevo usuario</strong></font></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td background="imagenes/tabla2.gif"><table width="440" border="0" align="center" cellpadding="4" cellspacing="2">
        <tr> 
          <td><p align="center"><font face="Tahoma" style="font-size: 8pt" color="#FFFFFF"> 
              <strong><font color="#EEEEEE">El usuario <? echo $_POST[nick?> 
              ha sido registrado correctamente en la web. Haz click aqu&iacute; 
              para iniciar sesi&oacute;n en la web y acceder a los contenidos</font></strong></font></p></td>
        </tr>
        <tr> </tr>
      </table></td>
  </tr>
  <tr> 
    <td><img src="imagenes/tabla3.gif" width="467" height="21"></td>
  </tr>
</table>
<?
}
}
//
}else {
?><SCRIPT type="text/javascript">
<!--
function showimage() {
if (!document.images)
return
document.images.avatar.src=
'imagenes/avatares/' + document.formulario.avatar.options[document.formulario.avatar.selectedIndex].value
}
//-->
</SCRIPT>
<?
el error me lo tira en la linea 60 que corresponde con:

Código PHP:
$comprobar mysql_query("select * from usuarios where nick='$_POST[nick]' or email='$_POST[email]'");
if(
mysql_num_rows($comprobar) != 0) { 
A ver si alguien me puede echar un cable.

Mil gracias.