Delete in mysql
Jens V
24/04/2006 21:34:00ik probeer een record in de table "contact" te verwijderen, maar het lukt niet. Wat is hieraan fout?
Answer asap
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$id=$_GET[id];
$mysql_id = mysql_connect("localhost", "XXXXX", "XXXXX");
mysql_select_db("XXXXX",$mysql_id);
$sql="DELETE * FROM contact WHERE id='$id'";
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1)
{
while ($row = mysql_fetch_array ($res))
{
echo '<font face="Verdana" size="2" color="#FFFFFF">Message succesfully deleted!</font><br><a href="viewmsg.php" style="text-decoration: none"><font face="Verdana" size="2" color="#FFFFFF">Back to Inbox</font></a>';
}
}
?>
$id=$_GET[id];
$mysql_id = mysql_connect("localhost", "XXXXX", "XXXXX");
mysql_select_db("XXXXX",$mysql_id);
$sql="DELETE * FROM contact WHERE id='$id'";
$res = mysql_query ($sql) or die (mysql_error ());
if (mysql_num_rows ($res) >= 1)
{
while ($row = mysql_fetch_array ($res))
{
echo '<font face="Verdana" size="2" color="#FFFFFF">Message succesfully deleted!</font><br><a href="viewmsg.php" style="text-decoration: none"><font face="Verdana" size="2" color="#FFFFFF">Back to Inbox</font></a>';
}
}
?>
Answer asap
PHP hulp
16/11/2024 13:33:02Terence Hersbach
24/04/2006 21:38:00Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$id=$_GET[id];
$mysql_id = mysql_connect("localhost", "XXXXX", "XXXXX");
mysql_select_db("XXXXX",$mysql_id);
$sql="DELETE * FROM contact WHERE id='$id'";
$res = mysql_query ($sql) or die (mysql_error ());
if ($res)
{
echo '<font face="Verdana" size="2" color="#FFFFFF">Message succesfully deleted!</font><br><a href="viewmsg.php" style="text-decoration: none"><font face="Verdana" size="2" color="#FFFFFF">Back to Inbox</font></a>';
}
?>
$id=$_GET[id];
$mysql_id = mysql_connect("localhost", "XXXXX", "XXXXX");
mysql_select_db("XXXXX",$mysql_id);
$sql="DELETE * FROM contact WHERE id='$id'";
$res = mysql_query ($sql) or die (mysql_error ());
if ($res)
{
echo '<font face="Verdana" size="2" color="#FFFFFF">Message succesfully deleted!</font><br><a href="viewmsg.php" style="text-decoration: none"><font face="Verdana" size="2" color="#FFFFFF">Back to Inbox</font></a>';
}
?>
ik denk dat het zo beter werkt, je liet de variable niet uitvoeren;)
Gewijzigd op 01/01/1970 01:00:00 door Terence Hersbach
Jens V
24/04/2006 21:42:00You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM contact WHERE id='1'' at line 1
dit blijft ie zeggen :s
dit blijft ie zeggen :s
Willem Jan Z
24/04/2006 21:53:00- SanThe -
24/04/2006 22:03:00En mysql_num_rows werkt niet bij een DELETE. Dan moet je mysql_affected_rows() hebben.
En dit werkt uiteraard ook niet na een DELETE query:
while ($row = mysql_fetch_array (.....))
En dit werkt uiteraard ook niet na een DELETE query:
while ($row = mysql_fetch_array (.....))