0

why i have this problem? i created the "bdconsultas" in phpmyadmin but this error still appearing

<?php

$conexion=mysql_connect("localhost","root","1234") or die("Problemas en la conexion");

mysql_select_db("bdconsultas",$conexion) 
                 or die("Problemas en la seleccion de la base de datos");

mysql_query("insert into tconsultas(nombre,mail,mensaje) 
    values ('$_REQUEST[nombre]','$_REQUEST[mail]','$_REQUEST[mensaje]')",$conexion) 
    or die("Problemas en el select:".mysql_error());

mysql_close($conexion);

echo "El cliente fue dado de alta.";

?>
Vinay Veluri
  • 6,317
  • 5
  • 30
  • 54
  • The mysql extension is deprecated, and has been removed from PHP 7. It's advised you use mysqli or PDO instead. – Bytewave Feb 21 '17 at 04:47
  • Try checking to see if the PHP MySQL extension module is being loaded: with – Pramod Patil Feb 21 '17 at 04:47
  • Possible duplicate of [Fatal error: Call to undefined function mysql\_connect()](http://stackoverflow.com/questions/10615436/fatal-error-call-to-undefined-function-mysql-connect) – Adhan Timothy Younes Feb 21 '17 at 04:48

1 Answers1

0

you can use mysqli_*.

<?php
 $servername = "localhost";
 $username = "root";
 $password = "1234";
 $dbname = "bdconsultas";

 // Create connection
 $conn = new mysqli($servername, $username, $password, $dbname);
 // Check connection
if ($conn->connect_error) {
 die("Connection failed: " . $conn->connect_error);
}

$sql = "insert into tconsultas(nombre,mail,mensaje) 
values ('$_REQUEST[nombre]','$_REQUEST[mail]','$_REQUEST[mensaje]')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();

?>

for more reference please read here

denny
  • 1,914
  • 2
  • 14
  • 19