0
<?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 =(((

4
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by karthik_ppts
0

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

0

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 ;

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

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;
}

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

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, --.--''''

0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.