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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:33:44+00:00 2026-06-09T11:33:44+00:00

This should be so simple but it’s driving me crazy. I’m trying to insert

  • 0

This should be so simple but it’s driving me crazy. I’m trying to insert some values into a database from some form fields, but only decimals are being saved. I’m very confused.

For example, this will echo out correct values from the form fields, so I know those values are being passed along…

echo "Trying to insert $posttime, $name, $agency, $message"; 
// The above correctly outputs this: Trying to insert 1344548784, Mike, Test, Test 

But the SQL query below only works if I use numbers in the text fields, nothing else works. (I’m using phpmyadmin to confirm)

mysql_query("INSERT INTO mytable (id, from_name, from_agency, message) VALUES ($posttime, $name, $agency, $message)");

As a test, this query DOES work when I hard-code the values. I’m so confused…

mysql_query("INSERT INTO mytable (id, from_name, from_agency, message) VALUES (1344548784, 'Mike', 'Test', 'Test')");
  • 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-09T11:33:45+00:00Added an answer on June 9, 2026 at 11:33 am

    Encapsulate your text fields with quotes when inserting data. Even though they are variables in PHP, you need to tell the database that they are strings – which is done with quotes.:

    mysql_query("INSERT INTO mytable (id, from_name, from_agency, message) VALUES ($posttime, '$name', '$agency', '$message')");
    

    Also, the mysql_* functions really are a bit dated, you should really look at moving to PDO or mysqli.

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

Sidebar

Related Questions

I think this should be simple but I am having some difficulty implementing it.
This should be pretty simple but for some reason I can't get this value
This should be simple but it's not working. I am trying to strip single
This should be really simple but for some reason I'm stumped on this... I'm
This should be really simple but for some reason I can't seem to get
This should be simple but is boggling me for some reason. I'm sure it's
This should be simple but for some reason I'm stuck. I have data that
This should be simple but I'm having trouble changing some C code that uses
This should be really simple but what i'm doing is pulling data from a
This should be simple task but i am not been able to find the

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.