0

I am using php script to add data from inputs to mysql data base

    <?php
$dblocation = "127.0.0.1"; 
$dbuser = "root";          
$dbpasswd = "root";            
$dbname = "mydbtest";   
$link = mysqli_connect($dblocation, $dbuser, $dbpasswd, $dbname);
$dbcnx = @mysql_connect($dblocation,$dbuser,$dbpasswd);
if (!$dbcnx) 
{
  echo("<P>Something gone wrong</P>");
  exit();
}
else{
    if (!@mysql_select_db($dbname, $dbcnx)) {
    echo( "<P>Bad news.</P>" );
    exit();
    }
    $country = $_POST['country'];
    $city = $_POST['city'];
    $linkF = $_POST['linkF'];
    $description = $_POST['description'];
    $price = $_POST['price'];
    $square = $_POST['square'];
    $floor = $_POST['floor'];
    $address = $_POST['address'];
    $query = "INSERT INTO avito ('country','city','address', 'linkF', 'description','price', 'square', 'floor') VALUES ('$country', '$city','$address', '$linkF','$description','$price',
    '$square', '$floor')";
    $result = mysqli_query($link, $query); 
    if($result)
        echo 'Success';
    else 
        echo 'Failed adding new room';
}
?>

And it's always 'Failed adding new room'. If you can help me i would be very happy, thanks.

hype
  • 1
  • Pro tip: check for errors with [`mysqli_error()`](http://php.net/manual/en/mysqli.error.php). – John Conde Jul 08 '16 at 19:14
  • don't output fixed error messages. they're useless. have the DB tell you why it failed: `echo $link->error` – Marc B Jul 08 '16 at 19:14

0 Answers0