andrew_biggart Posted May 28, 2008 Share Posted May 28, 2008 CAN ANYONE SPOT THE PHP ERROR IN THE SYNTAX or why this wouldnt work ???? <?php include("config.php"); if(!isset($_POST['delete'])){ $sql="SELECT * FROM biggart_members"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?><table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td> <td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td> </tr> <?php if($_POST['perform']) { foreach($_POST as $user_id) { // This will loop through the checked checkboxes mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1"); } } mysql_close(); ?> </table> </form> </td> </tr> </table> </div> Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/ Share on other sites More sharing options...
BlueSkyIS Posted May 28, 2008 Share Posted May 28, 2008 parse error: syntax error, unexpected $end in /Users/Sites/site1/test.php on line 58 Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552025 Share on other sites More sharing options...
Gighalen Posted May 28, 2008 Share Posted May 28, 2008 <?php include("config.php"); if(!isset($_POST['delete'])){ $sql="SELECT * FROM biggart_members"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?><table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"> <input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td> <td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td> </tr> <?php if($_POST['perform']) { foreach($_POST as $user_id) { // This will loop through the checked checkboxes mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1"); } } } mysql_close(); ?> </table> </form> </td> </tr> </table> </div> Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552026 Share on other sites More sharing options...
prcollin Posted May 28, 2008 Share Posted May 28, 2008 CAN ANYONE SPOT THE PHP ERROR IN THE SYNTAX or why this wouldnt work ???? <?php include("config.php"); if(!isset($_POST['delete'])){ $sql="SELECT * FROM biggart_members"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?><table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td> <td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td> </tr> <?php if($_POST['perform']) { foreach($_POST as $user_id) { // This will loop through the checked checkboxes mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1"); } } mysql_close(); ?> </table> </form> </td> </tr> </table> </div> Thanks in advance first you already posted this didnt you? second put your code in Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552027 Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 you're missing a bracket (}) Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552028 Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 yup...missing close bracket at the end...start indenting, it will make your life SO much easier: <?php include("config.php"); if(!isset($_POST['delete'])){ $sql="SELECT * FROM biggart_members"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?><table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td> <td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td> </tr> <?php if($_POST['perform']) { foreach($_POST as $user_id) { // This will loop through the checked checkboxes mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1"); } } mysql_close(); ?> </table> </form> </td> </tr> </table> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552029 Share on other sites More sharing options...
Gighalen Posted May 28, 2008 Share Posted May 28, 2008 I fixed it, just copy and paste the code i posted. Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552030 Share on other sites More sharing options...
craygo Posted May 28, 2008 Share Posted May 28, 2008 you changed a few things from the code I gave you before. you changed your submit button name but didn't change the check up top. <?php include("config.php"); if(!isset($_POST['perform'])){ $sql="SELECT * FROM biggart_members"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?><table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td> <td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td> </tr> <?php } else { foreach($_POST as $user_id) { // This will loop through the checked checkboxes mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1"); } } mysql_close(); ?> </table> </form> </td> </tr> </table> </div> Ray Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552031 Share on other sites More sharing options...
andrew_biggart Posted May 28, 2008 Author Share Posted May 28, 2008 ok thanks for that i am no longer getting a blanc screen but the code isnt doing what i wnat it to do !! All i want is to be able to delte users by checking a checkbox and clicking delete! does anyone have any ideas why this code would not work??? Thanks again sorry if im pissing any1 off im new to this forum <?php include("config.php"); if(!isset($_POST['delete'])){ $sql="SELECT * FROM biggart_members"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?><table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"> <input type="checkbox" name="<?=$row[user_id]?>" id="<?=$row[user_id]?>" value="<?=$row[user_id]?>" /></td> <td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td> </tr> <?php if($_POST['perform']) { foreach($_POST as $user_id) { // This will loop through the checked checkboxes mysql_query("DELETE FROM biggart_members WHERE user_id='$user_id' LIMIT 1"); } } } mysql_close(); ?> </table> </form> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552033 Share on other sites More sharing options...
andrew_biggart Posted May 28, 2008 Author Share Posted May 28, 2008 [move]any 1 ? ? ? ? ?? ? ??? pleassssssssssseeeee help ???[/move] Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552045 Share on other sites More sharing options...
craygo Posted May 28, 2008 Share Posted May 28, 2008 How many time you going to change it. This works just copy and paste it. <?php include("config.php"); $table = "biggart_members"; if(!isset($_POST['perform'])){ $sql="SELECT * FROM $table"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?><table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="checkbox[]" id="<?=$rows['user_id']?>" value="<?=$rows['user_id']?>" /></td> <td bgcolor="#FFFFFF"><?php echo $rows['user_id']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td> <!-- --> <td bgcolor="#FFFFFF"><?php echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><?php echo $rows['email']; ?></td> <!-- --> <td bgcolor="#FFFFFF"><?php echo $rows['username']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td> </tr> <?php } else { foreach($_POST['checkbox'] as $user_id) { // This will loop through the checked checkboxes $sql = "DELETE FROM $table WHERE user_id='$user_id' LIMIT 1"; echo $sql."<br />"; mysql_query($sql) or die(mysql_error()); } } mysql_close(); ?> </table> </form> </td> </tr> </table> </div> Ray Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552049 Share on other sites More sharing options...
DarkWater Posted May 28, 2008 Share Posted May 28, 2008 I'm pretty sure that craygo's code works. As for you being new to the forums, let me give you some hints so you can get better help: 1) Don't type in caps. It's annoying. 2) Marquees are equally annoying. 3) Typing coherently works wonders. Inside of typing "liek dis", type properly so you can properly ask a question. 4) Don't just sit there and wait for a response. At least try something while you wait. Following those tips, even if you only follow one or two of them, will help a lot. Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552052 Share on other sites More sharing options...
andrew_biggart Posted May 28, 2008 Author Share Posted May 28, 2008 Thanks so much ray you are a legend it works yes!!! But yes the dreaded but, it messes with my layout so ive tried to add it to my normal tables now and now im getting a syntax error can anyone spot it ????? please and thanks for everyones help especially ray aka legend!! <?php include("config.php"); $table = "biggart_members"; if(!isset($_POST['perform'])){ $sql="SELECT * FROM $table"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <br/> <form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table class= "select_header"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td style="width: 370px" class="select_header">Admin Section </td> </tr> </table> <br/> <table class= "select_myebaygrey"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td style="width: 370px">View all users</td> </tr> </table> <br/> <table class= "select_myebaygrey"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td style="width: 30px" class="style28">Userid </td> <td style="width: 69px" class="style28">First name</td> <td style="width: 102px" class="style28">Email</td> <td style="width: 107px" class="style28">Username</td> <td style="width: 136px" class="style28">Avatar</td> <td class="style28">Delete User</td> </tr> </table> <table class= "select_main"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td style="width: 33px" ><? echo $rows['user_id']; ?></td> <td style="width: 94px" ><? echo $rows['name']; ?></td> <td style="width: 97px" ><? echo $rows['email']; ?></td> <td style="width: 86px" ><? echo $rows['username']; ?></td> <td style="width: 122px" ><? echo "<img src='avatars/". $rows['user_avatar'] . "' style='width:50px; height:50px;' />";?></td> <td align="center"><input type="checkbox" name="checkbox[]" id="<?=$rows['user_id']?>" value="<?=$rows['user_id']?>" /></td> </tr> </table> <?php } ?> <table> <tr> <td colspan="5" align="right" ><input type="submit" name="perform" id="perform" value="Delete Selected" /> </td> </tr> </table> <?php } else { foreach($_POST['checkbox'] as $user_id) { // This will loop through the checked checkboxes $sql = "DELETE FROM $table WHERE user_id='$user_id' LIMIT 1"; echo $sql."<br />"; mysql_query($sql) or die(mysql_error()); } } mysql_close(); ?> </form> Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552095 Share on other sites More sharing options...
DarkWater Posted May 28, 2008 Share Posted May 28, 2008 Where are you getting the error...? And which error? Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552100 Share on other sites More sharing options...
andrew_biggart Posted May 28, 2008 Author Share Posted May 28, 2008 Never min i have found it now and it works whopppppppp THANK YOU SO MUCH RAY YOU ARE A LEGEND (sorry for the caps very exceited ) Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552105 Share on other sites More sharing options...
.josh Posted May 28, 2008 Share Posted May 28, 2008 I'm pretty sure that craygo's code works. As for you being new to the forums, let me give you some hints so you can get better help: 1) Don't type in caps. It's annoying. 2) Marquees are equally annoying. 3) Typing coherently works wonders. Inside of typing "liek dis", type properly so you can properly ask a question. 4) Don't just sit there and wait for a response. At least try something while you wait. Following those tips, even if you only follow one or two of them, will help a lot. 5) Use code tags 6) don't make ambiguous titles like "PLEASEEEE HELP" Quote Link to comment https://forums.phpfreaks.com/topic/107683-solved-pleaseeee-help/#findComment-552106 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.