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 8202309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:08:14+00:00 2026-06-07T07:08:14+00:00

I have been trying to insert a row into my table in my database,

  • 0

I have been trying to insert a row into my table in my database, I couldnt accomplished insert query also I cant get any errors so I dont know what is the problem

my table:

CREATE TABLE IF NOT EXISTS `general_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `First Name` varchar(30) NOT NULL,
  `Last Name` varchar(30) NOT NULL,
  `University` varchar(80) NOT NULL,
  `Major` varchar(50) NOT NULL,
  `Current_Level` varchar(50) NOT NULL,
  `Date_Joined` varchar(15) NOT NULL,
  `Current_Team` varchar(50) NOT NULL,
  `added_by` int(11) NOT NULL,
  `Phone` varchar(25) NOT NULL,
  `Email` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `member_id` (`added_by`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

my html :

<body>

        <div class="memberInfo"> 
        <h1>Add A Member</h1>

        <form id=add_member name="add_member" method="post" action="addmember.php" >

                <fieldset>

                <legend>Member Details</legend>

                <ol>

                    <li>
                        <label for=first_name>First Name</label>
                        <input id=first_name name=first_name type=text placeholder="First Name" required autofocus>
                    </li>

                    <li>
                        <label for=last_name>Last Name</label>
                        <input id=last_name name=last_name type=text placeholder="Last Name" required autofocus>
                    </li>

                    <li>
                        <label for=email>Email</label>
                        <input id=email name=email type=email placeholder="example@domain.com" required>
                    </li>

                    <li>
                        <label for=university>University</label>
                        <input id=university name=university type=text placeholder="Eg.Istanbul University" required>
                    </li>

                    <li>
                        <label for=major>Major</label>
                        <input id=major name=major type=text placeholder="Eg. Business" >
                    </li>

                    <li>
                        <label for=phone>Phone</label>
                        <input id=phone name=phone type=tel placeholder="Eg. +447500000000" >
                    </li>

                    <li>
                        <label for=current_stage>Current Stage</label>
                        <input id=current_stage name=current_stage type=text placeholder="Eg.Newbie" required>
                    </li>

                    <li>
                        <label for=current_team>Current Team</label>
                        <input id=current_team name=current_team type=text placeholder="Eg.External Relations">
                    </li>

                    <li>
                        <label for=date_joined>Date Joined</label>
                        <input id=date_joined name=date_joined type=text placeholder="Eg. 08/24/2012" required>
                    </li>
                    </ol>

            </fieldset>

            <fieldset>

                <button type=submit >Save Member</button>


            </fieldset>

        </form>
      </div>
    </body>

How i retrieve $_SESSION[‘user_id’] in my login php

 if($stmt->num_rows==1){                    
        echo $myusername . " ";
        session_register("myusername");
        session_register("mypassword");

        $_SESSION['user_id']=$user_id;
        $_SESSION['username'] = $myusername;
        session_write_close();
        header("location:login_success.php");

    }

addmember.php:

<?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);

    session_start();


if(isset( $_SESSION['user_id'])){


    $mysqli = new mysqli('localhost', 'root', 'password', 'aiesec');

    if(mysqli_connect_errno()) {
        echo "Connection Failed: " . mysqli_connect_errno();
        exit();
    }


    $stmt = $mysqli -> prepare("INSERT INTO general_info (First Name, Last Name, University, Major, Current_Level, Date_Joined, Current_Team, added_by, Phone, Email) VALUES (?,?,?,?,?,?,?,?,?,?)") 

    $stmt -> bind_param("sssssssiss", $First_Name, $Last_Name,$University,$Major, $Current_Level, $Date_Joined, $Current_Team, $added_by, $Phone, $Email);

    $First_Name=$_POST['first_name'];
    $Last_Name=$_POST['last_name'];
    $University=$_POST['university'];
    $Major=$_POST['major'];
    $Current_Level=$_POST['current_stage'];
    $Date_Joined=$_POST['date_joined'];
    $Current_Team=$_POST['current_team'];

    $added_by=$_SESSION['user_id'];

    $Phone=$_POST['phone'];
    $Email=$_POST['email'];

    $stmt -> execute();

    printf("%d Row inserted.\n", $stmt->affected_rows);

    printf("Errormessage: %s\n", $stmt->error);

    $stmt->close();

    $mysqli->close();

}
else{

    printf("Nope\n"); 
    header("location:main_login.php");

}

    ?>

If I remove all the code and put echo to see $_SESSION['user_id'] output is 1 so if statement works.

I guess problem line might be $added_by=$_SESSION['user_id']; but I am not sure.

How can I fix insert or How can I see the error?

Thanks in advance for any suggestions.

—–EDIT SOLUTION——-
Simplest mistake of all times

I have changed First Name and Last Name to First_Name and Last_Name

I forgot to put semicolon at end of the line
$stmt = $mysqli -> prepare("INSERT INTO general_info (First Name, Last Name, University, Major, Current_Level, Date_Joined, Current_Team, added_by, Phone, Email) VALUES (?,?,?,?,?,?,?,?,?,?)")

after putting semicolon script added the row to the database

  • 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-07T07:08:17+00:00Added an answer on June 7, 2026 at 7:08 am

    you have an errors in your code

    look on

    $First Name, $Last Name
    

    you need to have an underscore in variables name like:

    $First_Name, $Last_Name 
    

    look in the manual

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

Sidebar

Related Questions

When trying to INSERT data into a database table, I've been getting the following
I've been trying to get a shell(bash) script to insert a row into a
I am relatively new to Perl.I have been trying to insert data to database
So I've been trying to insert sql into this one specific table for the
I have been trying to get the syntax of following query right but it
I have been trying for almost a week now to create an SQLite database
I am trying to insert a future date into a MySQL table from PHP.
I've been trying to load multiple files into a table, so that they would
I'm trying to delete a row from my table view and so far have
I have been trying to compress and store a json encoded string into mysql,

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.