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

  • Home
  • SEARCH
  • 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 6528415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:31:56+00:00 2026-05-25T09:31:56+00:00

Hello I cannot figure out what is wrong with my code. Have not much

  • 0

Hello I cannot figure out what is wrong with my code. Have not much experience with php yet. Can someone please tell me what am I doing wrong??

Here is my code:

<?php
   include 'mysql_connect.php';
if (!isset($_POST['submit'])) {
    $fuelQuery2 = sprintf("UPDATE fuel_price SET `Price` = '%s' WHERE FuelType = '%s' LIMIT 1",
                        mysql_real_escape_string($_POST['inputPrice']),
                        mysql_real_escape_string($_POST['fueltype']));

    $Result = mysql_query($fuelQuery2);
    if($Result){
        echo 'Price has been updated!';
    } else{
        echo 'Failed to update price!';
    }
} else{
    echo 'No form submitted';
}


?>

<h1>Update Oil Price</h1>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Oil Price:<input name="inputPrice" type="text" value=""/>

Product
<select name="fueltype">
<option value="Oil">Kero</option>
<option value="Diesel">Diesel</option>
<option value="RedDiesel">Red Diesel</option>
</select>

<input type="submit" name="submit" value="Modify" />
</form>
  • 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-25T09:31:57+00:00Added an answer on May 25, 2026 at 9:31 am

    It’s really simple, change

    if (!isset($_POST['submit'])) {
    

    to

    if(isset($_POST['submit'])) { //Only execute the query when the form is submitted
    

    Your original code told PHP to execute the query when the form wasn’t submitted (notice that I removed the !) instead of when it was. The notices you were getting were telling you that the $_POST variables you grabbed for your query didn’t exist (because the code ran before the form was submitted).

    Also, do look into PDO. The mysql_ family of functions is no longer the preferred method for interacting with the database layer.

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

Sidebar

Related Questions

foo\r\nbar.replace(/(foo).+/m, bar) Hello. I can not understand why this code does not replace foo
Hello I cannot figure out why I get this error. I've got a list
so im practicing the STL string class, but i can not figure out why
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
HEllo , i can not find any way to get horizontal or/and vertical resolution
Hello can anybody solve this please I'm creating the object in the action class
I'm embarrassed to ask this, but I cannot figure out how to run a
I cannot figure out what the hell is going on for the life of
I'm trying to figure out why this code doesn't work in C# and how
Hello in my aspx page using MVC 3, I have the following code: <%Response.WriteFile(/Content/Bing.htm);

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.