edit mysql
Pagina1:
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
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
<?php
echo '<html><title>Admin Edit news Page</title></html>';
echo '<body bgcolor="#262626">';
echo'<table width="580" align=center>
<tr>
<td>
<table border="0" cellpadding="2" cellspacing="0" width="580" colspan="2" align=center>';
if (!@mysql_select_db("XXXXX", @mysql_connect("localhost", "XXXXX", "XXXXX")))
{
echo 'Er kan geen database connectie gemaakt worden.';
exit();
}
$sql = "SELECT * FROM staff WHERE isstaff = 1 order by id DESC";
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1)
{
while ($row = mysql_fetch_array ($res))
{
echo' <tr>
<td height="25" background="newssl.gif" width="480" style="border-left-style:solid; border-left-width:1px; border-top-style:solid; border-top-width:1px; border-right-style: solid; border-right-width: 1px; border-bottom-style: solid; border-bottom-width: 1px #E6E6E6; ">
<p align="left"><a href="editstaffp2.php?id=' . $row['id'] .'" style="text-decoration: none"><font size="2" color="#FFFFFF" face="Verdana">' . $row['name'] .'</font></a>
</td>
</tr>';
}
}
echo' </table>
</td>
</tr>
</table>';
echo '<br><a href="indexr.php" style="text-decoration: none"><font face="Verdana" size="2" color="#FFFFFF">Back to index</font></a>';
?>
echo '<html><title>Admin Edit news Page</title></html>';
echo '<body bgcolor="#262626">';
echo'<table width="580" align=center>
<tr>
<td>
<table border="0" cellpadding="2" cellspacing="0" width="580" colspan="2" align=center>';
if (!@mysql_select_db("XXXXX", @mysql_connect("localhost", "XXXXX", "XXXXX")))
{
echo 'Er kan geen database connectie gemaakt worden.';
exit();
}
$sql = "SELECT * FROM staff WHERE isstaff = 1 order by id DESC";
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1)
{
while ($row = mysql_fetch_array ($res))
{
echo' <tr>
<td height="25" background="newssl.gif" width="480" style="border-left-style:solid; border-left-width:1px; border-top-style:solid; border-top-width:1px; border-right-style: solid; border-right-width: 1px; border-bottom-style: solid; border-bottom-width: 1px #E6E6E6; ">
<p align="left"><a href="editstaffp2.php?id=' . $row['id'] .'" style="text-decoration: none"><font size="2" color="#FFFFFF" face="Verdana">' . $row['name'] .'</font></a>
</td>
</tr>';
}
}
echo' </table>
</td>
</tr>
</table>';
echo '<br><a href="indexr.php" style="text-decoration: none"><font face="Verdana" size="2" color="#FFFFFF">Back to index</font></a>';
?>
Pagina2:
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
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
<?php
//html, body
echo '<html><title>Admin Add staff Page</title></html>';
echo '<body bgcolor="#262626">';
$id=$_GET[id];
$mysql_id = mysql_connect("localhost", "XXXXX", "XXXXX");
mysql_select_db("XXXXX",$mysql_id);
$sql="SELECT * FROM staff WHERE id='$id'";
$res = mysql_query("$sql", $mysql_id);
$row=mysql_fetch_row($res);
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1)
{
while ($row = mysql_fetch_array ($res))
{
echo "
<form method='POST' action='editstaffp3.php?"; echo $row['id']; echo"'>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Name</font></u></b>
<br>
<input type='text' name='name' size='60' value='"; echo $row['name']; echo"'>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Country</font></u></b>
<br>
<select name='flag' size='1' value='"; echo $row['country']; echo"'><option value='au'>Australia</option><option value='at'>Austria</option><option value='be'>Belgium</option><option value='ca'>Canada</option><option value='ee'>Estonia</option><option value='fi'>Finland</option><option value='fr'>France</option><option value='de'>Germany</option><option value='gr'>Greece</option><option value='ie'>Ireland</option><option value='it'>Italy</option><option value='lv'>Latvia</option><option value='lu'>Luxembourg</option><option value='nl'>Netherlands</option><option value='no'>Norway</option><option value='pl'>Poland</option><option value='es'>Spain</option><option value='se'>Sweden</option><option value='ch'>Switzerland</option><option value='tr'>Turkey</option><option value='uk'>United Kingdom</option><option value='us'>USA</option></select>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Alt</font></u></b>
<br>
<input type='text' name='alt' size='70' value='"; echo $row['alt']; echo"'>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Age</font></u></b>
<br>
<input type='text' name='age' size='70' value='"; echo $row['age']; echo"'>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Real Name</font></u></b>
<br>
<input type='text' name='rname' size='70' value='"; echo $row['rname']; echo"'>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Sex</font></u></b>
<br>
<input type='text' name='sex' size='70' value='"; echo $row['sex']; echo"'>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Email</font></u></b>
<br>
<input type='text' name='email' size='70' value='"; echo $row['email']; echo"'>
<br>
<input type='submit' name='submit' value='Edit staff' size='20'>";}}
echo '<br><a href="indexr.php" style="text-decoration: none"><font face="Verdana" size="2" color="#FFFFFF">Back to index</font></a></body></html>';
?>
//html, body
echo '<html><title>Admin Add staff Page</title></html>';
echo '<body bgcolor="#262626">';
$id=$_GET[id];
$mysql_id = mysql_connect("localhost", "XXXXX", "XXXXX");
mysql_select_db("XXXXX",$mysql_id);
$sql="SELECT * FROM staff WHERE id='$id'";
$res = mysql_query("$sql", $mysql_id);
$row=mysql_fetch_row($res);
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1)
{
while ($row = mysql_fetch_array ($res))
{
echo "
<form method='POST' action='editstaffp3.php?"; echo $row['id']; echo"'>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Name</font></u></b>
<br>
<input type='text' name='name' size='60' value='"; echo $row['name']; echo"'>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Country</font></u></b>
<br>
<select name='flag' size='1' value='"; echo $row['country']; echo"'><option value='au'>Australia</option><option value='at'>Austria</option><option value='be'>Belgium</option><option value='ca'>Canada</option><option value='ee'>Estonia</option><option value='fi'>Finland</option><option value='fr'>France</option><option value='de'>Germany</option><option value='gr'>Greece</option><option value='ie'>Ireland</option><option value='it'>Italy</option><option value='lv'>Latvia</option><option value='lu'>Luxembourg</option><option value='nl'>Netherlands</option><option value='no'>Norway</option><option value='pl'>Poland</option><option value='es'>Spain</option><option value='se'>Sweden</option><option value='ch'>Switzerland</option><option value='tr'>Turkey</option><option value='uk'>United Kingdom</option><option value='us'>USA</option></select>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Alt</font></u></b>
<br>
<input type='text' name='alt' size='70' value='"; echo $row['alt']; echo"'>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Age</font></u></b>
<br>
<input type='text' name='age' size='70' value='"; echo $row['age']; echo"'>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Real Name</font></u></b>
<br>
<input type='text' name='rname' size='70' value='"; echo $row['rname']; echo"'>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Sex</font></u></b>
<br>
<input type='text' name='sex' size='70' value='"; echo $row['sex']; echo"'>
<br>
<b><u><font face='Verdana' size='1' color='#FFFFFF'>Email</font></u></b>
<br>
<input type='text' name='email' size='70' value='"; echo $row['email']; echo"'>
<br>
<input type='submit' name='submit' value='Edit staff' size='20'>";}}
echo '<br><a href="indexr.php" style="text-decoration: none"><font face="Verdana" size="2" color="#FFFFFF">Back to index</font></a></body></html>';
?>
Pagina3:
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
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
<?php
//html, body
echo '<html><title>Admin Edit news Page</title></html>';
echo '<body bgcolor="#262626">';
if (!@mysql_select_db("XXXXX", @mysql_connect("localhost", "XXXXX", "XXXXX")))
{
echo 'Er kan geen database connectie gemaakt worden.';
exit();
}
function strip_var($value)
{
$value1 = addslashes($value);
$value2 = strip_tags($value1);
$value3 = htmlspecialchars($value2);
return $value3;
}
//input
$id=$_GET[id];
$name = strip_var($_POST['name']);
$age = $_POST['age'];
$rname = strip_var($_POST['rname']);
$email = strip_var($_POST['email']);
$sql2 = "UPDATE news SET
name = '$name',
age = '$age',
rname = '$rname',
email = '$email'
WHERE id = $id";
mysql_query($sql2) or die(mysql_error());
//output
echo '<font color="#FFFFFF" size="2" face="Verdana">Staff member succesfully updated.</font><br><a href="indexr.php" style="text-decoration: none"><font color="#FFFFFF" size="2" face="Verdana"><Back to index</font></a>';
?>
//html, body
echo '<html><title>Admin Edit news Page</title></html>';
echo '<body bgcolor="#262626">';
if (!@mysql_select_db("XXXXX", @mysql_connect("localhost", "XXXXX", "XXXXX")))
{
echo 'Er kan geen database connectie gemaakt worden.';
exit();
}
function strip_var($value)
{
$value1 = addslashes($value);
$value2 = strip_tags($value1);
$value3 = htmlspecialchars($value2);
return $value3;
}
//input
$id=$_GET[id];
$name = strip_var($_POST['name']);
$age = $_POST['age'];
$rname = strip_var($_POST['rname']);
$email = strip_var($_POST['email']);
$sql2 = "UPDATE news SET
name = '$name',
age = '$age',
rname = '$rname',
email = '$email'
WHERE id = $id";
mysql_query($sql2) or die(mysql_error());
//output
echo '<font color="#FFFFFF" size="2" face="Verdana">Staff member succesfully updated.</font><br><a href="indexr.php" style="text-decoration: none"><font color="#FFFFFF" size="2" face="Verdana"><Back to index</font></a>';
?>
Bij pagina 3 geeft ie een fout:
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 '' at line 6
Hoe dit op te lossen?
Wie weet is dat het!
Groeten Cris
if (!@mysql_select_db("XXXXX", @mysql_connect("localhost", "XXXXX", "XXXXX")))
{
echo 'Er kan geen database connectie gemaakt worden.';
exit();
}
komaan... help eens iemand plz
Misschien ligt het aan je '' om je variabelen heen. Probeer het eens als je die weg haalt.
welke variablen?
Code (php)
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
<?
$sql2 = "UPDATE news SET
name = '".$name. "',
age = '".$age."',
rname = '".$rname."',
email = '".$email."'
WHERE id = ". $id;
?>
$sql2 = "UPDATE news SET
name = '".$name. "',
age = '".$age."',
rname = '".$rname."',
email = '".$email."'
WHERE id = ". $id;
?>
deze vars
Gewijzigd op 01/01/1970 01:00:00 door Klaasjan Boven