yandoo Posted March 27, 2008 Share Posted March 27, 2008 Hi there , Im having trouble running my code as i keep getting 404 error! Im pretty sure it is because of this lie of code: <?=$_SERVER['PHP_SELF']?> .... I think its because i have global variables turned off (which i want to leave off) in php.ini file and this line of code code is done with shorter tages... Im trying to modify it to have longer tags but not with much success... How is it done please???? Thanks Link to comment https://forums.phpfreaks.com/topic/98079-404-php_self/ Share on other sites More sharing options...
kenrbnsn Posted March 27, 2008 Share Posted March 27, 2008 Please post the rest of the code, so we can see what you're doing. Also, don't use "<?=", use "<?php echo". Turning off register_globals does not affect this, turning off short_tags does. Ken Link to comment https://forums.phpfreaks.com/topic/98079-404-php_self/#findComment-501799 Share on other sites More sharing options...
yandoo Posted March 27, 2008 Author Share Posted March 27, 2008 Hi, I have a simple bit of code that deletes records based on check boxes next to each record. Ithink i just got around the problem by using like you said the php echo: <?php echo $_SERVER['PHP_SELF']?>.....but i found that even though i click submit the record doesnt delete??? Whats going wrong???? <?php require_once('Connections/woodside.php'); ?> <?php mysql_select_db($database_woodside, $woodside); $query_Recordset1 = sprintf("SELECT * FROM animalfears WHERE AnimalID = %s", $colname_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $woodside) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if($_POST['perform']) { foreach($_POST as $id) { // This will loop through the checked checkboxes mysql_select_db($database_woodside, $woodside); $query_test="DELETE FROM animalfears WHERE AnimalFearID='" . $row_Recordset1['AnimalFearID'] ."'"; // Change yourtable and id. $test = mysql_query($query_test, $woodside) or die(mysql_error()); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form name="action" id="action" method="post" action="<?php echo $_SERVER['PHP_SELF']?>"> <table width="465" border="1"> <tr> <?php do { ?> <td><?php echo $row_Recordset1['FearID']; ?></td> <td><label> <input type="checkbox" name="<?php echo $row_Recordset1['AnimalFearID']; ?>" id="<?php echo $row_Recordset1['AnimalFearID']; ?>" value="<?php echo $row_Recordset1['AnimalFearID']; ?>" /> </label></td> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?></tr> <tr> <td> </td> <td> </td> </tr> </table> <p> <label> <input type="submit" name="perform" id="perform" value="Delete Selected" /> </label> </p> </form> </body> </html> <?php mysql_free_result($Recordset1); ?> If you could take a glance that woudl be ace Thanks Link to comment https://forums.phpfreaks.com/topic/98079-404-php_self/#findComment-501812 Share on other sites More sharing options...
kenrbnsn Posted March 27, 2008 Share Posted March 27, 2008 Your logic and form are a mess. Try this: <?php require_once('Connections/woodside.php'); mysql_select_db($database_woodside, $woodside); if(isset($_POST['perform'])) { foreach($_POST['id'] as $id) { // This will loop through the checked checkboxes $query_test="DELETE FROM animalfears WHERE AnimalFearID='$id'"; // Change yourtable and id. $test = mysql_query($query_test) or die("Problem with the query: $query_test<br />" . mysql_error()); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php $query_Recordset1 = "SELECT * FROM animalfears WHERE AnimalID = " . $colname_Recordset1; $Recordset1 = mysql_query($query_limit_Recordset1) or die("Problem with the query: $query_Recordset1<br />" . mysql_error()); ?> <form name="action" id="action" method="post" action="<?php echo $_SERVER['PHP_SELF']?>"> <table width="465" border="1"> <tr> <?php while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { ?> <td><?php echo $row_Recordset1['FearID']; ?></td> <td><label> <input type="checkbox" name="id[<?php echo $row_Recordset1['AnimalFearID']; ?>]" id="id_<?php echo $row_Recordset1['AnimalFearID']; ?>" value="<?php echo $row_Recordset1['AnimalFearID']; ?>" /> </label></td> <?php } ?></tr> <tr> <td> </td> <td> </td> </tr> </table> <p> <label> <input type="submit" name="perform" id="perform" value="Delete Selected" /> </label> </p> </form> </body> </html> <?php mysql_free_result($Recordset1); ?> Ken Link to comment https://forums.phpfreaks.com/topic/98079-404-php_self/#findComment-501845 Share on other sites More sharing options...
rofl90 Posted March 27, 2008 Share Posted March 27, 2008 <?php echo $_SERVER['PHP_SELF']?> You forgot your semi-colon Link to comment https://forums.phpfreaks.com/topic/98079-404-php_self/#findComment-501849 Share on other sites More sharing options...
kenrbnsn Posted March 27, 2008 Share Posted March 27, 2008 Don't need it if the statement is the last one before a closing "?>". Ken Link to comment https://forums.phpfreaks.com/topic/98079-404-php_self/#findComment-501853 Share on other sites More sharing options...
yandoo Posted March 28, 2008 Author Share Posted March 28, 2008 Hi, Thats ACE! Thanks very much indeed, it works a charm! Link to comment https://forums.phpfreaks.com/topic/98079-404-php_self/#findComment-502713 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.