Results 1 to 14 of 14

Thread: could you take a look at my code and tell me what I did worng

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    could you take a look at my code and tell me what I did worng

    in poll.htm file:
    Code:
    <html>
    
    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Poll</title>
    <FONT face=Courier color=#ffcc00 size=2></FONT>
    <script language="Javascript">
    <!--
    
    function ValidateForm(form) {
      if (!form.Answer[0].checked && !form.Answer[1].checked) {
        alert("Please choose your answer before submitting!");
    	form.Answer[0].focus();
    	return false;
      }
    }
    //-->
    </script>
    </head>
    
    <body bgcolor="#008000">
    
    <pre><font face="Courier" color="#999999" size="2"></pre>
    <p></p>
    <center>
    <table cellpadding="15" cellspacing="0" border="1">
      <tr>
        <td bgcolor="#006666"><font face="Arial" size="2" color="#ffffff">Isn't my first PHP poll just excellent? </font></td>
      </tr>
      <tr>
        <td><font face="Arial" size="2" color="#ffffff"><font color="#ffcc00">
        <form name="Poll" onSubmit="return ValidateForm(this)" method="post" action="results.php">
          <input type="radio" name="Answer" value="1">Yes<br>
          <input type="radio" name="Answer" value="2">No<br>
          <br>
          <input type="submit" value="Submit"> <input type="reset">
        </form>
        </font><a href="results.php"><font face="Arial" size="2" color="#ffffff">see 
        the results </font> </a></font></td>
      </tr>
    </table>
    </center>
    <p></p>
    <pre></pre>
    </font>
    
    </body>
    
    </html>
    in results.php
    PHP Code:
    <html>
    <title>Poll results</title>
    <body>
    <center>
    <table cellpadding=15 cellspacing=0 border=1>
    <tr>
    <td bgcolor="#006666">
    <font face="Arial" size=2 color="#ffffff">
        Isn't my first PHP poll just excellent?
    </font>
    </td>
    </tr>

    <tr>
    <td>
    <font face="Courier" size=2 color="#ffffff">
    <body bgcolor="#008000">
    <?php 
    mysql_connect
    ("localhost""root");
    $query "SELECT votes from polldb WHERE answer_id = 1;";
    $result = (mysql_db_query("database"$query));
    $row mysql_fetch_array($result);
    $votes $row["votes"];
    echo
    "Yes: $votes vote(s)<br>";

    $query "SELECT votes from polldb WHERE answer_id = 2;";
    $result = (mysql_db_query("database"$query));
    $row mysql_fetch_array($result);
    $votes $row["votes"];
    echo
    "No: $votes vote(s)<br>";
    if (isset(
    $Answer)) {
        
    $query "UPDATE polldb SET votes=votes+1 
            WHERE answer_id = 
    $Answer;";
        
    $result mysql_db_query("database"$query);
    }
    ?>
    </td>
    </tr>

    </table>
    </center>
    </body>
    </html>
    When I run this code I'm getting 405 error: method not allowed for url /
    Any idea why it happens?

    Thanks

    Q

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    and which line is the error picked up on ?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Is your webserver configured to accept HTTP POSTs for PHP pages?
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    localhost and root are unneccessary in the db connect function...

  5. #5
    scoutt
    Guest
    Originally posted by da_silvy
    localhost and root are unneccessary in the db connect function...
    how is he suppose to connect to the database without signing on? only unneccessary if he isn't root. but what if he is doing it from his own computer?

    QWERTY, you say when you run the code, well which one?? the top one or the bottom one.


    and there is no 405 error, at least not according to this
    http://www.w3.org/Protocols/HTTP/HTRESP.html

  6. #6
    scoutt
    Guest
    look at this.


    $query = "SELECT votes from polldb WHERE answer_id = 1;";

    you don't need the first ; after the 1 take it out.

  7. #7
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    HTTP 1.1
    http://www.w3.org/Protocols/rfc2616/rfc2616.txt

    and there is no 405 error, at least not according to this
    From the link you posted: "This is a historic document and is not accurate anymore. For up-to-date details on the HTTP specification, see the latest HTTP/1.1 drafts "

    The 405 error means the server's not accepting the HTTP POST, which seems like a web server config problem than a programming problem to me...
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  8. #8
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Just to clarify / back that, this is from the current IIS :

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  9. #9
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Originally posted by scoutt

    how is he suppose to connect to the database without signing on? only unneccessary if he isn't root. but what if he is doing it from his own computer?

    QWERTY, you say when you run the code, well which one?? the top one or the bottom one.


    and there is no 405 error, at least not according to this
    http://www.w3.org/Protocols/HTTP/HTRESP.html
    If he is connecting as root and localhost, then they are unneccessary.

    I'm sure that vbulletin runs mysql off it's server - that would make it a local database.

    I assumed that he is root as he was connecting:
    "localhost","root"
    -> There is no need to sign on, you are automatically assigned root.

    I run mySQL on my computer.

    Maybe he wants to test his code (like me) or wants to run a web server ?

  10. #10
    scoutt
    Guest
    I see, but I run mysql for testing purposes too and I have to sign on. wouldn't let me run it unless I did. I can run mysql but to grab and put information I had to sign on. which doesn't bother me as I have to do it on my site as well.

    But the whole purpose to test for my site is so I don't have to change much if I run it on my computer to mysite. ie change passwords, user names, links, etc...

  11. #11
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Ahh ok

  12. #12
    scoutt
    Guest
    I guess he is not going to answer his own thread..... or we won't be able to see if it was the problem or not

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    Thanks for help guys. The problem was indeed with my server which wasn't properly configured to accept that kind of information. It works now thanks.

  14. #14
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    That's good.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width