Niets in database gooien?
Ik heb een script waarbij input-velden zijn.
Als ik op submit druk hoort hij de waardes die ik meegeef in m'n database te gooien, echter doet hij dit niet;
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
if (isset($_GET["id"])){
$news_id = $_GET["id"];
$result = mysql_query("SELECT * FROM news WHERE id = $news_id ");
while (list($id, $uDatee, $subject, $creator, $time, $date, $content, $reactions) =
mysql_fetch_row($result)){
$uContent = $content;
$uContent = stripslashes($uContent);
$textbox = '
<form method="post" name="reaction">
<table>
<tr>
<td>Name:</td>
<td><input name="your_name" type="text" value="Your name!" class="default_input_field" /></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="your_email" type="text" value="Your E-Mail!" class="default_input_field" /></td>
</tr>
<tr>
<td valign="top">Reaction:</td>
<td><textarea name="your_reaction" rows="8" cols="64" class="default_input_field">Your reaction!</textarea></td>
</tr>
<tr>
<td valign="top"><input type="submit" name="submit" value="Submit" class="default_input_button"></td>
<td></td>
</tr>
</table>
</form>';
?>
<table border="0" cellspacing="5">
<tr>
<td width="400" valign="top" class="content">
<strong>NEWS: <?php echo "//" . $subject; ?></strong>
<hr class="content_hr" />
<table>
<tr>
<td class="user_text"><strong>Date</strong>:</td>
<td class="user_text" align="left"><?php echo $date; ?></td>
</tr>
<tr>
<td class="user_text"><strong>Creator:</strong></td>
<td class="user_text" align="left"><?php echo $creator ?></td>
</tr>
<tr>
<td align="left" class="user_text" valign="top"><strong>Bericht</strong>:</td>
<td class="user_text" align="left"><textarea disabled="disabled" rows="15" cols="64" class="default_input_field"><?php echo $uContent; }}?></textarea></td>
</tr>
<tr>
<td colspan="2">REACTIONS:<br /><hr class="content_hr" /></td>
</tr>
<tr>
<td colspan="2">
<?php
$result_count = mysql_query("SELECT * FROM news_reactions WHERE id_news = $news_id ");
while (list($id, $id_news, $subject, $user, $time, $date, $content) =
mysql_fetch_row($result_count)){
if($content != NULL) {
echo '
<table>
<tr>
<td>Name:</td>
<td>' . $user . '</td>
</tr>
<tr>
<td>Date:</td>
<td>' . $date . '</td>
</tr>
<tr>
<td>Reaction:</td>
<td>' . $content . '</td>
</tr>
</table>
<br />';
} else {
echo "There are no reactions yet!<br />
Please fill in the box below to add your reactions on this news!<br /><br />" .
$textbox;
}
}
echo "<hr class='content_hr' />" . $textbox;
?>
<?php
$date = date("jS F, Y");
$creator = $_POST['creator'];
$subject = "Tijdelijk subject";
$user = "Tijdelijk user";
$melding = "Reactie: ". $_POST['reaction'] ." is met succes geplaats!";
if($_SERVER['REQUEST_METHOD'] == "POST") {
$sql = 'INSERT INTO news_reactions
(id_news, subject, user, time, date, content)
VALUES
("' . 10 . '",
"' . mysql_real_escape_string( $subject ) . '",
"' . mysql_real_escape_string( $user ) . '",
NOW(),
"' . mysql_real_escape_string( $date ) . '",
"' . mysql_real_escape_string( $_POST['your_reaction'] ) . '")';
$query = mysql_query($sql) or die (mysql_error());
echo $melding;
}
}
?>
</table>
</form>
</td>
<td width="150"></td>
<td width="160" valign="top">
<strong>Updates:</strong>
<hr class="content_hr" />
</td>
</tr>
</table>
if (isset($_GET["id"])){
$news_id = $_GET["id"];
$result = mysql_query("SELECT * FROM news WHERE id = $news_id ");
while (list($id, $uDatee, $subject, $creator, $time, $date, $content, $reactions) =
mysql_fetch_row($result)){
$uContent = $content;
$uContent = stripslashes($uContent);
$textbox = '
<form method="post" name="reaction">
<table>
<tr>
<td>Name:</td>
<td><input name="your_name" type="text" value="Your name!" class="default_input_field" /></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="your_email" type="text" value="Your E-Mail!" class="default_input_field" /></td>
</tr>
<tr>
<td valign="top">Reaction:</td>
<td><textarea name="your_reaction" rows="8" cols="64" class="default_input_field">Your reaction!</textarea></td>
</tr>
<tr>
<td valign="top"><input type="submit" name="submit" value="Submit" class="default_input_button"></td>
<td></td>
</tr>
</table>
</form>';
?>
<table border="0" cellspacing="5">
<tr>
<td width="400" valign="top" class="content">
<strong>NEWS: <?php echo "//" . $subject; ?></strong>
<hr class="content_hr" />
<table>
<tr>
<td class="user_text"><strong>Date</strong>:</td>
<td class="user_text" align="left"><?php echo $date; ?></td>
</tr>
<tr>
<td class="user_text"><strong>Creator:</strong></td>
<td class="user_text" align="left"><?php echo $creator ?></td>
</tr>
<tr>
<td align="left" class="user_text" valign="top"><strong>Bericht</strong>:</td>
<td class="user_text" align="left"><textarea disabled="disabled" rows="15" cols="64" class="default_input_field"><?php echo $uContent; }}?></textarea></td>
</tr>
<tr>
<td colspan="2">REACTIONS:<br /><hr class="content_hr" /></td>
</tr>
<tr>
<td colspan="2">
<?php
$result_count = mysql_query("SELECT * FROM news_reactions WHERE id_news = $news_id ");
while (list($id, $id_news, $subject, $user, $time, $date, $content) =
mysql_fetch_row($result_count)){
if($content != NULL) {
echo '
<table>
<tr>
<td>Name:</td>
<td>' . $user . '</td>
</tr>
<tr>
<td>Date:</td>
<td>' . $date . '</td>
</tr>
<tr>
<td>Reaction:</td>
<td>' . $content . '</td>
</tr>
</table>
<br />';
} else {
echo "There are no reactions yet!<br />
Please fill in the box below to add your reactions on this news!<br /><br />" .
$textbox;
}
}
echo "<hr class='content_hr' />" . $textbox;
?>
<?php
$date = date("jS F, Y");
$creator = $_POST['creator'];
$subject = "Tijdelijk subject";
$user = "Tijdelijk user";
$melding = "Reactie: ". $_POST['reaction'] ." is met succes geplaats!";
if($_SERVER['REQUEST_METHOD'] == "POST") {
$sql = 'INSERT INTO news_reactions
(id_news, subject, user, time, date, content)
VALUES
("' . 10 . '",
"' . mysql_real_escape_string( $subject ) . '",
"' . mysql_real_escape_string( $user ) . '",
NOW(),
"' . mysql_real_escape_string( $date ) . '",
"' . mysql_real_escape_string( $_POST['your_reaction'] ) . '")';
$query = mysql_query($sql) or die (mysql_error());
echo $melding;
}
}
?>
</table>
</form>
</td>
<td width="150"></td>
<td width="160" valign="top">
<strong>Updates:</strong>
<hr class="content_hr" />
</td>
</tr>
</table>
Dit was m'n code.
Iemand enig idee waarom hij niets insert?
Gewijzigd op 01/01/1970 01:00:00 door [email protected]
Daar staat je ) buiten je ", die moet er toch in staan...