1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

SQL, php problem with drop box

Discussion in 'Web Design & Development' started by memccool, Aug 13, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. memccool

    memccool Thread Starter

    Joined:
    Aug 13, 2012
    Messages:
    1
    Ok so I have a script that I am writing and I have encounted a problem. I can not get the information from a dropbox to submit into mysql data base here is my script.


    <form action="work.php" method="post">


    <table>
    <tr>
    <td>Email:</td>
    <td><input type="text" name="Email" tabindex="1" />
    </td>
    </tr>

    <tr>
    <td>Messgae:</td>
    <td><textarea name="Message"
    rows = "7"
    cols = "35"
    tabindex = "2" /></textarea>
    </td>
    </tr>


    <tr>
    <Td>Time</td>

    <td>
    <select name="hour" tabindex="3">
    <option value="1">1AM</option>
    <option value="2">2AM</option>
    <option value="3">3AM</option>
    <option value="4">4AM</option>
    <option value="5">5AM</option>
    <option value="6">6AM</option>
    <option value="7">7AM</option>
    <option value="8">8AM</option>
    <option value="9">9AM</option>
    <option value="10">10AM</option>
    <option value="11">11AM</option>
    <option value="12">12PM</option>
    <option value="13">1PM</option>
    <option value="14">2PM</option>
    <option value="15">3PM</option>
    <option value="16">4PM</option>
    <option value="17">5PM</option>
    <option value="18">6PM</option>
    <option value="19">7PM</option>
    <option value="20">8PM</option>
    <option value="21">9PM</option>
    <option value="22">10PM</option>
    <option value="23">11PM</option>
    <option value="24">12AM</option>
    </select><br>
    <input type="submit" name="formSubmit" value="Submit" >
    </form>


    And then here is work.php

    <?php
    $time = $_POST['hour'];
    $email1 = $_POST['Email'];
    $message1 = $_POST['Message'];

    mysql_connect ('localhost', my'user', 'mypassword') or die ('Error: ' .mysql_error());
    mysql_select_db ("mydatabase");

    $query="INSERT INTO Reminder (Email, Message, Time)
    VALUES
    ('$email1','$message1','$time')";
    mysql_query($query) or die ('Error submitting');

    echo "You Chose: " .$time ;

    ?>
     
  2. dukevyner

    dukevyner

    Joined:
    Nov 4, 2011
    Messages:
    787
    Welcome to T.S.G, i have looked over your script, and tested it... it seems to be working fine, i did not encounter and issue... this can be seen at http://channeljackers.co.cc/tet1.html no change were mad to your code(other than removing the database connection, cause i don't have one for it)
     
  3. janikPilot

    janikPilot

    Joined:
    Nov 26, 2010
    Messages:
    141
    ^ I was thinking the same thing.

    The error must therefore reside in your MySQL database. Ensure the column names match and collaborate properly with the script.
     
  4. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    2,058
    Isn't "Time" or "time" a mySQL reserved word? Try a back-tick (`) in your $query= syntax, perhaps?
     
  5. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    2,058
    No it doesn't seem to be a reserved word, but as previously mentioned, the problem is almost certainly your database column names ...
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1064940