-2

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead.

connect.php

error in:

<?php function connections(){
$user="root";
$pass="";
$server="localhost";
$db="db";
$con=mysql_connect($server,$user,$pass) or die ('Connection failed: '.mysql_error());
mysql_select_db($db,$con) or die ('Could db: '.mysql_error());
return $con;
}
?>

insertcase.php

error in:

$con=connections();

$query="insert into caso values ('','$date','name')";

$cierto=mysql_query($query,$con);

if(!$cierto){
echo "No saved";
}
else {
$query= mysql_query("SELECT @@identity  AS id ");
 if ($row = mysql_fetch_row($query)) 
 {
   $id = trim($row[0]);
}
echo '<script>alert (" tickect is:  '.$id.'");   window.location="../index.php";</script>';
}

please help... :)

chris85
  • 23,846
  • 7
  • 34
  • 51

1 Answers1

0

Use PDO to connect to a mysql server.

here is an example.

 <?php
  $servername = "localhost";
  $username = "username";
  $password = "password";

 try {
     $conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);
     // set the PDO error mode to exception
     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     echo "Connected successfully";
     }
 catch(PDOException $e)
     {
     echo "Connection failed: " . $e->getMessage();
     }
 ?> 
Bela_b
  • 121
  • 5