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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:38:16+00:00 2026-05-15T07:38:16+00:00

$from = $_POST[‘from’]; $to = $_POST[‘to’]; $message = $_POST[‘message’]; $query = SELECT * FROM

  • 0
$from = $_POST['from'];
$to = $_POST['to'];
$message = $_POST['message'];

$query  = "SELECT * FROM Users WHERE `user_name` = '$from' LIMIT 1";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $fromID = $row['user_id'];
} 

I’m trying to have $formID be the user_id for a user in my database. Each row in the Users table is like:

user_id | user_name | user_type
   1    |  Hristo   |   Agent

So I want $from = 1 but the above code isn’t working. Any ideas why?

  • 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-05-15T07:38:17+00:00Added an answer on May 15, 2026 at 7:38 am

    Try this:

    $from = mysql_real_escape_string($_POST['from']);
    $to = mysql_real_escape_string($_POST['to']);
    $message = mysql_real_escape_string($_POST['message']);
    
    $query  = "SELECT * FROM Users WHERE user_name = '$from' LIMIT 1";
    $result = mysql_query($query) or die(mysql_error());
    
    while($row = mysql_fetch_assoc($result)) {
        $fromID = $row['user_id'];
    }
    

    Also, make sure that:

    • You have connected to the database
    • You do get data from the post, try var_dump with your vars eg var_dump($from)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 495k
  • Answers 495k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When you load an image with Loader it is stored… May 16, 2026 at 11:17 am
  • Editorial Team
    Editorial Team added an answer Here is a sample Rectangle that I borrowed from MSDN.… May 16, 2026 at 11:17 am
  • Editorial Team
    Editorial Team added an answer Your code doesn't work via normal import either. >>> from… May 16, 2026 at 11:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

say I have this $result = mysql_query('SELECT views FROM post ORDER BY views ASC');
I have an array ($form) which retreives some information from $_POST: $form = $_POST['game'];
I am currently running into a problem where an element is coming back from
After processing form from POST I should redirect, to prevent user from hitting back.
I put the variables email and password from POST to GET such that Part
Visual studio 2005: I am moving from post build event to using the external
I want to receive multi file post from image uploader.( i use this )
I am trying to get some form data from POST method. Here's the code
basically i want to hold a parameter that retrieve value from $.post() call like
We have a client unable to switch a form from POST to GET, at

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.