non si collega al database =Fatal error: Uncaught Error: Call to undefined function mysql_select_db() in /home/mhd-01/www.sito.it/htdocs/pagina.php:56 Stack trace: #0 {main} thrown in /home/mhd-01/www.sito.it/htdocs/pagina.php on line 56
Codice: Seleziona tutto
<?php
// dichiaro le variabili che ricevo da arduino
$publicKey = $_GET['publicKey'];
$privateKey = $_GET['privateKey'];
$CPM = $_GET['CPM'];
$Dose = $_GET['Dose'];
$Vcc = $_GET['Vcc'];
$MaxCPM = $_GET['MaxCPM'];
// inserimento data e ora
$tmsp = strtotime("now");
$date = date('d/m/Y ', $tmsp);
$time = date(' H:i:s ', $tmsp);
// Nome della Stazione di rilevamento
$station = ('nome stazione');
// Nome della tabella
$tabella = "ik0_tab";
// effettuo la connessione al mysql
$host = "sql.sito.it";
$database = "database1";
$password = "1234567";
$link = mysql_connect($host, $database, $password);
if (!$link) {
die('non connesso : ' . mysql_error());
}
// effettuo la connessione al database mysql
$db_selected = mysql_select_db('database1', $link);
if (!$db_selected) {
die ('Non è possibile connettersi al database : ' . mysql_error());
}
// seleziono la tabella nella quale memorizzare i dati
$query = mysql_query("SELECT * FROM $tabella");
$fetch = mysql_fetch_array($query);
// inserisco i valori
if (mysql_query("INSERT INTO $tabella(publicKey,privateKey,station,date,time,CPM,Dose,Vcc,MaxCPM)
VALUES('$publicKey','$privateKey','$station','$date','$time','$CPM','$Dose','$Vcc','$MaxCPM') ")or die(mysql_error()))
{ // se tutto è andato a buon fine...
echo "OK";
}
else{
echo "ERROR";
}
?>