• 0
Sign in to follow this  
Jonathan Rodrigues

Problema de Seleção do mysql no php

Question

boa tarde, caros amigos

estou desenvolvendo uma pagina de cadastro em $_POST, quando clico em cadastrar diz que o banco de dados não está selecionado segue abaixo meus codigos

cad.php

<?php
//variaveis
$nome= $_POST['nome'];
$cnpjcpf= $_POST['cnpjcpf'];
$ie= $_POST['ie'];
$endereco= $_POST['endereco'];
$bairro= $_POST['bairro'];
$estado= $_POST['estado'];
$cep= $_POST['cep'];
$contato= $_POST['contato']; 
$telefone= $_POST['telefone'];
$celular= $_POST['celular'];
$email= $_POST['email'];
$website= $_POST['site'];

//conexão
$conecta= mysql_connect ('mysql.sisworks.com.br','sisworks02','7561150490joejo');
if (!$conecta)
//erro sql
die ("Erro de conexão com localhost, o seguinte erro ocorreu -> ".mysql_error());
$banco= mysql_select_db('clientes');
//insere dados 
$inserir = mysql_query ( 'INSERT INTRO $banco (nome,cnpjcpf,ie,endereco,bairro,estado,cep,contato,telefone,celular,email,site) values ( $nome,$cnpjcpf,$ie,$endereco,$bairro,$cep,$contato,$telefone,$celular,$email,$website)')or print (mysql_error());
//mensagem de cadastro
echo "( $nome )"; exit; 
"Seu cadastro foi realizado com sucesso!Agradecemos a atenção.";
?>
cad.html
<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="cad.php"method="post"  enctype="multipart/form-data" >
<input class="text-input small-input" type="checkbox" id="small-input" name="empresa" /><label>Juridica</label>
<input class="text-input small-input" type="checkbox" id="small-input" name="empresa" /><label>Fisica</label>
   
                    
                                    <p>
                                      <label>Nome</label>
                                      <input class="text-input small-input" type="text" id="nome" name="nome" />
  </p>
                                    <p>
                                      <label>CNPJ/CPF</label>
                                      <input class="text-input small-input" type="text" id="cnpjcpf" name="cnpjcpf" />
                                      <label>IE</label>
                                      <input class="text-input small-input" type="text" id="ie" name="ie" />
                                      <label><br />
                                        <br />
                                      Endereço</label>
                                      <input class="text-input small-input" type="text" id="endereco" name="endereco" />
                                      <label>Bairro</label>
                                      <input class="text-input small-input" type="text" id="bairro" name="bairro" />
                                      <label>Cidade</label>
                                      <input class="text-input small-input" type="text" id="cidade" name="cidade" />
                                      <label>Estado</label>
                                      <select id="estado">
                                        <option>Selecione...</option>
                                        <option value="AC">AC</option>
                                        <option value="AL">AL</option>
                                        <option value="AP">AP</option>
                                        <option value="AM">AM</option>
                                        <option value="BA">BA</option>
                                        <option value="CE">CE</option>
                                        <option value="ES">ES</option>
                                        <option value="DF">DF</option>
                                        <option value="MA">MA</option>
                                        <option value="MT">MT</option>
                                        <option value="MS">MS</option>
                                        <option value="MG">MG</option>
                                        <option value="PA">PA</option>
                                        <option value="PB">PB</option>
                                        <option value="PR">PR</option>
                                        <option value="PE">PE</option>
                                        <option value="PI">PI</option>
                                        <option value="RJ">RJ</option>
                                        <option value="RN">RN</option>
                                        <option value="RS">RS</option>
                                        <option value="RO">RO</option>
                                        <option value="RR">RR</option>
                                        <option value="SC">SC</option>
                                        <option value="SP">SP</option>
                                        <option value="SE">SE</option>
                                        <option value="TO">TO</option>
                                      </select>
                                      <label>CEP</label>
                                      <input class="text-input small-input" type="text" id="cep" name="cep" />
  </p>
                                    <p>
                                      <label>Contato</label>
                                      <input class="text-input small-input" type="text" id="contato" name="contato" />
                                      <label>Telefone</label>
                                      <input class="text-input small-input" type="text" id="telefone" name="telefone" />
                                      <label>Celular</label>
                                      <input class="text-input small-input" type="text" id="celular" name="celular" />
                                      <label>Email</label>
                                      <input class="text-input small-input" type="text" id="email" name="email" />
                                      <label>Website</label>
                                      <input class="text-input small-input" type="text" id="site" name="site" />
                                      <input name="cadastrar" type="submit" id="cadastrar" value="Cadastrar" />
  </p>
</form>

</body>
</html>
erro
Nenhum banco de dados foi selecionado

não está gravando no mysql. vlw galera

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Vamos lpa.

$inserir = mysql_query ( 'INSERT INTRO $banco (nome,cnpjcpf,ie,endereco,bairro,estado,cep,contato,telefone,celular,email,si
te) values ( $nome,$cnpjcpf,$ie,$endereco,$bairro,$cep,$contato,$telefone,$celular,$email,$website)')or print (mysql_error());
INSERT INTO sem o R. e outra ali onde ta $banco é o nome da tabela que vai por os dados e não o nome do banco de dados.
mysql_connect ('mysql.sisworks.com.br','sisworks02','7561150490joejo');

tenta não deixar espaço com fez na conexao.. e outra coisa.. o host é mysql.siswork.com.br mesmo ? a tabela clientes existe la.. este usuario que esta utilizando tem permissao para acessar esse banco ?

Da uma pesquisada melhor sobre CRUD em PHP e MYSQL e Conexão ao Banco de dados .

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this