Witam,
Ponizej jest kod na którym pracuje, nic wielkiego, uzytkownik wpisuje pare rzeczy które php potem przekazje MySQLowi:
<html>
<head><title>Add a Hirer!</title>
</head>
<body background="img19.gif">
<center>
<p1><B>Add a New Hirer to the Village Hall Booking System!</B></p1>
</center>
<form action="
<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<br><table><tr><td width="200">
Title</td><td width="200"><select name="title">
<option>Choose
<option>Doctor
<option>Father
<option>Master
<option>Miss
<option>Mr
<option>Mrs
<option>Professor
<option>Sister
</select>
</td><td width="200"><b>Further Details</b></td></tr>
<tr><td width="200">
Surname</td><td width="150"><input type="text" name="surname"><br></td><td width="200">Time of Booking:</td>
<td width="200"><select name="Time">
<option selected>Choose
<Option>Morning
<Option>Afternoon
<Option>Evening
<Option>Evening Extension
</select>
</td></tr><tr><td width="200">Forename</td><td width="200"><input type="text" name="forename"></td>
<td width="200">Type of Booking:</td><td width="200"><select name="Type">
<option selected>Choose
<option>Chess Club
<option>Cubs & Scouts
<option>Golden Wedding Anniversary
<option>Guides & Brownies
<option>Line Dancing
<option>Play Group
<option>Silver Wedding Anniversary
<option>Women's Institute
<option>18th Birthday Party
<option>Other
</select>
</td></tr><tr><td width="200">Street Number</td><td width="200"><input type="text" name="street_number"></td>
<td width="200">Date:</td><td width="200">
<select name="DateNumber">
<option selected>1
<option>2
<option>3
<option>4
<option>5
<option>6
<option>7
<option>8
<option>9
<option>10
<option>11
<option>12
<option>13
<option>14
<option>15
<option>16
<option>17
<option>18
<option>19
<option>20
<option>21
<option>22
<option>23
<option>24
<option>25
<option>26
<option>27
<option>28
<option>29
<option>30
<option>31
<option>32
</select>
<select name="DateMonth">
<option selected>January
<option>February
<option>March
<option>April
<option>May
<option>June
<option>July
<option>August
<option>September
<option>October
<option>November
<option>December
</select>
<select name="DateYear">
<option selected>2005
<option>2006
<option>2007
</select>
</td></tr><tr><td width="200">Street Name</td><td width="200"><input type="text" name="street_name"></td>
<td width="200">Day Of Week:</td><td width="200"><select name="Day_of_week">
<option selected>Choose
<option>Monday
<option>Tuesday
<option>Wednesday
<option>Thursday
<option>Friday
<option>Saturday
<option>Sunday
</select>
</td></tr><tr><td width="200">Town/City</td><td width="200"><input type="text" name="town_city"></td>
<td width="200">Regular Customer:</td><td width="200"><select name="Regular">
<option selected>Choose
<option>Yes
<option>No
</select>
</td></tr><tr><td width="200">County</td><td width="200"><input type="text" name="county"></td>
<td width="200">Paid:</td><td width="200"><select name="Paid">
<option selected>Choose
<option>Yes
<option>No
</select>
</td></tr><tr><td width="200">Post Code</td><td width="200"><input type="text" name="PostCode">
</td></tr><tr><td width="200">Home Tel. No.</td><td width="200"><input type="text" name="home_tel">
</td></tr><tr><td width="200">Mobile Tel. No.</td><td width="200"><input type="text" name="mobile_tel">
</td></tr><tr><td width="200">Email</td><td width="200"><input type="text" name="email">
</td></tr>
</table>
<br><br><input type="submit" value="Submit"><br><br>
</form>
<font color="orange"><font size="4"><B>
<?php
$Time = $_REQUEST['Time'];
$Price = $_REQUEST['Price'];
$Regular = $_REQUEST['Regular'];
$Paid = $_REQUEST['Paid'];
$Type = $_REQUEST['Type'];
$Day_of_week = $_REQUEST['Day_of_week'];
if ($Type == 'Golden Wedding Anniversary' OR $Type == 'Silver Wedding Anniversary' OR $Type == '18th Birthday Party' AND $Day_of_week == 'Friday' OR $Day_of_week == 'Saturday' AND $Time == 'Evening') {
$Price="10.00";
echo "Your booking qualifies for our special rate of 10.00 pounds including the e
vening extension!";
}
elseif ($Time == 'Morning') {
$Price="12.00";
echo "The price is 12.00 pounds.";
}
elseif ($Time == 'Afternoon') {
$Price="12.00";
echo "The price is 12.00 pounds.";
}
elseif ($Time == 'Evening') {
$Price="15.00";
echo "The price is 15.00 pounds.";
}
elseif ($Time == 'Evening Extension') {
$Price="5.00";
echo "The price is 5.00 pounds.";
}
else {
echo "The price will be quoted based on your selection.";
}
if ($Regular == 'Yes') {
$Regular="Yes";
}
else {
$Regular="No";
}
if ($Paid == 'Yes') {
$Paid="Yes";
}
else {
$Paid="No";
}
?>
<br>
<?php
if (!$dbcnx) {
exit('<p>Unable to connect to the database server at this time.</p>'); }
exit('<p>Unable to locate the Village Hall database at this time.</p>'); }
if (isset($_POST['title'])) {
$title = $_POST['title'];
$surname = $_POST['surname'];
$forename = $_POST['forename'];
$street_number = $_POST['street_number'];
$street_name = $_POST['street_name'];
$town_city = $_POST['town_city'];
$county = $_POST['county'];
$PostCode = $_POST['PostCode'];
$Home_Tel = $_POST['home_tel'];
$Mobile_Tel = $_POST['mobile_tel'];
$email = $_POST['email'];
$Time = $_POST['Time'];
$Type = $_POST['Type'];
$DateNumber = $_POST['DateNumber'];
$DateMonth = $_POST['DateMonth'];
$DateYear = $_POST['DateYear'];
$Price = $_POST['Price'];
$Regular = $_POST['Regular'];
$Paid = $_POST['Paid'];
$sql = "INSERT INTO Hirer SET
title='$title',
surname='$surname',
forename='$forename',
street_number='$street_number',
street_name='$street_name',
town_city='$town_city',
county='$county',
PostCode='$PostCode',
Home_Tel='$Home_Tel',
Mobile_Tel='$Mobile_Tel',
Email='$email'
Time='$Time',
Type='$Type',
DateNumber='$DateNumber',
DateMonth='$DateMonth',
DateYear='$DateYear',
Day_of_week='$Day_of_week',
Price='$Price',
Regular='$Regular',
Paid='$Paid'";
echo '<p>Your Hirer & Booking Details have been added.</p>'; } else {
echo '<p>Error submitting hirer details: ' . }
}
?>
<br><a href="mainpage.php"> Back to Main Page</a>
</body>
</html>
Ta stronka juz mi wczesniej dzialala w 100%, tyle ze potem dodalem pare dodatkowych informacji które maja znalezc sie w bazie danych, wszystkie te po $_POST['Email'].
I teraz problem, przestalo dzialac i wyrzuca mi taki blad:
<?php
Error submitting hirer details
: You have an error in your SQL syntax
; check the manual that corresponds to your
MySQL server version
for the right syntax to use near
'Time='Choose
' Type='Choose
' DateNumber='1' DateMonth='January
' DateYear=' at line
13
?>
Widze ze cos jest nie tak z tymi nowymi informacjami które dodalem ale siedzie juz nad tym od wczoraj i przegladam caly kod nie widzac co jest nie tak.
Bylbym naprawde wdzieczny gdyby którys ze znawców mógl pokazac w czym problem (IMG:
http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Pozdrawiam.