<?php

 $login = $_POST['login'];
 $nickname = $_POST['nickname'];
 $senha = $_POST['senha'];
 $email = $_POST['email'];



 $conexao = mysql_pconnect("localhost","rodrigue_incub","xxx24df") or die (mysql_error());
 $banco = mysql_select_db("rodrigue_incubadora");

 //Utilizando o  mysql_real_escape_string voce se protege o seu codigo contra SQL Injection.
 $login = mysql_real_escape_string($login);
 $nickname = mysql_real_escape_string($nickname);
 $senha = mysql_real_escape_string($senha);
 $email = mysql_real_escape_string($email);


	$consulta = mysql_query("SELECT * FROM usuarios WHERE login = '$login'");
    $NumeroLinhas = mysql_num_rows($consulta);
	if ($NumeroLinhas < 1) {


    $consulta2 = mysql_query("SELECT * FROM usuarios WHERE nickname = '$nickname'");
    $NumeroLinhas2 = mysql_num_rows($consulta2);
	if ($NumeroLinhas2 < 1) {


 $insert = mysql_query("insert into usuarios (login,nickname,senha,email) values ('{$login}','{$nickname}','{$senha}','{$email}')");
 mysql_close($conexao);
 if($insert) {
     print "Cadastro Realizado!";
 }else {
     print "Erro ao Cadastrar!";
 }
 }else{
 print "Nickname ja esta em uso!";
 }
 }else{
 print "Login ja esta em uso!";
 }
 ?>

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/rodrigue/public_html/dmo/enviar.php on line 21

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/rodrigue/public_html/dmo/enviar.php on line 26

Help me please =(((

I prefer you to first check whether you are able to fetch data from database using mysql_fetch_array....
Because there is error in the query.....
Check this....It might work...

$consulta = mysql_query("SELECT * FROM usuarios WHERE login = '".$login."'");

If this works then it's ok...
otherwise give the complete database and i will help u to find the solution

Didn't worked =/

CREATE TABLE IF NOT EXISTS `usuarios` (
  `login` varchar(15) NOT NULL default '',
  `nickname` varchar(15) NOT NULL default '',
  `senha` varchar(20) NOT NULL default '',
  `email` varchar(40) NOT NULL default '',
  `id` int(10) unsigned NOT NULL auto_increment,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;

easier method is using count($result); then echo it out on screen

oh and remove all the if/else statements, use the following instead:

switch ($i) {
    case 0:
        echo "i equals 0";
        break;
    case 1:
        echo "i equals 1";
        break;
    case 2:
        echo "i equals 2";
        break;
}

easier method is using count($result); then echo it out on screen

Worked but it give me result = 1 but haven't no one register in DB...

Oh My God,what's wrong, --.--''''

mysql_num_rows is only if u want to retreive back 1 row from the database, i would use mysql_fetch_array.

Go through the "Read Me: FAQ:" post on the top of the php posts and follow the steps mentioned in that post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.