Error (20024)

Alles, was den Apache betrifft, kann hier besprochen werden.

Error (20024)

Postby Patoue » 18. November 2009 21:14


I'm trying to run an Insert query on mysql with php. I get the Error 403 Access forbidden!
Checking the error log, I get the following
Code: Select all
(20024)The given path is misformatted or contained invalid characters: Cannot map POST /%3Cphp?=$_SERVER[%27PHP_SELF%27]?%3E HTTP/1.1 to file

What am I doing wrong?
I'm pretty new at this and I'm trying for follow an online tutorial. I simply copied what was given.

Php code:
Code: Select all
<basefont face="Arial">


if (!isset($_POST['submit'])) {
// form not submitted

    <form action="<php?=$_SERVER['PHP_SELF']?>" method="post">
    Country: <input type="text" name="country">
    National animal: <input type="text" name="animal">
    <input type="submit" name="submit">

else {
// form submitted
// set server access variables
    $host = "localhost";
    $user = "superuser";
    $pass = "mypw";
    $db = "mydb";
// get form input
    // check to make sure it's all there
    // escape input values for greater safety
    $country = empty($_POST['country']) ? die ("ERROR: Enter a country") : mysql_escape_string($_POST['country']);
    $animal = empty($_POST['animal']) ? die ("ERROR: Enter an animal") : mysql_escape_string($_POST['animal']);

    // open connection
    $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
    // select database
    mysql_select_db($db) or die ("Unable to select database!");
    // create query
    $query = "INSERT INTO symbols (country, animal) VALUES ('$country', '$animal')";
    // execute query
    $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
    // print message with ID of inserted record
    echo "New record inserted with ID ".mysql_insert_id();
    // close connection


Thanks for your help!
Posts: 2
Joined: 18. November 2009 20:38

Re: Error (20024)

Postby Wiedmann » 18. November 2009 21:59

Code: Select all
<form action="<php?=$_SERVER['PHP_SELF']?>" method="post">

Code: Select all
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
AF Moderator
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Error (20024)

Postby Patoue » 19. November 2009 20:51

Thanks - it works perfectly!
Posts: 2
Joined: 18. November 2009 20:38

Return to Apache

Who is online

Users browsing this forum: No registered users and 18 guests