<?phpinclude("conexao.php");?><?php$nome=$_POST['nome'];$senha=$_POST['senha'];$verificando=mysql_query("SELECT * FROM usuarios WHERE nome = '$nome' ");if(mysql_num_rows($verificando)==1){echo"<script>alert('Este nick jรก esta em uso')";}else{$sql=mysql_query("INSERT INTO usuarios(nome, senha) VALUES ('$nome', '$senha')");echo"<script>location.href='central.php';";}?>
Verifique se existem dados em $nome e $senha.
Talvez eles não estão chegando.
Caso estejam preenchidos, tente concatenar as variáveis:
“SELECT * FROM usuarios WHERE nome = '” . $nome . “’ “
“INSERT INTO usuarios(nome, senha) VALUES (’” . $nome .”’, '” . $senha ."’)"
M
Matheus_D
Tem como me passar o código completo ? Está dando este erro:
Warning: mysql_query(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Sao_Paulo’ for ‘-3.0/no DST’ instead in C:\WebServer\Apache2.2\htdocs\c\cadastrando.php on line 7 Warning: mysql_query(): Access denied for user ‘’@‘localhost’ (using password: NO) in C:\WebServer\Apache2.2\htdocs\c\cadastrando.php on line 7 Warning: mysql_query(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Sao_Paulo’ for ‘-3.0/no DST’ instead in C:\WebServer\Apache2.2\htdocs\c\cadastrando.php on line 7 Warning: mysql_query(): A link to the server could not be established in C:\WebServer\Apache2.2\htdocs\c\cadastrando.php on line 7 Warning: mysql_num_rows(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Sao_Paulo’ for ‘-3.0/no DST’ instead in C:\WebServer\Apache2.2\htdocs\c\cadastrando.php on line 8 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\WebServer\Apache2.2\htdocs\c\cadastrando.php on line 8 Warning: mysql_query(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Sao_Paulo’ for ‘-3.0/no DST’ instead in C:\WebServer\Apache2.2\htdocs\c\cadastrando.php on line 11 Warning: mysql_query(): Access denied for user ‘’@‘localhost’ (using password: NO) in C:\WebServer\Apache2.2\htdocs\c\cadastrando.php on line 11 Warning: mysql_query(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Sao_Paulo’ for ‘-3.0/no DST’ instead in C:\WebServer\Apache2.2\htdocs\c\cadastrando.php on line 11 Warning: mysql_query(): A link to the server could not be established in C:\WebServer\Apache2.2\htdocs\c\cadastrando.php on line 11
Bega_Lima
Cara, tem como passar o arquivo conexao.php?
Talvez tenha algum parâmetro errado ao tentar fazer a conexão.
F
Fred_Peixoto
Boa tarde,
Cara acho que é algo na conexão.
$sql="select * from tabela;$executeQuery=mysqli_query( $conexaoDoIncludeComOBanco, $sql);$numberRows=$executeQuery->num_rows;
if($numberRows>0){
echo"já existe "; }
else{
echo"faz outra coisa";}
se puder colocar o arquivo conexao ajuda. vlw.
L
LostSoldier1 like
Bom, interpretando sua mensagem de erro, alguns pontos:
Tente corrigir esses pontos inicialmente, após vai postando outras mensagens que ocorrer…
Outra coisa, se estiver usando versões mais novas do php, evite usar api mysql_*, dê preferência por PDO ou Mysqli assim você já fica compatível com a versão 7 (que removeu a api antiga) evitando incompatibilidade e o principal, acrescentando mais performance e segurança no seu código…