Ok I feel like such a noob. I am trying to create a webform in which sends data to my sqlite database. I keep getting error Error in insert: SQLSTATE[HY000] [14] unable to open database file
I have tried numerous things. Here is the code for the files.
IF anyone has any idea please let me know, i will be checking this as often as possible as i need to get this correct by friday.
I’ve made sure sqlite is running and i’ve checked with php. Also went into the php file and removed the ;'s
Thank you
index.html
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
<meta name=“description” content=“Created by: Jonathan Brainard” />
<title>Main Page</title>
<style type=“text/css”>
<!–
.style1 {
font-family: “Times New Roman”, Times, serif;
font-size: 16px;
color: #003E34;
}
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
color: #000000;
}
body {
background-color: #FFFFFF;
}
–>
</style>
<link href=“color.css” rel=“stylesheet” type=“text/css” />
<style type=“text/css”>
<!–
a:link {
color: #FF0000;
}
a:visited {
color: #0000FF;
}
.style4 {
font-size: 16px;
font-family: “Times New Roman”, Times, serif;
}
.style5 {
font-size: 12px
}
.style6 {
font-size: 18px;
font-weight: bold;
}
.style15 {color: #000000; font-family: “Times New Roman”, Times, serif; font-size: 15px; }
.style16 {
font-family: “Times New Roman”, Times, serif;
font-size: 18px;
font-weight: bold;
}
.style18 {
font-size: 36px
}
.style21 {font-size: 24px; font-family: “Times New Roman”, Times, serif;}
.style23 {font-size: 26px}
.style24 {font-size: 14px}
–>
</style>
<script src=“AC_RunActiveContent.js” type=“text/javascript”></script>
</head>
<body>
<div class=“style16”>
<div align=“left” class=“style18”>
<div align=“center”>Admissions Inquiry Form</div>
</div>
</div>
<h3 align=“center”>Please fill out the following information.</h3>
<div align=“left” class=“style21 style23”></div>
<p align=“center”></p>
<form action=‘save.php’ method=‘post’>
<div align=“left” class=“style1”>
<div align="center">
<table width="367" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td><span class="style15">Last Name:</span></td>
<td><span class="style15">
<label>
<input name="lname" type="text" id="lname" size="30" maxlength="60" />
</label>
</span></td>
</tr>
<tr>
<td><p class="style15">First Name:</p> </td>
<td><span class="style15">
<label>
<input name="fname" type="text" id="fname" size="30" maxlength="60" />
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">Middle Intial:</span></td>
<td><span class="style15">
<label>
<input name="mname" type="text" id="mname" size="5" maxlength="1" />
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">Street Line 1:</span></td>
<td><span class="style15">
<label>
<input name="street1" type="text" id="street1" size="30" maxlength="30" />
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">Street Line 2:</span></td>
<td><span class="style15">
<label>
<input name="street2" type="text" id="street2" size="30" maxlength="30" />
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">City:</span></td>
<td><span class="style15">
<label>
<input name="city" type="text" id="city" size="30" maxlength="20" />
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">State:</span></td>
<td><span class="style15">
<label>
<select name="state" id="state">
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AS">AS</option>
<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DE">DE</option>
<option value="DC">DC</option>
<option value="FM">FM</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="GU">GU</option>
<option value="HI">HI</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="IA">IA</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="ME">ME</option>
<option value="MH">MH</option>
<option value="MD">MD</option>
<option value="MA">MA</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MS">MS</option>
<option value="MO">MO</option>
<option value="MT">MT</option>
<option value="NE">NE</option>
<option value="NV">NV</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NY">NY</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="MP">MP</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PW">PW</option>
<option value="PA">PA</option>
<option value="PR">PR</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VT">VT</option>
<option value="VI">VI</option>
<option value="VA">VA</option>
<option value="WA">WA</option>
<option value="WV">WV</option>
<option value="WI">WI</option>
<option value="WY">WY</option>
</select>
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">Zip:</span></td>
<td><span class="style15">
<label>
<input name="zip" type="text" id="zip" size="30" maxlength="5" />
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">Area Code:</span></td>
<td><span class="style15">
<label>
<input name="areacode" type="text" id="areacode" size="30" maxlength="3" />
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">Phone Number:</span></td>
<td><span class="style15">
<label>
<input name="phone" type="text" id="phone" size="30" maxlength="7" />
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">E-mail:</span></td>
<td><span class="style15">
<label>
<input name="email" type="text" id="email" size="30" maxlength="60" />
</label>
</span></td>
</tr>
<tr>
<td class="style15">Birthday: <span class="style24">DDMMYYYY</span></td>
<td><span class="style15">
<label>
<input name="bday" type="text" id="bday" size="30" maxlength="10" />
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">Gender:</span></td>
<td><span class="style15">
<label>
<select name="gender" id="gender">
<option value="M" selected="selected">Male</option>
<option value="F">Female</option>
</select>
</label>
</span></td>
</tr>
<tr>
<td><span class="style15">Highschool CEEB Code:</span></td>
<td><input name="ceeb" type="text" id="ceeb" size="30" maxlength="16" /></td>
</tr>
<tr>
<td><span class="style15">Highschool Graduation Year:</span></td>
<td><input name="gradyear" type="text" id="gradyear" size="30" maxlength="4" /></td>
</tr>
<tr>
<td><span class="style15">Major Code:</span></td>
<td><input name="major" type="text" id="major" size="30" maxlength="4" /></td>
</tr>
<tr>
<td><span class="style15">Interest Code:</span></td>
<td><input name="interest" type="text" id="interest" size="30" maxlength="2" /></td>
</tr>
<tr>
<td><span class="style15">Inquiry Type:</span></td>
<td><span class="style15">
<select name="inquiry" id="inquiry">
<option value="CN">College Night</option>
<option value="HS">High School</option>
<option value="O">Other</option>
</select>
</span></td>
</tr>
</table>
</div>
<p align="center"><strong>
<input name="Submit" type="Submit" id="Submit" value="Submit" />
</strong></p>
<div class="style6"></div>
</div>
</form>
<p align=“center”> </p>
<p align=“center”><span class=“style4”>If you have any questions please contact the <a href=“mailto:brainajw@alfredstate.edu”>Web Master</a></span></p>
save.php
<style type=“text/css”>
<!–
.insert {font-family: “Times New Roman”, Times, serif;
color: #000000;
background-color: #FFFFFF;
}
–>
</style>
<h1>
<center>
<p><b>Thank you!</b></p>
</center>
</h1>
<h3>
<center>
<p class=“insert”>You may exit your browser, or click <a href=“index.html” target=“_parent”>here</a> to return.</p>
</center>
</h3>
<?php
ini_set(“display_errors”, true);
// if form submitted
// attempt database connection
//$db=‘admission.db’;
//$sqlite= new SQLiteDatabase($db, 0666);
// check input making sure required fields have data
$lname= !empty($_POST[‘lname’]) ? sqlite_escape_string($_POST[‘lname’]) : die(‘ERROR: Last name is required’);
$fname= !empty($_POST[‘fname’]) ? sqlite_escape_string($_POST[‘fname’]) : die(‘ERROR: First name is required’);
$mname= !empty($_POST[‘mname’]) ? sqlite_escape_string($_POST[‘mname’]) : die(‘ERROR: Middle intial is required’);
$street1= !empty($_POST[‘street1’]) ? sqlite_escape_string($_POST[‘street1’]) : die(‘ERROR: Street line 1 is required’);
$street2= $_POST[‘street2’]; //not required
$city= !empty($_POST[‘city’]) ? sqlite_escape_string($_POST[‘city’]) : die(‘ERROR: City is required’);
$state= !empty($_POST[‘state’]) ? sqlite_escape_string($_POST[‘state’]) : die(‘ERROR: State is required’);
$zip= !empty($_POST[‘zip’]) ? sqlite_escape_string($_POST[‘zip’]) : die(‘ERROR: Zip Code is required’);
$areacode= !empty($_POST[‘areacode’]) ? sqlite_escape_string($_POST[‘areacode’]) : die(‘ERROR: Area code is required’);
$phone= !empty($_POST[‘phone’]) ? sqlite_escape_string($_POST[‘phone’]) : die(‘ERROR: Phone # is required’);
$email= !empty($_POST[‘email’]) ? sqlite_escape_string($_POST[‘email’]) : die(‘ERROR: Email required’);
$bday= !empty($_POST[‘bday’]) ? sqlite_escape_string($_POST[‘bday’]) : die(‘ERROR: Birthday is required’);
$gender= !empty($_POST[‘gender’]) ? sqlite_escape_string($_POST[‘gender’]) : die(‘ERROR: Gender is required’);
$ceeb= !empty($_POST[‘ceeb’]) ? sqlite_escape_string($_POST[‘ceeb’]) : die(‘ERROR: Highschool CEEB Code is required’);
$gradyear= !empty($_POST[‘gradyear’]) ? sqlite_escape_string($_POST[‘gradyear’]) : die(‘ERROR: Highschool Graduation Year is required’);
$major= !empty($_POST[‘major’]) ? sqlite_escape_string($_POST[‘major’]) : die(‘ERROR: Major Code is required’);
$interest= !empty($_POST[‘interest’]) ? sqlite_escape_string($_POST[‘interest’]) : die(‘ERROR: Interest Code is required’);
$inquiry= !empty($_POST[‘inquiry’]) ? sqlite_escape_string($_POST[‘inquiry’]) : die(‘ERROR: Inquiry Type is required’);
try
{
$dbh = new PDO('sqlite:"C:\\wamp\\www\\admissions.db"');
$sql = "INSERT INTO students VALUES ('','$lname','$fname','$mname','$street1','$street2','$city','$state','$zip','$areacode','$phone','$email','$bday','$gender','$ceeb','$gradyear','$major','$interest','$inquiry')";
$dbh->query($sql);
echo "Thank You";
}
catch(PDOException $e)
{
echo "Error in insert: " . $e->getMessage();
}
/*** close the database connection ***/
$dbh = null;
//$sql = “INSERT INTO students VALUES (‘’,‘$lname’,‘$fname’,‘$mname’,‘$street1’,‘$street2’,‘$city’,‘$state’,‘$zip’,‘$areacode’,‘$phone’,‘$email’,‘$bday’,‘$gender’,‘$ceeb’,‘$gradyear’,‘$major’,‘$interest’,‘$inquiry’)”;
//if ($sqlite->queryExec($sql) == true) {
//echo ‘<div id=“message”>Data recorded successfully.</div>’;
//} else {
//echo "ERROR: Could not execute $sql. " . sqlite_error_string($sqlite->lastError());
//}
// close connection
//unset($sqlite);
?>