Good morning, I'm new to PHP and I'm trying to make a form that puts the data in a mysql bd.
HTML code (Bootstrap):
<div class="form-group">
<label for="nome" class="col-md-1 control-label">Nome:</label>
<div class="col-md-11">
<input type="text" id="nome" name="nome" class="form-control" placeholder="Hubert Weber Xylo, 2012"></input>
</div>
</div>
<div class="form-group">
<label for="descricao" class="col-md-1 control-label">Descrição:</label>
<div class="col-md-11">
<textarea name="descricao" class="form-control" rows="3"></textarea>
</div>
</div>
Code info.php:
<?php
$connect = mysql_connect("localhost", "root", "1234");
if (!$connect) {
die('Connection Failed:' .mysql_error());
}
mysql_select_db("db_teste", $connect);
$nome = $_POST['nome'];
$descricao = $_POST['descricao'];
$user_info = "INSERT INTO 'mytable' ( 'NOME', 'DESCRICAO' ) VALUES ( $nome, $descricao )";
if (!mysql_query($user_info, $connect)) {
die('Error: ' . mysql_error());
}
echo 'Cadastro concluido.';
mysql_close($connect);
But the error I'm getting is the following:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' mytable '' (at
NOME
,DESCRICAO
) VALUES (TestName, TestDesc) 'at line 1
What am I doing wrong?