Probleem bij nieuws systeem
Ik heb een probleem met mijn nieuws systeempje,
de hele zooi komt niet in de database terecht heeft iemand een idee?
hier de code:
//add.php
//index.php
de hele zooi komt niet in de database terecht heeft iemand een idee?
hier de code:
//add.php
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
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
<?php
mysql_connect('*****', '*****', '******') or die (mysql_error());
mysql_select_db('*****');
if(isset($_POST['news']))
{
$toevoegen = 'INSERT INTO news SET gb_name = "'.$_POST['gb_name'].'",title = "'.$_POST['title'].'",message = "'.$_POST['message'].'"';
mysql_query($toevoegen) or die (mysql_error());
echo 'Message introduced';
}
echo '<a href="index.php">Index</a>';
echo '<form action="" method="post">';
echo 'Title:<input type="text" name="gb_name">';
echo '<br />';
echo 'Title:<input type="text" name="title">';
echo '<br />';
echo 'Message:<textarea name="message" rows="10" cols="30">';
echo '</textarea>';
echo '<br />';
echo '<br />';
echo '<input type="submit" value="Submit">';
echo '<br />';
?>
mysql_connect('*****', '*****', '******') or die (mysql_error());
mysql_select_db('*****');
if(isset($_POST['news']))
{
$toevoegen = 'INSERT INTO news SET gb_name = "'.$_POST['gb_name'].'",title = "'.$_POST['title'].'",message = "'.$_POST['message'].'"';
mysql_query($toevoegen) or die (mysql_error());
echo 'Message introduced';
}
echo '<a href="index.php">Index</a>';
echo '<form action="" method="post">';
echo 'Title:<input type="text" name="gb_name">';
echo '<br />';
echo 'Title:<input type="text" name="title">';
echo '<br />';
echo 'Message:<textarea name="message" rows="10" cols="30">';
echo '</textarea>';
echo '<br />';
echo '<br />';
echo '<input type="submit" value="Submit">';
echo '<br />';
?>
//index.php
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
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
<?php
mysql_connect('*****', '*****', '*****') or die (mysql_error());
mysql_select_db('*****'); // database connectie
$query = 'SELECT * FROM news';
$result = mysql_query($query) or die('Fout bij uitvoeren van de query');
echo '<table>';
while ($row = mysql_fetch_assoc($result))
{
echo '<tr>';
echo '<a href="add.php>Add message</a>"';
echo '<a href="admin_add.php>Admin</a>';
echo '<td>'.$row['gb_name'].'</td>';
echo '<td>'.$row['title'].'</td>';
echo '<td>'.$row['message'].'</td>';
echo '<td>'.$row['opmerking'].'</td>';
echo '<td><a href="add.php?id='.$row['id'].'">Edit</a></td>';
echo '</tr>';
}
echo '</table>';
?>
<html>
<body>
hoi
</body>
</html>
mysql_connect('*****', '*****', '*****') or die (mysql_error());
mysql_select_db('*****'); // database connectie
$query = 'SELECT * FROM news';
$result = mysql_query($query) or die('Fout bij uitvoeren van de query');
echo '<table>';
while ($row = mysql_fetch_assoc($result))
{
echo '<tr>';
echo '<a href="add.php>Add message</a>"';
echo '<a href="admin_add.php>Admin</a>';
echo '<td>'.$row['gb_name'].'</td>';
echo '<td>'.$row['title'].'</td>';
echo '<td>'.$row['message'].'</td>';
echo '<td>'.$row['opmerking'].'</td>';
echo '<td><a href="add.php?id='.$row['id'].'">Edit</a></td>';
echo '</tr>';
}
echo '</table>';
?>
<html>
<body>
hoi
</body>
</html>
Gewijzigd op 01/01/1970 01:00:00 door Mich
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
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
<?php
mysql_connect('*****', '*****', '******') or die (mysql_error());
mysql_select_db('*****');
if (isset($_POST['news'])) {
$toevoegen = "
INSERT INTO news
SET
gb_name = '" . $_POST['gb_name'] . "',
title = '" . $_POST['title'] . "',
message = '" . $_POST['message'] . "'";
mysql_query($toevoegen) or die (mysql_error());
echo 'Message introduced';
}
echo '<a href="index.php">Index</a>';
echo '<form action="" method="post">';
echo 'Title:<input type="text" name="gb_name">';
echo '<br />';
echo 'Title:<input type="text" name="title">';
echo '<br />';
echo 'Message:<textarea name="message" rows="10" cols="30">';
echo '</textarea>';
echo '<br />';
echo '<br />';
echo '<input type="submit" value="Submit">';
echo '<br />';
?>
mysql_connect('*****', '*****', '******') or die (mysql_error());
mysql_select_db('*****');
if (isset($_POST['news'])) {
$toevoegen = "
INSERT INTO news
SET
gb_name = '" . $_POST['gb_name'] . "',
title = '" . $_POST['title'] . "',
message = '" . $_POST['message'] . "'";
mysql_query($toevoegen) or die (mysql_error());
echo 'Message introduced';
}
echo '<a href="index.php">Index</a>';
echo '<form action="" method="post">';
echo 'Title:<input type="text" name="gb_name">';
echo '<br />';
echo 'Title:<input type="text" name="title">';
echo '<br />';
echo 'Message:<textarea name="message" rows="10" cols="30">';
echo '</textarea>';
echo '<br />';
echo '<br />';
echo '<input type="submit" value="Submit">';
echo '<br />';
?>
oke, bedankt
De SQL-variant die je nu gebruikt om een INSERT te doen, zal in MySQL misschien wel werken, maar het is zeker geen standaard en zal in andere database waarschijnlijk niet werken. Ik raad je aan om zo veel mogelijk de standaard SQL te gebruiken, dat maakt het voor jou een stuk eenvoudiger om met diverse database te werken.
SET hoort daar dus niet in thuis, die hoort bij UPDATE.
SET hoort daar dus niet in thuis, die hoort bij UPDATE.




