Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:42:09+00:00 2026-06-18T12:42:09+00:00

I am having issues with my PHP code. I am trying to insert data

  • 0

I am having issues with my PHP code. I am trying to insert data into a mysql database using two session variables that I will need at a later time in the form. However whenever I submit the form I am returned with a “Unknown column in ‘field list'” error.
The code is lengthy but you will likely need all of it to understand the issue.

    <?php
        session_start();
// Check for hazards and put them in an array if there is one selected
if($_SERVER['REQUEST_METHOD'] == 'POST') {
require ('../mysqli_connect.php'); //connect to the db

//Check for offender first name
if (empty($_POST['pris_firstname'])) {
$errors[] = 'You forgot to enter offender first name.';
    } else {
        $prisf=$_POST['pris_firstname'];
    }   

//Check for offender last name
if (empty($_POST['pris_lastname'])) {
$errors[] = 'You forgot to enter offender last name.';
    } else {
        $prisl=$_POST['pris_lastname'];
    }           

//Check for offender date of birth
$dob = ($_POST['pris_dateofbirth']);


//Check for offender phone number
if (empty($_POST['pris_phonenum'])) {
$errors[] = 'You forgot to enter offender Phone Number.';
    } else {
        $prisphone=trim($_POST['pris_phonenum']);
    }           

//Check for offender address
if (empty($_POST['pris_address'])) {
$errors[] = 'You forgot to enter offender Address.';
    } else {
        //$prisaddress=trim($_POST['pris_address']);
        foreach($_POST["pris_address"] as $value) { 
        $prisaddress .= $value . '\n'; 
    } 
    }   



//Check for offender next of kin first name
if (empty($_POST['pris_kinfirstname'])) {
$errors[] = 'You forgot to enter next of kin first name.';
    } else {
        $kinfirst=trim($_POST['pris_kinfirstname']);
    }   

//Check for offender next of kin last name
if (empty($_POST['pris_kinlastname'])) {
$errors[] = 'You forgot to enter next of kin last name.';
    } else {
        $kinlast=trim($_POST['pris_kinlastname']);
    }           

//Check for offender next of kin phone number
if (empty($_POST['pris_kinphone'])) {
$errors[] = 'You forgot to enter next of kin area code.';
    } else {
        $kinphone=trim($_POST['pris_kinphone']);
    }           

if (empty($_POST['pris_kinrelation'])) {
$errors[] = 'You forgot to enter next of kin relation.';
    } else {
        $kinrelation=trim($_POST['pris_kinrelation']);
    }

//Check for offender next of kin address
if (empty($_POST['pris_kinaddress'])) {
$errors[] = 'You forgot to enter next of kin street address.';
    } else  {
                foreach($_POST["pris_kinaddress"] as $value2) { 
                $kinaddress .= $value2 . '\n'; 
            } 
            }                   
if (empty($errors)) { //if everyhing is ok
$q = "INSERT INTO prisoner_profile (pris_status, 
                                    pris_firstname, 
                                    pris_lastname, 
                                    pris_dateofbirth, 
                                    pris_phonenum, 
                                    pris_address, 
                                    pris_kinfirstname, 
                                    pris_kinlastname, 
                                    pris_kinphone, 
                                    pris_kinaddress, 
                                    pris_kinrelation
                                    ) VALUES (
                                    '$status', 
                                               ".$_SESSION['pris_firstname'].",  ".$_SESSION['pris_lastname'].",
                                    '$dob', 
                                    '$prisphone', 
                                    '$prisaddress', 
                                    '$kinfirst', 
                                    '$kinlast', 
                                    '$kinphone', 
                                    '$kinaddress', 
                                    '$kinrelation'
                                    )"; 
$r = @mysqli_query ($dbc, $q); //Run the query.

Hope someone can help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:42:11+00:00Added an answer on June 18, 2026 at 12:42 pm

    The error is pretty much self-explanatory, it means that you have got a column name wrong in your database. I recomend you echo out the error for your query just for this case as:

    $r = mysqli_query ($dbc, $q) or die (mysqli_error());

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some issues trying to insert a query into the database. I have
I'm having issues with code that worked fine in PHP 5.3 and is now
Having issues trying to get this jquery code to work. The idea is that
I'm having issues with the functions.php file with variables $prev_dept = 0; $comment_count =
I'm having issues with connecting to MySQL 5.5.8 from PHP 5.3.5 (WAMP install). I'm
I am trying to get php's namespace technique down but having some issues here:
I am having issues connecting to my Xeround database through php. I have successfully
I'm trying to create a calendar class in php and am having issues returning
I am trying to return an XML list from a MySQL database via PHP
I am trying to gather some information from a MySQL database and am having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.