[Solved] Unable to insert data in MySQL database [duplicate]


I suggest using PDO or MYSQLi because MySQL_ is depreciated. Not only that, you’re not escaping your values and are exposing yourself to some issues such as MySQL injection

$pdo = new PDO("mysql:host=localhost;dbname=db","root","password");
$query = $pdo->prepare("INSERT INTO `metabase` (url, title, image, description) VALUES(:url, :title, :image, :descr)");
$query->bindValue(":url", "http://www.imgur.com", PDO::PARAM_STR);
$query->bindValue(":title", $title, PDO::PARAM_STR);
$query->bindValue(":image", $image, PDO::PARAM_STR);
$query->bindValue(":descr", $descr, PDO::PARAM_STR);
$query->execute();

8

solved Unable to insert data in MySQL database [duplicate]