| | |
PRoblem in Delete
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Nov 2009
Posts: 44
Reputation:
Solved Threads: 2
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
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
•
•
Join Date: Nov 2009
Posts: 44
Reputation:
Solved Threads: 2
-1
#3 Nov 3rd, 2009
•
•
•
•
Do you mean delete in an SQL query, or a unlink to delete files?
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 <?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????
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#4 Nov 3rd, 2009
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.
Edit: Please use the code tags
Look your few variable settings, you need to change them to the server values.
PHP Syntax (Toggle Plain Text)
$host="localhost"; // Host name, should be actual db server name now, and not the localhost $username="root"; // Mysql username on the above server $password=""; // Mysql password for the above db server $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
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Nov 2009
Posts: 44
Reputation:
Solved Threads: 2
0
#5 Nov 4th, 2009
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
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
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#7 Nov 4th, 2009
you did the same common mistake..not doing isset on $_POST['btnName'].
your improved code here -
you can experiment with the form method=post
your improved code here -
PHP Syntax (Toggle Plain Text)
<?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 <?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); if(isset($_GET['delete']) && $_GET['delete'] =='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\">"; } } ?> <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 mysql_close(); ?> </table> </form>
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#9 Nov 4th, 2009
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')
if(isset($_POST['delete']) && $_POST['delete'] =='Delete')
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
![]() |
Similar Threads
- mysql - problem using delete (PHP)
- memory leak problem... (C)
- can't delete text from table cells (Site Layout and Usability)
- Aim Problem Need Help (Windows NT / 2000 / XP)
- CDRW Problem (USB Devices and other Peripherals)
- problem with accessing sites (Web Browsers)
- hijacker.exe help, have no clue what's causing problem and don't want to delete good (Viruses, Spyware and other Nasties)
- Can't delete three .tmp files (Windows 95 / 98 / Me)
- CommonNames problem (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: connecting with mysqli
- Next Thread: calling different images from one php file
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code codingproblem cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select send server sessions sms snippet soap source space speed sql static structure syntax system table tutorial up-to-date update upload url validation validator variable video web wordpress xml youtube





