J
J
Jony13372016-10-10 19:17:20
PHP
Jony1337, 2016-10-10 19:17:20

Why is the database query not working?

There is a request

$NameVideo = $_POST ['name'];
$idVideo = $_POST ['message'];
echo $NameVideo;
$db = mysql_connect("localhost","d9",774272722");
mysql_select_db("dlx",$db);
mysql_query("SET NAMES utf8");
$resultat = mysql_query("INSERT INTO `dlx`.`videoByMe` (`id`, `DenumireaVideo`, `VideoMixID`) VALUES (NULL, \'.$NameVideo.\', \'.$idVideo.\');");
mysql_close($db);

and nothing changes in the database

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Walt Disney, 2016-10-11
@Jony1337

$NameVideo = $_POST ['name'];
$idVideo = $_POST ['message'];
echo $NameVideo;
$db = mysql_connect("localhost","d9",774272722");
mysql_select_db("dlx",$db);
mysql_query("SET NAMES utf8");
$resultat = mysql_query("INSERT INTO `dlx`.`videoByMe` (`id`, `DenumireaVideo`, `VideoMixID`) VALUES (NULL, '$NameVideo', '$idVideo')"); // тут был бардак с кавычками
if(!$resultat){
 var_dump(mysql_error()); // тут скорее всего ругнётся, что id не может быть NULL
 exit();
}
mysql_close($db);

W
WQP, 2016-10-10
@WQP

Learn php.net/manual/en/book.pdo.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question