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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:56:20+00:00 2026-06-04T14:56:20+00:00

I am a newbie in MySQL and PHP. I have a HTML form where

  • 0

I am a newbie in MySQL and PHP. I have a HTML form where I would like to pass 1 variable from to my PHP code and then run a query on my database for the record that holds that variable under the column ‘Serial’. I can run it fine when I hard code the ‘serial’ that I want to look up but when I try with the variable I get an error.

Any help would greatly be appreciated! Or a better way to do this.

Here is my error: Unknown column 'amg002' in 'where clause'

Here is my code;

$serial= $_POST['Serial'];
echo $serial;

//Connect To Database

$link = mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
echo "Connected to MySQL<br />";

//Select the database - 'SiteInfo'

// Collects data from "SiteInfo" table

//****This is where I am running into the error*** 

$sql = 'SELECT * FROM `SiteInfo` WHERE `Serial` ='.$serial; 

// This works!!!

//$sql = 'SELECT * FROM `SiteInfo` WHERE `Serial` ="amg002";';   

$data = mysql_query($sql)
or die(mysql_error());

// puts the "SiteInfo" info into the $info array

$info = mysql_fetch_array( $data );

//Print out the contents of the entry

echo "Site Name: ".$info['SiteName'] . "<br /";
Print "Serial Number: ".$info['Serial'] . "<br />";
Print "Location: ".$info['Location'] . "<br />";

// Close the database connection

mysql_close($link); 
echo "Connection Closed. <br />";
  • 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-04T14:56:21+00:00Added an answer on June 4, 2026 at 2:56 pm

    I agree its a quote issue, but here is how my code would look.

      $sql = 'SELECT * FROM SiteInfo WHERE Serial = "' . $serial . '"';
    

    or

      $sql = "SELECT * FROM 'SiteInfo; WHERE 'Serial' = \"$serial\"";      
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a newbie in PHP and MySQL i have written the code below
I am a newbie in php, mysql. I have written a hello.php script, which
I am a newbie in php. I have a form with multiple checkbox values.
Sorry, I want to ask a newbie question :) I have PHP scripts like
Mysql , php newbie here. Please be nice . I have a list of
I'm an absolute newbie to EC2. My goal is to run a php-mysql-website on
I'm newbie in php mysql and google maps v3. I have a problems in
Well, I have a simple page displaying records from Database with PHP & MySQL.
I am newbee with PHP and MySQL and need help... I have two tables
Newbie question about PostgreSQL. I'm migrating a MySQL/PHP app I've created, hosted on a

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.