I'm running a small web server on my raspberry pi using nginx, php5, and sqlite3. Unfortunately, when I'm trying to insert some data into my database, it just stops at sqlite_open(). No errors, it just stops.
<html>
<head>
<title>halp</title>
<style>
* {font-family:verdana;}
</style>
</head>
<body>
<p><h2>Log in</h2></p>
<form action="" method="POST">
<table>
<tr><td>Username</td><td><input type="text" name="user"></td></tr>
<tr><td>Password</td><td><input type="password" name="pass"></td></tr>
<tr><td><input type="submit" value="Submit"></td><td><input type="checkbox" value="r" name="r"></td></tr>
</table>
</form>
<?php
if(isset($_POST['r']) || isset($_POST['user'])){
$reg = $_POST['r'];
if($reg == 'r'){
// echo $reg, "<br>";
echo "Registering... <br>";
$user = md5($_POST['user']);
$pass = md5($_POST['pass']);
// echo "user and pass <br>";
// echo "user: ", $user, " pass: ", $pass, "<br>";
try{
// echo "inside try <br>";
$db = sqlite_open('testdb', 0666, $error); //stops here
echo "error: ", $error->getMessage();
} catch (Exception $e) {
echo "error: ", $e->getMessage();
}
// echo "sqlite_open <br>";
if(!$db) { die($error); }
$query = "INSERT INTO users VALUES('$user', '$pass')";
$registered = sqlite_query($db, $query);
// echo "sqlite_exec";
if($registered){
echo "New user registered.<br>";
// echo $user." ";
// echo $pass;
} else { die($error); }
sqlite_close($db);
}
else{
$user = md5($_POST['user']);
$pass = md5($_POST['pass']);
// print $user."\n";
// print $pass."\n";
$db = new SQLite3('testdb');
$results = $db->query("SELECT * FROM users WHERE user = '$user' AND pass = '$pass';");
if(!$results){ echo 'Database error'; }
else {
$resultArray = $results->fetchArray(SQLITE3_NUM);
if($resultArray[0] == $user && $resultArray[1] == $pass){
echo 'Password and username match found!';
}
else{
echo 'Password and username do not match.';
}
}
}
}
?>
<br>
<a href="index.html">Back</a>
</body>
</html>
Once it gets to sqlite_open() it stops. As you can see, there is a link to index.html at the bottom of the code, but when I run this file, it does not display. The echos that I have commented out tell me that I only get as far as the try statement.
I have tried several things to resolve this:
- Creating a database using
sqlite3in command line - Messing with nginx & php configs
- Specifically, using my own sites-enabled
- Changing the value of
sqlite.assoc_caseinphp.ini. Frustratingly, there is a link to a page on php.net that does not exist.
- Because
sqlite_open()creates a database if it is not found, I used that to createtestdb chmod a+rwx testdbchmod a+rwx /var/www/html- Adding myself to
www-datagroup chgrp -R www-data /var/www/html- Different browsers
- IE hates it
- Rebooting even
This wouldn't be so rage inducing if I at least had an error message. gah.