I
I
IgorRastarov2017-03-21 16:14:55
PHP
IgorRastarov, 2017-03-21 16:14:55

Why are records not being added to the database on Denwer?

Hello. I am working on localhost. I'm trying to transfer data to a database.
Here is my form

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Untitled Document</title>
</head>
<body>
<form action="config.php" method="post" name="forma">
<fieldset>
<label for="first_name">Имя:</label><br/>
<input type="text" name="first_name" size="30"><br/>
<label for="last_name">Фамилия:</label><br/>
<input type="text" name="last_name" size="30"><br/>
<label for="email">Email:</label><br/>
<input type="text" name="email" size="30"><br/>
</fieldset>
<br/>
<fieldset>
<input id="submit" type="submit" value="Отправить данные"><br/>
</fieldset>
</form>
</body>
</html>

Here is config.php
<?php
mysql_pconnect("localhost","root","") or die ("Невозможно подключение к MySQL");
mysql_select_db("new_db") or die ("Невозможно открыть таблицу с данными");
$first_name = $_POST['first_name'];
$last_name  = $_POST['last_name'];
$email  = $_POST['email'];
$result = mysql_query ("INSERT INTO users VALUES ('".$first_name."', '".$last_name."', '".$email."')");
if ($result) 
  echo "Добавлено в базу данных.";
?>

I fill out the form, submit it, a completely empty config.php opens, with no errors at all. And the data in the table in a DB and is not brought.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Koryukov, 2017-03-21
@IgorRastarov

After calling mysql_query add a call to mysql_error and see what row it returns.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question