I have got a problem with a script that I am developing.I'm testing it on windows XAMPP and I have got a database and a table which I am trying to insert a row.I am using the mysqli extension and using prepared statements to prevent sql injection.But when I execute the query I gets Error 2006:MySQL server gone away,but the server is working well.The server is my own computer.So I don't know what happens.
This is the code I am using:
<?php
header('Content-type: text/html; charset=utf-8');
if(isset($_GET['user']) && isset($_GET['pass'])){
$db = new mysqli("localhost", "root", "", "admin");
if ($db->connect_errno) {
echo "Falló la conexión a MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
if (!($db = $db->prepare("INSERT INTO logins(user,pass,ip,url) VALUES (?,?,?,?)"))) {
echo "Falló la preparación: (" . $mysqli->errno . ") " . $mysqli->error;
}
if (!$db->bind_param('ssss', $_GET['user'], $_GET['pass'],$_SERVER['REMOTE_ADDR'],$_SERVER["HTTP_REFERER"])){
echo "Falló la vinculación de parámetros: (" . $db->errno . ") " . $db->error;
}
if (!$db->execute()) {
echo "Falló la ejecución: (" . $db->errno . ") " . $db->error;
}
$db->close();
}
?>
Thanks
EDIT:I forgot to put that I have tried to use the ini_set trick,but didn't worked