0

I am trying to make a website that has a database connected to it. I am on a Mac. I downloaded XAMPP and have developed the form on my webpage that I am going to use to get data from the user. I have tested that and it seems to be working. I then followed XAMPP instructions on how to create a sqlite db through the terminal and then connect to that database through php. I was able to read things from that database with a select statement however when I went to go insert into it, it said that it was a read only copy and that I could not insert. I was wondering if there was a line of code that I was missing? Or some setting that I had to change?

Here is a picture of the error that is displaying

Here is a picture of the error that is displaying

Here is my PHP code, I can also share the HTML if you need it:

    <html> 

    <style type="text/css">
    body {background-color:#666666; color: white;}
    </style> 

    <body>
    <h1 align = "center">

    <img src="housebackground.jpg" alt="Mountain View" style="width:97%;height:228px;" ></h1>

    <h1 align = "center">Submission Status</h1>

    <?php
       $db = new SQLite3('mydb.sq3');

       $StructureName = $_POST["StructureName"];
       $Author = $_POST["Author"];
       $YearBuilt = $_POST["YearBuilt"];
       $EraBuilt = $_POST["EraBuilt"];
       $YearDestroyed = $_POST["YearDestroyed"];
       $EraDestroyed = $_POST["EraDestroyed"];
       $Latitude = $_POST["Latitude"];
       $Longitude = $_POST["Longitude"];
       $StructureLink = $_POST["StructureLink"];


       $db->exec("INSERT INTO info VALUES (null, '$StructureName', '$Author', $YearBuilt, '$EraBuilt', $YearDestroyed, '$EraDestroyed', $Latitude, $Longitude, '$StructureLink');"); 


       unset($db); 
    ?>

    <br><br>
    </body>
    </html>
  • @JayBlanchard That makes sense however I am not sure on how to make the htdoc folder in the XAMPP application a writable folder? I am sorry I am very new to webdev, so I am very confused and not just being lazy. I looked up "how to make a folder writable" but there are conflicting things and I don't want to mess anything up. – Jessica Napolitano Mar 15 '17 at 20:47
  • Since you're using XAMPP I am assuming you're on Windows. You make the folder writable under the Security tab for the folder. Curious though: why aren't you using the MySQL database that comes with XAMPP? – Jay Blanchard Mar 16 '17 at 12:10

0 Answers0