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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:08:57+00:00 2026-06-01T02:08:57+00:00

I have a situation with my php code. In a previous page the user

  • 0

I have a situation with my php code. In a previous page the user enters in their username. Now when they submit the form, the username is posted and echo on the current page.

E.G if the teacher entered in ‘j.lu’ as the username, it posts ‘j.lu’ on the current page.

But what I want to do is that I want the insert the teacher’s Id in the database. To do this I set up a query to select the teacher’s Id by finding it’s username. So ‘j.lu’ has a TeacherId ‘T1’ but it does not display this is the field when inserted. Instead it states ‘SEL’ in the field.

So my question is that what does ‘SEL’ mean and how can I fix it so instead of saying ‘SEL’ it will state the teacher’s id which in this example is ‘T1’.

Below is code of the query, insert and the echo:

$teacherid = "SELECT TeacherId FROM Teacher WHERE (TeacherUsername = '".mysql_real_escape_string($_SESSION['teacherusername'])."')";

echo $_SESSION['teacherusername'];

$sql="INSERT INTO Session (TeacherId)
VALUES
(' ". mysql_real_escape_string( $teacherid ) . "')";

mysql_query($sql);
  • 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-01T02:08:58+00:00Added an answer on June 1, 2026 at 2:08 am

    SEL are the first three chars of the word SELECT as the query you run is

    INSERT INTO Session (TeacherId) VALUES ('SELECT TeacherId FROM Teacher WHERE ...
    

    You need to change the $teacherid content:

    $teacherid =mysql_real_escape_string($_SESSION['teacherusername']);
    
    // the escape is already done
    $sql = "INSERT INTO Session (TeacherId) VALUES ('$teacherid')";
    
    mysql_query($sql);
    

    As far you have a table called Session …

    edit

    Instead of using the username as is, the you have to execute the first query:

    $sql = "SELECT TeacherId FROM Teacher WHERE (TeacherUsername = '" 
         . mysql_real_escape_string($_SESSION['teacherusername'])."')";
    $rs = mysql_query($sql);
    $record = mysql_fetch_array($rs);
    $teacherid = $record['TeacherId'];
    
    $sql = "INSERT INTO Session (TeacherId) VALUES ('$teacherid')";
    mysql_query($sql);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have situation like this: user submits form with action='/pay' in '/pay' I have
The situation is next: I have php file, which parses a web-page. on that
Okay, here is my situation. I have a page, index.php, which is the mainsite
CODE HERE: http://jsfiddle.net/B7Y43/ Hello fello programmers, I have the following situation: My PHP-script generates
I have a situation. I read in a html page using php using this
I have a situation like this. <php> <redirect the page > <exit> <javascript> <redirect
I have a simple situation here. lets face html code first => <form name=geoKey
I have the following situation. I have a PHP script that imports a CSV
I have situation where a user can manipulate a large set of data (presented
Say currently I have url like : http://mydomain.com/showpost.php?p=123 Now I want to make it

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.