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

Related Questions

say I have this $result = mysql_query('SELECT views FROM post ORDER BY views ASC');
I have a SQL query which retrieve wall post list $qry=mysql_query(SELECT senderid,post,date FROM .post_table.
Query: SELECT * FROM Post ORDER BY Post.rating <-- Here , i want (
I have this query: $query = SELECT *FROM wp_postmeta WHERE meta_key = '_isEvent' AND
I have been trying to run this query: my_post = db.GqlQuery(SELECT * FROM Post
$sql = SELECT * from post where forum_id = $_GET[id]; $result = mysqli_query($conn, $sql)
I have the following query: $count = (SELECT COUNT(*) FROM post GROUP BY ID
In the yabe example, there is this query : def allWithAuthor:List[(Post,User)] = SQL( select
I try using FQL Query to fetch count of share from post on facebook
How do I specify the parent query field from within a subquery in 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.