Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Just a blank screen

  1. #1
    Join Date
    Mar 2008
    Posts
    25
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Just a blank screen

    I am wanting to make a database app. Very simple. I just need to be able to enter information into a database, delete it and show it.

    I've gotten the show part.

    I am working on the insert part and I am stuck. I have a very simple HTML form with about 9 fields.

    I am using a MS Access database and PHP.

    This is my processing file:

    PHP Code:
    <?php
    $requester
    =$_Post['Requester']
    $owner=$_Post['Owner']
    $makemodel=$_Post['MakeModel']
    $serialno=$_Post['SerialNo']
    $received=$_Post['Received']
    $shipped=$_Post['Shipped']
    $ticketno=$_Post['TicketNo']
    $notes=$_Post['Notes']



    if ( !( 
    $database odbc_connect"Warranty""","")))
    die( 
    "Could not connect to database" ); 



    $stmt odbc_prepare($database"INSERT INTO WarrantyInformation (Requester, Owner, MakeModel, SerialNo, Received, Shipped, TicketNo, Notes) VALUES('$requester','$owner', '$makemodel', '$serialno', '$received', '$shipped', '$ticketno', '$notes');" ); 

    if (!
    odbc_execute$stmt))

    {

    echo 
    "Whoops";

    }
    When I go to the form page and fill it in and click SUBMIT, I get a blank page and the DB is not updated. If I turn on the Friendly Warning in IE it just gets me a 500 Internal Server error.

    I am using Xitami as the webserver and it processes other PHP stuff just fine. What am I doing wrong?

    Thanks,

    JRF2k

  2. #2
    Join Date
    Feb 2008
    Location
    Coventry
    Posts
    103
    Thanks
    5
    Thanked 8 Times in 8 Posts

    Default

    You need to put a ';' at the end of your variables that are set to the posted data.
    sooo like this,
    Code:
    $requester=$_Post['Requester'];
    $owner=$_Post['Owner'];
    $makemodel=$_Post['MakeModel'];
    $serialno=$_Post['SerialNo'];
    $received=$_Post['Received'];
    $shipped=$_Post['Shipped'];
    $ticketno=$_Post['TicketNo'];
    $notes=$_Post['Notes'];
    Also i duno if its just you havent included it, but the closing ?> php tag. Duno just a suggestion
    The important thing is not to stop questioning. Curiosity has its own reason for existing.

  3. The Following User Says Thank You to city_coder For This Useful Post:

    JRF2k (03-19-2008)

  4. #3
    Join Date
    Mar 2008
    Posts
    25
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Entry is blank spaces

    When I run the code below, I get the next autonumber in the DB, but there is no data in there. I've rechecked all my variables and I can't see anything wrong. It just writes blanks and then autonumbers. What am I missing?


    Here is my HTML Form:

    Code:
    <html>
    <head><title></title></head>
    <body>
    <FORM action="insertintodb.php" method="post">
    Requester: <input type="text" name="requester"></br>
    Owner:<input type="text" name="owner"></br>
    Make/Model:<input type="text" name="makemodel"></br>
    Serial Number:<input type="text" name="serialno"></br>
    Received:<input type="text" name="received"></br>
    Shipped:<input type="text" name="shipped"></br>
    Ticket Number:<input type="text" name="ticketno"></br>
    Notes/Commnets:<input type="text" name="notes"></br>
    <input type="Submit" name="Enter"><input type="reset"></br>
    </FORM>
    </body>
    </html>
    and here is the PHP:

    PHP Code:
    <?php
    $requester
    =$_Post['requester'];
    $owner=$_Post['owner'];
    $makemodel=$_Post['makemodel'];
    $serialno=$_Post['serialno'];
    $received=$_Post['received'];
    $shipped=$_Post['shipped'];
    $ticketno=$_Post['ticketno'];
    $notes=$_Post['notes'];



    if ( !( 
    $database odbc_connect"Warranty""","")))
    die( 
    "Could not connect to database" ); 



    $stmt odbc_prepare($database"INSERT INTO WarrantyInformation (Requester, Owner, MakeModel, SerialNo, Received, Shipped, TicketNo, Notes) VALUES('$requester','$owner', '$makemodel', '$serialno', '$received', '$shipped', '$ticketno', '$notes');" ); 

    if (!
    odbc_execute$stmt))

    {

    echo 
    "Whoops";

    }

    ?>

  5. #4
    Join Date
    Mar 2008
    Posts
    25
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    Thanks! That was it.

    I SHOULD have seen that!

    That got it working, somewhat anyway. I have a new post about now the Access DB will autonumber but no data is inserted. If you can help, please do. I can't see anything wrong with the code.

  6. #5
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Code:
    <FORM action="insertintodb.php" method="post">
    Requester: <input type="text" name="requester" value=""></br>
    Owner:<input type="text" name="owner" value=""></></br>
    Make/Model:<input type="text" name="makemodel" value=""></></br>
    Serial Number:<input type="text" name="serialno" value=""></></br>
    Received:<input type="text" name="received" value=""></></br>
    Shipped:<input type="text" name="shipped" value=""></></br>
    Ticket Number:<input type="text" name="ticketno" value=""></></br>
    Notes/Commnets:<input type="text" name="notes" value=""></></br>
    <input type="Submit" name="Enter"><input type="reset"></br>
    </FORM>
    insert value into your form

    change
    $_Post['var']
    to
    Code:
    $_POST['var']

  7. #6
    Join Date
    Feb 2008
    Location
    Coventry
    Posts
    103
    Thanks
    5
    Thanked 8 Times in 8 Posts

    Default

    Anytime i made a simple mistake of leaving out an equals in html and when you send that through it doesnt work....we all do it.

    Think boogyman got there before i did. He seems to have it cracked, thats what i would have suggested.
    The important thing is not to stop questioning. Curiosity has its own reason for existing.

  8. The Following User Says Thank You to city_coder For This Useful Post:

    JRF2k (03-19-2008)

  9. #7
    Join Date
    Mar 2008
    Posts
    25
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    Thank you! That got it working wonderfully.

    If you don't mind me asking another basic question.

    How would I add links on my output page that would allow deleting of records?

    Here is that page:

    PHP Code:
    <html>
    <body><?php
    $conn
    =odbc_connect('Warranty','','');
    if (!
    $conn)
      {exit(
    "Connection Failed: " $conn);}
    $sql="SELECT * FROM WarrantyInformation";
    $rs=odbc_exec($conn,$sql);
    if (!
    $rs)
      {exit(
    "Error in SQL");}
    echo 
    "<table border=1>";
    echo 
    "<tr><th>Requester</th>";
    echo 
    "<th>Owner</th>";
    echo 
    "<th>Make/Model</th>";
    echo 
    "<th>Serial Number</th>";
    echo 
    "<th>Recieved</th>";
    echo 
    "<th>Shipped</th>";
    echo 
    "<th>Ticket Number</th>";
    echo 
    "<th>Notes/Comments</th></tr>";

    while (
    odbc_fetch_row($rs))
    {
      
    $requester=odbc_result($rs,"Requester");
      
    $owner=odbc_result($rs,"Owner");
      
    $makemodel=odbc_result($rs,"MakeModel");
      
    $serialno=odbc_result($rs,"SerialNo");
      
    $received=odbc_result($rs,"Received");
      
    $shipped=odbc_result($rs,"Shipped");
      
    $ticketno=odbc_result($rs,"TicketNo");
      
    $notes=odbc_result($rs,"Notes");
      echo 
    "<tr><td>$requester</td>";
      echo 
    "<td>$owner</td>";
      echo 
    "<td>$makemodel</td>";
      echo 
    "<td>$serialno</td>";
      echo 
    "<td>$received</td>";
      echo 
    "<td>$shipped</td>";
      echo 
    "<td>$ticketno</td>";
      echo 
    "<td>$notes</td></tr>";

      
    }
    odbc_close($conn);
    echo 
    "</table>";
    ?></body>
    </html>

  10. #8
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    same way you assign any other links, however this would need extra security to be sure that the person has the correct level of administrative access to perform this deletion action. the only way to "undo" a delete is from a backup, which means dumping your database.

    you assign the link to an anchor tag and use a get variable to assign the exact record you wish to delete,and once clicked, that script would perform a query to delete the record
    Code:
    DELETE FROM table WHERE condition;

  11. #9
    Join Date
    Mar 2008
    Posts
    25
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default

    Thanks again!

    The page that will contain that will be password protected.

    Thanks for all the help. I am almost done.

    So, the command will be "DELETE FROM WarrantyInformation WHERE Requester =".$_POST['Requester']";

    How would I just delete the entire record? Would I need to refer to it by the autonumer or something like that?

    The link itself is: <a ... umm...!! STUCK AGAIN!

    Looked around on Google but I can't see to find anything that explains it.
    Last edited by JRF2k; 03-19-2008 at 05:18 PM.

  12. #10
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    http://dev.mysql.com/doc/refman/5.0/en/delete.html
    delete syntax


    two helpful references are
    PHP Reference Manual - http://php.net
    MySQL Reference Manual - http://dev.mysql.com/doc/refman/5.0/en/

Bookmarks

Posting Permissions

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