0
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

$aa = (isset($_POST['aa'])) ? $_POST['aa'] : false;
$a= (isset($_POST['a'])) ? $_POST['a'] : false;
$b = (isset($_POST['b'])) ? $_POST['b'] : false;
$c = (isset($_POST['c'])) ? $_POST['c'] : false;
$d = (isset($_POST['d'])) ? $_POST['d'] : false;
$e = (isset($_POST['e'])) ? $_POST['e'] : false;
$f = (isset($_POST['f'])) ? $_POST['f'] : false;
$g = (isset($_POST['g'])) ? $_POST['g'] : false;


if ($aa && $c) {



    $query = "INSERT INTO casa
              VALUES ('$aa', '$a', '$b', '$c', '$d', '$e', '$f', '$g', 1);";


    $conexion = mysqli_connect('localhost','hostname','password','data_base');



    $resultado = mysqli_query($conexion, $query);


    if ($resultado) {

        echo 'OK';
    } else if (mysqli_errno($conexion) == 1062) {

        echo 'Duplicado';
    } else {

        echo 'Error';
    }
} else {

    //header("Location: index.html");
       echo 'asad';
}

When I upload all my filles to a web hosting, I compliment all the form and when I send it:

Warning: mysqli_connect(): (HY000/2002): No such file or directory in /home/vol4_2/260mb.net/n260m_21275877/xxxx.260mb.org/htdocs/form.php on line 26 Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/vol4_2/260mb.net/n260m_21275877/xxxx.260mb.org/htdocs/form.php on line 30 Error

And line 26 is the connection and line 30 is the mysqli_query

I need some help. thanks!!

Ben
  • 163
  • 3
  • 18
Ara
  • 1

2 Answers2

0

im not sure if you have changed or renamed your user and password in your db, so that's why your case come from here, so plis check this line

$conexion = mysqli_connect('localhost','hostname','password','data_base');
Tobok Sitanggang
  • 607
  • 5
  • 15
0

The problem is in your MySQL server on hosting.

If it's shared hosting, pls write ticket to provider with error you're getting: "Unable to connect to MySQL. Debugging errno: 2002 Debugging error: No such file or directory".

If you're using VPS or local server, check that mysql.sock file exist in right path and have write permission.

In my.cnf config file you can correct and check path to mysql.sock file:

[Mysqld]
socket = /tmp/mysql.sock
[Client]
socket = /tmp/mysql.sock

And then restart the server /etc/init.d/mysql restart

Related Question: Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in

Sergei Shitikov
  • 287
  • 2
  • 12
  • i´m using 260mb.net as my hosting. But I don´t what should I change to fix it – Ara Mar 06 '18 at 13:36
  • Try to contact with support and show them error you are getting. It depends on hosting settings or connection credentials you are using. – Sergei Shitikov Mar 06 '18 at 13:43