954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PRoblem in Delete

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

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

Do you mean delete in an SQL query, or a unlink to delete files?

Will Gresham
Master Poster
755 posts since May 2008
Reputation Points: 96
Solved Threads: 125
 
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'You need TO login First';
include 'login.html';
exit();
}
else{
session_set_cookie_params(1200);
}

$user = $_SESSION['myusername'];
?>
View Record of Online ApplicationLOGOUT




Login as  <?php echo $user; ?>
<?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);

?>

RECORDS DISPLAYING FOR ONLINE APPLICATION
SELECT
Id
Name
Email ID
ADDRESS
COURSE
EDUCATION
PHONE NO

<?php while($rows=mysql_fetch_array($result, MYSQL_ASSOC)){ ?>

<?php echo $rows['id']; ?>
<?php echo $rows['name']; ?>
<?php echo $rows['emailid']; ?>
<?php echo $rows['address']; ?>
<?php echo $rows['course']; ?>
<?php echo $rows['education']; ?>
<?php echo $rows['phoneno']; ?>

<?php } ?>


<?php if($_GET['delete']){
for($i=0;$i";
}
}
mysql_close();

?>

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????

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

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.

$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

network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
 

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

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

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

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

you did the same common mistake..not doing isset on $_POST['btnName'].
your improved code here -

<?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>




<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);

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>

you can experiment with the form method=post

network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
 

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

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

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')

network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
 

but boss my script is not working even on local host after changing with get to post
i am remain with my $_GET Script

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 
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????


so what error you getting on the server?
Again you including the login.html and using <?php echo $user; ?> in the script, $user gets set in the html file??
check with this or post your login.html too here

network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
 

thanks but my problem is not solve

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

is there any change needed in php.ini file to delete records from the database if it happen thn plz tell me

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 



ADMIN PANEL


LOG IN
User

Password

 


Foget Username or Password
Change Password

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

there is no any kind of error occuring in the server even it print the message that records have deleted but still reords is not deleted
My all the commands work properly but still the records are not deleted do somthing take it seriously plzzzzzz

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

No,deleting the rows got nothing to do with php.ini settings. Now I will write how to start debugging step by step.
-first check if you can connect to the mysql on the server; echo the connection object like

$con = mysql_connect(.....,....,..);
echo "Connection=>".$con;

-check you getting the delete query as echo after the delete
-try to execute it in the db,got any error in the mysql with the query syntax.

network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
 

Please use code tags, it makes it easier to read your code.

Also, the code on the first page has a Delete statement, the code above does not. Which code are you using at the moment?

Will Gresham
Master Poster
755 posts since May 2008
Reputation Points: 96
Solved Threads: 125
 

hello friends
1stly i am replying to network
my query works fine like there is a statements in my script like this

<?php if($_GET['delete'] && $_GET['delete'] =='Delete' ){
for($i=0;$i";
}
}
mysql_close();

?>
here i got proper execution of my script even no any kind of error occured
and message prints sucessfully
like
records is sucessfully Deleted
but results is no rows are deleting from the database

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

and this is the same script that work fine on my local host but not on uploading files on internet
what to do??????????
plz help me out
and i need to tell you that my localhost sql version is
MySQL
Server: localhost via TCP/IP
Server version: 5.1.37
Protocol version: 10
User: root@localhost
MySQL charset: UTF-8 Unicode (utf8)

and on internet i am having

localhost
Server version: 5.0.18-nt
Protocol version: 10
Server: localhost via TCP/IP
User: DATABASE@127.0.0.1
MySQL charset: UTF-8 Unicode (utf8)
MySQL connection collation:

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

is there any difference in any both the version of my sql??????

manishmannan
Junior Poster in Training
58 posts since Nov 2009
Reputation Points: 10
Solved Threads: 4
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You