Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Web Design & Development Web Design & Development
Search Search
Search for:
Tech Support Guy > > >

SQL, php problem with drop box


(!)

memccool's Avatar
memccool memccool is offline
Member with 1 posts.
THREAD STARTER
 
Join Date: Aug 2012
13-Aug-2012, 01:49 PM #1
SQL, php problem with drop box
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 ;

?>
dukevyner's Avatar
dukevyner   (Luke) dukevyner is offline
Computer Specs
Member with 787 posts.
 
Join Date: Nov 2011
Location: Pakenham, VIC, Australia
Experience: Advanced
14-Aug-2012, 10:05 PM #2
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)
janikPilot's Avatar
janikPilot   (Michael) janikPilot is offline
Computer Specs
Member with 141 posts.
 
Join Date: Nov 2010
Location: South FL
Experience: Advanced
14-Aug-2012, 10:13 PM #3
^ 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.
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,705 posts.
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
15-Aug-2012, 05:01 AM #4
Isn't "Time" or "time" a mySQL reserved word? Try a back-tick (`) in your $query= syntax, perhaps?
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,705 posts.
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
16-Aug-2012, 04:27 AM #5
No it doesn't seem to be a reserved word, but as previously mentioned, the problem is almost certainly your database column names ...
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑