I mention the following, your code should look like this:
$conexion = new mysqli('localhost', 'root', 'password', 'database');
$usuario="jose";
$linku= $_POST["linkm"];
$query=mysqli_query($conexion, "UPDATE link SET acceso='$linku' WHERE usuario='$usuario'");
if($query){
echo "actualizado";
}else{
echo "no actualizado";
}
WHAT DID I DO?
You can also pass the name of the database in the instance of mysqli
, so you do not need a function to connect and another to select the database
variable $query
will store the query, where: first I pass the variable of $conexion
and later the query; note how the variables I put them in single quotes
On the outside by a simple conditional evaluate whether the variable $query
was executed or not, remember that it has a Boolean value so it is enough to do if(var)
to check if it is executed or not
With the above, your code must already be functional
UPDATE
Considering that you are working with mysqli
and that you are receiving data from the user, the ideal thing here is to work the query in a prepared way to prevent SQL INJECTION , so your query should be like this
$conexion = new mysqli('localhost', 'root', 'password', 'database');
$linku= $_POST["linkm"];
$usuario="jose";
$query= $conexion->prepare("UPDATE link SET acceso= ? WHERE usuario= ?");
$query->bind_param('ss', $linku, $usuario);
$query->execute();
if($query){
echo "actualizado";
}else{
echo "no actualizado";
}
WHAT I DID
Replace the direct call of the variables in the query, with placeholders ?