943,936 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 2559
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 3rd, 2009
0

PRoblem in Delete

Expand Post »
Hello Friends I am new to PHP can any one help me
i am facing one problem
whenever i am working on local host my delete command is working without problem
but whenever i am uploading this file on internet through FTP
the command not deleting any records

Every one help wuld be appreciated
thanks manish mannan
Similar Threads
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
manishmannan is offline Offline
58 posts
since Nov 2009
Nov 3rd, 2009
0
Re: PRoblem in Delete
Do you mean delete in an SQL query, or a unlink to delete files?
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
Nov 3rd, 2009
-1
Re: PRoblem in Delete
Do you mean delete in an SQL query, or a unlink to delete files?
sory brother your are not getting me
my question is
i am working on some multiple records like here is my code
<?php
//echo $user;
session_start();
if (!isset($_SESSION['myusername']))
{
echo'<center><b>You need TO login First</b></center>';
include 'login.html';
exit();
}
else{
session_set_cookie_params(1200);
}

$user = $_SESSION['myusername'];
?>
<style>
body {
font-family:Arial, Helvetica, sans-serif;
background:#FFFFF0;
font-size:12px;
color:#000000;
}
.logout {
cursor:pointer;
background:#FFFF00;
border:#FF6600 1px solid;
width:100px;
height:30px;
font-size:14px;
font-weight:bold;
color:#FF6600;
float:right;
text-decoration:none;
font-family:Arial;
font-size:14px;
line-height:30px;
margin:50px 50px 0px 0px;
text-align:center;
}
h1 {
font-family:Arial, Helvetica, sans-serif;
font-size:20px;
color: #FF6600;
text-align:center;
margin:50px auto 0px auto;
font-weight:500;
}
.head {
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
color: #000;
text-align:center;
}
.form {
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
color:#666666;
line-height:18px;
background:#FBFBFB;
width:100%;
padding:20px;
border:#FFCC00 2px solid;
font-weight:bold;
}
.lable {
margin-left:100px;
}
.btn {
cursor:pointer;
background:#E0E0E0;
border:#000 1px solid;
width:100px;
height:30px;
font-size:14px;
font-weight:bold;
color:#000;
float:left;
margin-left:20px;
}
</style>
<title>View Record of Online Application</title><a href="logout.php"><span class="logout">LOGOUT</span> </a><br />
<br />
<br />
<br />
<br />
<h1>Login as&nbsp;&nbsp;<?php echo $user; ?></h1>
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="hnit";
$tbl_name="registration";
$con = mysql_connect($host, $username, $password)or die("cannot connect");
mysql_select_db($db_name)or die("cannot select DB");
$sql="SELECT * FROM $tbl_name ORDER BY id DESC";
$result=mysql_query($sql);
$count=mysql_num_rows($result);

?>
<form name="form1" method="get" action= "">
<table width="100%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#FF9900" bgcolor="#FBFBFB" class="head">
<tr>
<td height="38" colspan="8" bgcolor="#FFCC00"><strong>RECORDS DISPLAYING FOR ONLINE APPLICATION </strong></td>
</tr>
<tr>
<td width="67" height="38" align="center" bgcolor="#FFFFCC"><strong>SELECT</strong></td>
<td width="48" align="center" bgcolor="#FFFFCC"><strong>Id</strong></td>
<td width="188" align="center" bgcolor="#FFFFCC"><strong>Name</strong></td>
<td width="135" align="center" bgcolor="#FFFFCC"><strong>Email ID </strong></td>
<td width="175" align="center" bgcolor="#FFFFCC"><strong>ADDRESS</strong></td>
<td width="157" align="center" bgcolor="#FFFFCC"><strong>COURSE</strong></td>
<td width="115" align="center" bgcolor="#FFFFCC"><strong>EDUCATION</strong></td>
<td width="143" align="center" bgcolor="#FFFFCC"><strong>PHONE NO </strong></td>
</tr>
<?php while($rows=mysql_fetch_array($result, MYSQL_ASSOC)){ ?>
<tr>
<td height="44" align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value=" <?php echo $rows['id']; ?>"></td>
<td bgcolor="#FFFFFF"><?php echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['emailid']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['address']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['course']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['education']; ?></td>
<td bgcolor="#FFFFFF"><?php echo $rows['phoneno']; ?></td>
</tr>
<?php } ?>
<tr>
<td height="58" colspan="8" align="center" bgcolor="#FFFFCC"><input name="delete" type="submit" id="delete" value="Delete" class="btn" style="float:none;"></td>
</tr>
<?php if($_GET['delete']){
for($i=0;$i<count($_GET['checkbox']);$i++)
{
$del_id = $checkbox[$i];
$sql = "DELETE FROM $tbl_name WHERE id='$del_id' LIMIT 1";
$result = mysql_query($sql,$con);
if (mysql_query($sql,$con))
{
echo " records is sucessfully Deleted";
}
else{
die('Error: ' . mysql_error());
}
}
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=del.php\">";
}
}
mysql_close();

?>
</table>
</form>





whenever i am working on local host it work fine but after uploading file on internet
this script not deleting any records
what do i do????
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
manishmannan is offline Offline
58 posts
since Nov 2009
Nov 3rd, 2009
0
Re: PRoblem in Delete
If you upload the same script as it is to work on the server, it's supposed to throw errors.
Look your few variable settings, you need to change them to the server values.
PHP Syntax (Toggle Plain Text)
  1. $host="localhost"; // Host name, should be actual db server name now, and not the localhost
  2. $username="root"; // Mysql username on the above server
  3. $password=""; // Mysql password for the above db server
  4. $db_name="hnit";//is the db name same on the server too

Edit: Please use the code tags
Last edited by network18; Nov 3rd, 2009 at 8:35 am. Reason: Edit: use the code tags
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 4th, 2009
0
Re: PRoblem in Delete
Thanks for your Reply
yes brother after changing this personal information about the database still i am not able to delete the values selected by checkbox
while with the same program i am able to delete the values on my localhost
the script not work on internet why is it so
is there any change needed in php.ini
or any change needed in mysql plz tell me i am in big trouble
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
manishmannan is offline Offline
58 posts
since Nov 2009
Nov 4th, 2009
0
Re: PRoblem in Delete
in my localhost my PHP Engine Type is MyISAM While on Internet My php Engine Type is InnoDB
is there any difference in both the type of PHP engine
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
manishmannan is offline Offline
58 posts
since Nov 2009
Nov 4th, 2009
0
Re: PRoblem in Delete
you did the same common mistake..not doing isset on $_POST['btnName'].
your improved code here -
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. //echo $user;
  3. session_start();
  4. if (!isset($_SESSION['myusername']))
  5. {
  6. echo'<center><b>You need TO login First</b></center>';
  7. include 'login.html';
  8. exit();
  9. }
  10. else{
  11. session_set_cookie_params(1200);
  12. }
  13.  
  14. $user = $_SESSION['myusername'];
  15. ?>
  16. <style>
  17. body {
  18. font-family:Arial, Helvetica, sans-serif;
  19. background:#FFFFF0;
  20. font-size:12px;
  21. color:#000000;
  22. }
  23. .logout {
  24. cursor:pointer;
  25. background:#FFFF00;
  26. border:#FF6600 1px solid;
  27. width:100px;
  28. height:30px;
  29. font-size:14px;
  30. font-weight:bold;
  31. color:#FF6600;
  32. float:right;
  33. text-decoration:none;
  34. font-family:Arial;
  35. font-size:14px;
  36. line-height:30px;
  37. margin:50px 50px 0px 0px;
  38. text-align:center;
  39. }
  40. h1 {
  41. font-family:Arial, Helvetica, sans-serif;
  42. font-size:20px;
  43. color: #FF6600;
  44. text-align:center;
  45. margin:50px auto 0px auto;
  46. font-weight:500;
  47. }
  48. .head {
  49. font-family:Arial, Helvetica, sans-serif;
  50. font-size:14px;
  51. color: #000;
  52. text-align:center;
  53. }
  54. .form {
  55. font-family:Arial, Helvetica, sans-serif;
  56. font-size:12px;
  57. color:#666666;
  58. line-height:18px;
  59. background:#FBFBFB;
  60. width:100%;
  61. padding:20px;
  62. border:#FFCC00 2px solid;
  63. font-weight:bold;
  64. }
  65. .lable {
  66. margin-left:100px;
  67. }
  68. .btn {
  69. cursor:pointer;
  70. background:#E0E0E0;
  71. border:#000 1px solid;
  72. width:100px;
  73. height:30px;
  74. font-size:14px;
  75. font-weight:bold;
  76. color:#000;
  77. float:left;
  78. margin-left:20px;
  79. }
  80. </style>
  81. <title>View Record of Online Application</title><a href="logout.php"><span class="logout">LOGOUT</span> </a><br />
  82. <br />
  83. <br />
  84. <br />
  85. <br />
  86. <h1>Login as&nbsp;&nbsp;<?php echo $user; ?></h1>
  87. <?php
  88. $host="localhost"; // Host name
  89. $username="root"; // Mysql username
  90. $password=""; // Mysql password
  91. $db_name="hnit";
  92. $tbl_name="registration";
  93. $con = mysql_connect($host, $username, $password)or die("cannot connect");
  94. mysql_select_db($db_name)or die("cannot select DB");
  95. $sql="SELECT * FROM $tbl_name ORDER BY id DESC";
  96. $result=mysql_query($sql);
  97. $count=mysql_num_rows($result);
  98.  
  99. if(isset($_GET['delete']) && $_GET['delete'] =='Delete')
  100. {
  101. for($i=0;$i<count($_GET['checkbox']);$i++)
  102. {
  103. $del_id = $checkbox[$i];
  104. $sql = "DELETE FROM $tbl_name WHERE id='$del_id' LIMIT 1";
  105. $result = mysql_query($sql,$con);
  106. if (mysql_query($sql,$con))
  107. {
  108. echo " records is sucessfully Deleted";
  109. }
  110. else{
  111. die('Error: ' . mysql_error());
  112. }
  113. }
  114. if($result){
  115. echo "<meta http-equiv=\"refresh\" content=\"0;URL=del.php\">";
  116. }
  117. }
  118.  
  119. ?>
  120. <form name="form1" method="get" action= "">
  121. <table width="100%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#FF9900" bgcolor="#FBFBFB" class="head">
  122. <tr>
  123. <td height="38" colspan="8" bgcolor="#FFCC00"><strong>RECORDS DISPLAYING FOR ONLINE APPLICATION </strong></td>
  124. </tr>
  125. <tr>
  126. <td width="67" height="38" align="center" bgcolor="#FFFFCC"><strong>SELECT</strong></td>
  127. <td width="48" align="center" bgcolor="#FFFFCC"><strong>Id</strong></td>
  128. <td width="188" align="center" bgcolor="#FFFFCC"><strong>Name</strong></td>
  129. <td width="135" align="center" bgcolor="#FFFFCC"><strong>Email ID </strong></td>
  130. <td width="175" align="center" bgcolor="#FFFFCC"><strong>ADDRESS</strong></td>
  131. <td width="157" align="center" bgcolor="#FFFFCC"><strong>COURSE</strong></td>
  132. <td width="115" align="center" bgcolor="#FFFFCC"><strong>EDUCATION</strong></td>
  133. <td width="143" align="center" bgcolor="#FFFFCC"><strong>PHONE NO </strong></td>
  134. </tr>
  135. <?php while($rows=mysql_fetch_array($result, MYSQL_ASSOC)){ ?>
  136. <tr>
  137. <td height="44" align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value=" <?php echo $rows['id']; ?>"></td>
  138. <td bgcolor="#FFFFFF"><?php echo $rows['id']; ?></td>
  139. <td bgcolor="#FFFFFF"><?php echo $rows['name']; ?></td>
  140. <td bgcolor="#FFFFFF"><?php echo $rows['emailid']; ?></td>
  141. <td bgcolor="#FFFFFF"><?php echo $rows['address']; ?></td>
  142. <td bgcolor="#FFFFFF"><?php echo $rows['course']; ?></td>
  143. <td bgcolor="#FFFFFF"><?php echo $rows['education']; ?></td>
  144. <td bgcolor="#FFFFFF"><?php echo $rows['phoneno']; ?></td>
  145. </tr>
  146. <?php } ?>
  147. <tr>
  148. <td height="58" colspan="8" align="center" bgcolor="#FFFFCC"><input name="delete" type="submit" id="delete" value="Delete" class="btn" style="float:none;"></td>
  149. </tr>
  150. <?php
  151. mysql_close();
  152. ?>
  153. </table>
  154. </form>
you can experiment with the form method=post
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 4th, 2009
0
Re: PRoblem in Delete
thanks for your reply sir but my coding is currently working on localhost but not working on internet why is it so

if your changes work then i will back to you thanks once again
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
manishmannan is offline Offline
58 posts
since Nov 2009
Nov 4th, 2009
0
Re: PRoblem in Delete
you tried this code, change method in the form to 'POST' and the successive changes from $_GET to $_POST like -
if(isset($_POST['delete']) && $_POST['delete'] =='Delete')
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 4th, 2009
0
Re: PRoblem in Delete
but boss my script is not working even on local host after changing with get to post
i am remain with my $_GET Script
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
manishmannan is offline Offline
58 posts
since Nov 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: connecting with mysqli
Next Thread in PHP Forum Timeline: calling different images from one php file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC