Page 1 of 1

deleting an entry? what am i doign wrong?

Posted: Sat Jan 24, 2004 8:48 am
by lizlazloz

Code: Select all

<?php
$sql1="delete from crews where name ='". $crew ."'";
?>
$name is a valid name for one of the entrys... but it does not delete it? why not?

Posted: Sat Jan 24, 2004 8:57 am
by kettle_drum
I guess that your then passing the $sql1 variable to mysql_query() and everything is ok in that area? As your syntax seems ok.

Posted: Sat Jan 24, 2004 8:59 am
by lizlazloz
yes. i get no errors or anything, the entry just doesnt disappear...

Posted: Sat Jan 24, 2004 9:00 am
by markl999
If you echo $sql1; and use mysql_query($sql1) or die(mysql_error()); .. what do you get?

Posted: Sat Jan 24, 2004 9:01 am
by DuFF
Try echoing out the query to see if it looks how you want it to:

Code: Select all

<?php
$sql1 = "DELETE FROM crews WHERE name ='". $crew ."'";
echo $sql1;
?>

Posted: Sat Jan 24, 2004 9:04 am
by lizlazloz
will do

Posted: Sat Jan 24, 2004 9:12 am
by lizlazloz
i get nothing. well, i edited $crew at an earlier time, before the $sql, and i got the correct value, so i guess that is working...

i get this error though:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/tekwar/public_html/disband.php on line 34

after the page does nothing for 30 seconds...

heres the code:

Code: Select all

<?php
include("checklogin.php");
include("connect.php");


$sql="select crew from game where name ='". $_COOKIE[access] ."'";
$rs=mysql_query($sql,$conn)
or die("could not execute query1");
$row= mysql_fetch_array($rs);
$crew=$row[crew];
echo($crew);
$sql="select leader,r1,r2,r3,r4 from crews where name ='". $crew ."'";
$rs=mysql_query($sql,$conn)
or die("could not execute query2");


$row= mysql_fetch_array($rs);
$r1=$row[r1];
$r2=$row[r2];
$r3=$row[r3];
$r4=$row[r4];
$leader=$row[leader];
if ( $leader == $_COOKIE[access] )
{
if ($_POST[choice] == "yes")
{
$sql1="update game set crew = '' where name ='". $_COOKIE[access] ."'";
$rs1=mysql_query($sql1,$conn)
or die("could not execute query");

$r1 = explode(",", $r1);
$size1 = count($r1);
$ri = 1;
while( $i < $size1 )
{
$sql1="update game set crew = '' where name ='". $r1[$i] ."'";
$rs1=mysql_query($sql1,$conn)
or die("could not execute query");
}

$r2 = explode(",", $r2);
$size2 = count($r2);
$i = 1;
while( $i < $size2 )
{
$sql1="update game set crew = '' where name ='". $r2[$i] ."'";
$rs1=mysql_query($sql1,$conn)
or die("could not execute query");
}

$r3 = explode(",", $r3);
$size3 = count($r3);
$i = 1;
while( $i < $size3 )
{
$sql1="update game set crew = '' where name ='". $r3[$i] ."'";
$rs1=mysql_query($sql1,$conn)
or die("could not execute query");
}

$r4 = explode(",", $r4);
$size4 = count($r4);
$i = 1;
while( $i < $size4 )
{
$sql1="update game set crew = '' where name ='". $r4[$i] ."'";
$rs1=mysql_query($sql1,$conn)
or die("could not execute query");
}

$sql1="delete from crews where name ='". $crew ."'";
echo($sql);
$rs1=mysql_query($sql1,$conn)
or die("could not execute query");
$result="Crew disbanded";
}
}
else
{
$result="Only the leader can disband!";
}

?>
all the rest of the querys are executed, but not the last one...

Posted: Sat Jan 24, 2004 9:14 am
by markl999
while( $i < $size1 ) <-- infinite loop

I don't see where you set $i (or increment it?)
Maybe you want a foreach($size1 as $whatever){ ... } ?
The same applies for those other while() loops

Edit..Looked again and saw $ri = 1;
that should be $i=1; methinks. But the loops are still missing a $i++

Posted: Sat Jan 24, 2004 9:19 am
by lizlazloz
ARGH! i'm so stupid... thanks.