问题
Every time I hit the submit button to process this code in my webpage it goes to the Object Not Found (404 error) page. It has happened in a few of my scripts and i don't know the source of the problem of whether its my localhost(Xampp) or my code.
if (isset($_POST['submit']))
{
require "dbc.php"; //Connection to database
//the textfield input to be saved
$name = mysql_real_escape_string($_POST['assign_id']);
$id = mysql_real_escape_string($_POST['id']);
//the mysql query to process the textfield input
$query = mysql_query("UPDATE users SET docID='$assign_id' WHERE id='$id'");
//normal statement to let the user know that the changes have been made.
echo "Doctor ID Successfully Assigned for Patient ID : $name ";
echo "<p>Refresh page to view changes.</p>";
}
回答1:
You are using $assign_id in your query, where you get the $_POST['assign_id'] earlier and store it to $name.
Try changing $assign_id in your query to $name.
or
Try changing you variable $name to $assign_id.
EDIT
Another thing to check, is the file dbc.php in the same directory as this file?
EDIT 2
Post the contents of your apache2/error.log file. That will show what file was not found.
EDIT 3
Post the code for you <form> opening tag. What is your action set to? Does the action file actually exist?
回答2:
404 is an HTTP error code, it has nothing to do (directly) with PHP.
It means that the server is not able to locate a file that matches with your request.
Essentially, it looks like you're requesting http://yourdomain.com/path/to/script.php when you submit your form, but the /path/to/script.php file doesn't exist.
回答3:
When pressing submit on a form, the server tries to find the 'action' of the form. You should check that this action contains a valid filename in a correct path.
回答4:
When pressing submit on a form, the server tries to find the 'action' of the form. You should check that this action contains a valid filename in a correct path.Always it shows error..
来源:https://stackoverflow.com/questions/15978782/object-not-found-error-for-simple-php-script