hulp bij wat errors
Ben bezig met school werk maar kom er niet helemaal uit.(!!ja ik mag hulp vragen!!)
Ik heb een soort van beheer systeem gemaakt maar ik krijg verschillende error's waar ik niet helemaal uit kom.
is er iemand die me zou willen helpen hier mee?
alvast bedankt.
Moet je wel meer info geven. Hier kunnen we uiteraard niks mee.
Gewijzigd op 06/01/2012 00:25:52 door Antonov tonova
De relevante code dan met daarbij je probleem en wat je hebt geprobeerd om dit te verhelpen.
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
class bieren {
var $host;
var $username;
var $password;
var $db;
function connect(){
$con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error());
mysql_select_db($this->db, $con) or die(mysql_error());
}//Ends Connect
function get_bieren($id = '') {
if($id != ""):
$id = mysql_real_escape_string($id);
$sql = "SELECT * FROM merken WHERE id = '$id'";
else:
$sql = "SELECT * FROM merken ORDER BY id DESC"; // ASC = A -> Z and DESC = Z -> A
endif;
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) != 1):
while($row = mysql_fetch_assoc($res)) {
echo '<h1><a href="index.php?id='. $row['id'] .'">' . $row['naam'] . '</a></h1>';
echo '<p>' . $row['brouwer'] . '</p>';
$return = '<p><a href="index.php">Ga terug naar content</a></p>';
}
else:
echo '<p>Uh Oh!, this doesn\'t exist</p>';
endif;
echo $return;
} //Ends get_bieren
function add_bieren($p) {
$naam = mysql_real_escape_string($p['naam']);
$brouwer = mysql_real_escape_string($p['brouwer']);
if(!$naam || !$brouwer):
if(!$naam):
echo "<p>The naam Is Required</p>";
endif;
if(!$brouwer):
echo "<p>The brouwer Is Required</p>";
endif;
echo '<p><a href="add-content.php">Try Again</a></p>';
else:
$sql = "INSERT INTO merken VALUES ('$naam', '$brouwer')";
$res = mysql_query($sql) or die(mysql_error());
echo "Added Successfully!";
endif;
} //Ends add_bieren
function manage_bieren() {
echo '<div id="manage">';
$sql = "SELECT * FROM merken";
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($res)) :
?>
<div>
<h2 class="naam"><?=$row['naam']?></h2>
<span class="actions"><a href="update-content.php?id=<?=$row['id']?>">Edit</a> | <a href="?delete=<?=$row['id'];?>">Delete</a></span>
</div>
<?php
endwhile;
echo '</div>'; //Closes Manage Div
}//Ends manage_bieren
function delete_bieren($id) {
if(!$id) {
return false;
}else {
$id = mysql_real_escape_string($id);
$sql = "DELETE FROM merken WHERE id = '$id'";
$res = mysql_query($sql) or die(mysql_error());
echo "Content Deleted Successfully!";
}
}//Ends delete_bieren
function update_bieren_form($id) {
$id = mysql_real_escape_string($id);
$sql = "SELECT * FROM merken WHERE id = '$id'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
?>
<form method="post" action="index.php">
<input type="hidden" name="update" value="true" />
<input type="hidden" name="id" value="<?=$row['id']?>" />
<div>
<label for="naam">Naam:</label>
<input type="text" name="naam" id="naam" value="<?=$row['naam']?>" />
</div>
<div>
<label for="brouwer">brouwer:</label>
<input type="text" name="brouwer" id="brouwer" value="<?=$row['brouwer']?>" />
</div>
<input type="submit" name="submit" value="Add Content" />
</form>
<?php
}//Ends update_bieren_form
function update_bieren($p) {
$id = mysql_real_escape_string($P['id']);
$naam = mysql_real_escape_string($P['naam']);
$brouwer = mysql_real_escape_string($P['brouwer']);
if(!$naam || !$brouwer):
if(!$naam):
echo "<p>The naam Is Required</P>";
endif;
if(!$brouwer):
echo "<p>The brouwer Is Required</P>";
endif;
echo '<p><a href="update-content.php?id=' . $id . '">Try Again !</a></p>';
else:
$sql = "UPDATE merken SET naam = '$naam', '$brouwer' = '$brouwer' WHERE id = '$id'";
$res = mysql_query($sql) or die(mysql_error());
echo "Updated Successfuly!";
endif;
}//Ends update_bieren
} //Ends our class
?>
class bieren {
var $host;
var $username;
var $password;
var $db;
function connect(){
$con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error());
mysql_select_db($this->db, $con) or die(mysql_error());
}//Ends Connect
function get_bieren($id = '') {
if($id != ""):
$id = mysql_real_escape_string($id);
$sql = "SELECT * FROM merken WHERE id = '$id'";
else:
$sql = "SELECT * FROM merken ORDER BY id DESC"; // ASC = A -> Z and DESC = Z -> A
endif;
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) != 1):
while($row = mysql_fetch_assoc($res)) {
echo '<h1><a href="index.php?id='. $row['id'] .'">' . $row['naam'] . '</a></h1>';
echo '<p>' . $row['brouwer'] . '</p>';
$return = '<p><a href="index.php">Ga terug naar content</a></p>';
}
else:
echo '<p>Uh Oh!, this doesn\'t exist</p>';
endif;
echo $return;
} //Ends get_bieren
function add_bieren($p) {
$naam = mysql_real_escape_string($p['naam']);
$brouwer = mysql_real_escape_string($p['brouwer']);
if(!$naam || !$brouwer):
if(!$naam):
echo "<p>The naam Is Required</p>";
endif;
if(!$brouwer):
echo "<p>The brouwer Is Required</p>";
endif;
echo '<p><a href="add-content.php">Try Again</a></p>';
else:
$sql = "INSERT INTO merken VALUES ('$naam', '$brouwer')";
$res = mysql_query($sql) or die(mysql_error());
echo "Added Successfully!";
endif;
} //Ends add_bieren
function manage_bieren() {
echo '<div id="manage">';
$sql = "SELECT * FROM merken";
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($res)) :
?>
<div>
<h2 class="naam"><?=$row['naam']?></h2>
<span class="actions"><a href="update-content.php?id=<?=$row['id']?>">Edit</a> | <a href="?delete=<?=$row['id'];?>">Delete</a></span>
</div>
<?php
endwhile;
echo '</div>'; //Closes Manage Div
}//Ends manage_bieren
function delete_bieren($id) {
if(!$id) {
return false;
}else {
$id = mysql_real_escape_string($id);
$sql = "DELETE FROM merken WHERE id = '$id'";
$res = mysql_query($sql) or die(mysql_error());
echo "Content Deleted Successfully!";
}
}//Ends delete_bieren
function update_bieren_form($id) {
$id = mysql_real_escape_string($id);
$sql = "SELECT * FROM merken WHERE id = '$id'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
?>
<form method="post" action="index.php">
<input type="hidden" name="update" value="true" />
<input type="hidden" name="id" value="<?=$row['id']?>" />
<div>
<label for="naam">Naam:</label>
<input type="text" name="naam" id="naam" value="<?=$row['naam']?>" />
</div>
<div>
<label for="brouwer">brouwer:</label>
<input type="text" name="brouwer" id="brouwer" value="<?=$row['brouwer']?>" />
</div>
<input type="submit" name="submit" value="Add Content" />
</form>
<?php
}//Ends update_bieren_form
function update_bieren($p) {
$id = mysql_real_escape_string($P['id']);
$naam = mysql_real_escape_string($P['naam']);
$brouwer = mysql_real_escape_string($P['brouwer']);
if(!$naam || !$brouwer):
if(!$naam):
echo "<p>The naam Is Required</P>";
endif;
if(!$brouwer):
echo "<p>The brouwer Is Required</P>";
endif;
echo '<p><a href="update-content.php?id=' . $id . '">Try Again !</a></p>';
else:
$sql = "UPDATE merken SET naam = '$naam', '$brouwer' = '$brouwer' WHERE id = '$id'";
$res = mysql_query($sql) or die(mysql_error());
echo "Updated Successfuly!";
endif;
}//Ends update_bieren
} //Ends our class
?>
add-bieren.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
36
37
38
39
40
41
42
43
44
45
46
47
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
<?php
include '../_class/bieren_class.php';
$obj = new bieren();
// Setup Our connection Vars
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->db = 'test';
// connect To Our DB
$obj->connect();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Add-bieren</title>
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="page-wrap">
<?php include '../nav.php';?>
<h2>Add bieren</h2>
<form method="post" action="index.php">
<input type="hidden" name="add" value="true" />
<div>
<label for="naam">Naam:</label>
<input type="text" name="naam" id="naam" />
</div>
<div>
<label for="brouwer">Brouwer:</label>
<input type="text" name="brouwer" id="brouwer" />
</div>
<input type="submit" name="submit" value="Add bier" />
</form>
</div>
</body>
</html>
include '../_class/bieren_class.php';
$obj = new bieren();
// Setup Our connection Vars
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->db = 'test';
// connect To Our DB
$obj->connect();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Add-bieren</title>
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="page-wrap">
<?php include '../nav.php';?>
<h2>Add bieren</h2>
<form method="post" action="index.php">
<input type="hidden" name="add" value="true" />
<div>
<label for="naam">Naam:</label>
<input type="text" name="naam" id="naam" />
</div>
<div>
<label for="brouwer">Brouwer:</label>
<input type="text" name="brouwer" id="brouwer" />
</div>
<input type="submit" name="submit" value="Add bier" />
</form>
</div>
</body>
</html>
update-bieren.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
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
<?php
include '../_class/bieren_class.php';
$obj = new bieren();
// Setup Our connection Vars
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->db = 'test';
// connect To Our DB
$obj->connect();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Update-bieren</title>
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="page-wrap">
<?php include '../nav.php';?>
<h2>Update bieren</h2>
<?=$obj->update_bieren_form($_GET['$id'])?>
</div>
</body>
</html>
include '../_class/bieren_class.php';
$obj = new bieren();
// Setup Our connection Vars
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->db = 'test';
// connect To Our DB
$obj->connect();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Update-bieren</title>
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="page-wrap">
<?php include '../nav.php';?>
<h2>Update bieren</h2>
<?=$obj->update_bieren_form($_GET['$id'])?>
</div>
</body>
</html>
manage-bieren.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
36
37
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
<?php
include '../_class/bieren_class.php';
$obj = new bieren();
// Setup Our connection Vars
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->db = 'test';
// connect To Our DB
$obj->connect();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Manage-Bieren</title>
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="page-wrap">
<?php include '../nav.php';?>
<?php
if($_GET['$id']):
$obj->delete_bieren($_GET['$id']);
endif;
?>
<?=$obj->manage_bieren()?>
</div>
</body>
</html>
include '../_class/bieren_class.php';
$obj = new bieren();
// Setup Our connection Vars
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->db = 'test';
// connect To Our DB
$obj->connect();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Manage-Bieren</title>
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="page-wrap">
<?php include '../nav.php';?>
<?php
if($_GET['$id']):
$obj->delete_bieren($_GET['$id']);
endif;
?>
<?=$obj->manage_bieren()?>
</div>
</body>
</html>
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
36
37
38
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
<?php
include '../_class/bieren_class.php';
$obj = new bieren();
// Setup Our connection Vars
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->db = 'test';
// connect To Our DB
$obj->connect();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Home</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="page-wrap">
<?php include 'nav.php';?>
<?php
if(isset($_GET['id'])):
$obj->get_bieren($_GET['id']);
else:
$obj->get_bieren();
endif;
?>
</div>
</body>
</html>
include '../_class/bieren_class.php';
$obj = new bieren();
// Setup Our connection Vars
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->db = 'test';
// connect To Our DB
$obj->connect();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Home</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<div id="page-wrap">
<?php include 'nav.php';?>
<?php
if(isset($_GET['id'])):
$obj->get_bieren($_GET['id']);
else:
$obj->get_bieren();
endif;
?>
</div>
</body>
</html>
Gewijzigd op 06/01/2012 01:02:34 door Antonov tonova
Euh... test geslaagd, en nu?
sorry daar voor :D
de error die ik krijg is:
op pagina manage-bieren:
Notice: Undefined index: $id in D:\xampp\htdocs\moderncms\admin\manage-bieren.php on line 29
maar ook krijg ik de edit en de delete knop niet aan de gang.
hoop dat jullie mij kunnen helpen :)
Gewijzigd op 06/01/2012 01:11:05 door Antonov tonova
Graag RELEVANTE code posten, en vermelden wat je probleem is.
Een betere titel zou ook zeker niet mis zijn...
Velen hier op PHP Hulp hebben hulp nodig bij vreemde foutmeldingen.
Gewijzigd op 06/01/2012 01:05:33 door - Ariën -
sorry voor de rare zinnen die ik schrijf maar ik heb dyslexie en soms schrijf ik dan wat anders dan wat ik in mij hoofd heb.
if($_GET[$id]): of if($_GET['id']):
- SanThe - op 06/01/2012 01:22:52:
if($_GET['$id']):
if($_GET[$id]): of if($_GET['id']):
if($_GET[$id]): of if($_GET['id']):
ik heb ze bij de geprobeerd maar de error blijft staan
isset().
Tja, dan zal de GET niet bestaan. Zie wand met:
spreek je toch dit aan?
Code (php)
1
2
3
4
5
6
2
3
4
5
6
function update_bieren_form($id) {
$id = mysql_real_escape_string($id);
$sql = "SELECT * FROM merken WHERE id = '$id'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
?>
$id = mysql_real_escape_string($id);
$sql = "SELECT * FROM merken WHERE id = '$id'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
?>
<form method="post" action="index.php">
<input type="hidden" name="update" value="true" />
<input type="hidden" name="id" value="" />
<div>
<label for="naam">Naam:</label>
<input type="text" name="naam" id="naam" value="" />
</div>
<div>
<label for="brouwer">brouwer:</label>
<input type="text" name="brouwer" id="brouwer" value="" />
</div>
<input type="submit" name="submit" value="Add Bieren" />
</form>
of zie ik dat verkeerd?
Gewijzigd op 06/01/2012 20:22:55 door Antonov tonova