473,473 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

delete query

mac
hi all,
im creating a form wich wil upload images to a folder and
their names and other details to a database.
im able to do uploading but my delete function is not working, please
can anybody tell me mistake n help me??

image_uploader.php
<?
if(isset($_REQUEST['sub']))
{
//print "<pre>";
//print_r ($_FILES);
$dir_path=$_SERVER['DOCUMENT_ROOT']."/uploadproject/images/".
$_FILES['img1']['name'];
//print $dir_path;
if(move_uploaded_file($_FILES['img1']['tmp_name'],$dir_path))
{
//print "sucessfull";
}
else
{
//print "error";
}
mysql_connect("localhost","root","");
mysql_select_db("mac");
$date1=date("Y-m-d H:i:s");
$sql="insert into images(imagename,image_type,created_date)
values('".$_FILES['img1']['name']."','".$_FILES['img1']['type']."','".
$date1."')";
mysql_query($sql);
print "<font color='blue' size='3'>Image Added sucessfully...</
font>";
}
?>
<form name="frm" action="" method="post" enctype="multipart/form-
data">
<table border="1" align="center">
<tr><td colspan="2" align="center">Image upload</td></tr>
<tr><td>Choose An Image</td><td><input type="file" name="img1" /</
td>
</tr><tr><td></td><td><input type="submit" name="sub" value="Add
Image" />&nbsp;&nbsp;<a href="show_images.php" target="_blank">Show
images</a>
&nbsp;&nbsp;<a href="delete_images.php" target="_blank">Delete images</
a></td>

</table>
</form>

show_images.php
<?
mysql_connect("localhost","root","");
mysql_select_db("mac");
$rs=mysql_query("select * from images");

$count=mysql_num_rows($rs);
$i=1;
while($row=mysql_fetch_array($rs))
{
if($i==1 || $i==4)
{

if($i==4)
{
$i=1;
}
?>
</tr><tr>
<?
}
else
{
//print $i;
}
$i=$i+1;
?>
<td><img width="100" height="100" src="images/<?=
$row['imagename']?>" /></td>
<?
}

?>
</tr>
<tr<td<a href="img_uploader.php"Back </a</td</tr>
</table>

--------------------------
delete_images.php
---some problem with this page
<?php
mysql_connect("localhost","root","");
mysql_select_db("mac");

@$id = $_POST["id"];
//@$delete = $_POST["delete"];
if ($id) {
mysql_connect("localhost","root","");
mysql_select_db("mac");

$sql = "DELETE FROM images WHERE id='$id'";
mysql_query($sql);
print "Deleted ". $img1 ." from database";
}
mysql_connect("localhost","root","");
mysql_select_db("mac");
$sql = "SELECT imagename FROM images";
$result = mysql_query($sql);
?>
<form method="post" action="show_images.php">
Picture: <select name="imagename">
<?php
while ($row = mysql_fetch_array(($result), MYSQL_ASSOC))
print "<option>" . $row["imagename"];
?>
</select>
<input type="submit" name="delete" value="delete">
</form>
-----------------------------



Sep 13 '08 #1
13 1841
mac wrote:
hi all,
Hello.
im creating a form wich wil upload images to a folder and
their names and other details to a database.
im able to do uploading but my delete function is not working, please
can anybody tell me mistake n help me??
<snip irrelevant code>

Just the delete code would have sufficed.
>
--------------------------
delete_images.php
---some problem with this page
What problems? Be more specific; although, below, there are several
problems.
<?php
mysql_connect("localhost","root","");
mysql_select_db("mac");
$linkId = mysql_connect(...);

Do some error checking. See PHP manual: mysql_error().
>
@$id = $_POST["id"];
//@$delete = $_POST["delete"];
$id = isset($_POST['id']) ? intval($_POST['id']) : false;

Check if an array element exists with isset(), the @ error suppression
is unnecessary, not to mention slow. You also need to make sure you're
working with an int, in this case, so as to prevent SQL injection below.
if ($id) {
if ($id !== false) {
mysql_connect("localhost","root","");
mysql_select_db("mac");
Why are you making another connection? You already make an active
connection to the database just a few lines above. You only need one.
>
$sql = "DELETE FROM images WHERE id='$id'";
mysql_query($sql);
print "Deleted ". $img1 ." from database";
}
mysql_connect("localhost","root","");
mysql_select_db("mac");
Again, you're attempting to make another connection to the database.
This is unnecessary.
$sql = "SELECT imagename FROM images";
$result = mysql_query($sql);
?>
<form method="post" action="show_images.php">
Picture: <select name="imagename">
<?php
while ($row = mysql_fetch_array(($result), MYSQL_ASSOC))
while ($imagename = mysql_fetch_row($result))

You only have one row in the result set, so mysql_fetch_array() is
unnecessary here.
print "<option>" . $row["imagename"];
echo "<option>{$imagename}</option>";
?>
</select>
<input type="submit" name="delete" value="delete">
</form>
-----------------------------
Besides the fact that you didn't say what was going wrong, exactly,
your code is being used improperly, so you should probably fix that up
first, then you can figure out if there's a problem with your query,
if any.

--
Curtis
Sep 13 '08 #2
Curtis wrote:
> print "<option>" . $row["imagename"];

echo "<option>{$imagename}</option>";
There is nothing wrong with

print '<option>' . $row['imagename'] . '</option>';

It is a matter of style. Personally, I prefer this style because it
clearly shows to me when I read it what are text pieces and what are php
variable pieces.
Sep 13 '08 #3
mac wrote:
hi all,
im creating a form wich wil upload images to a folder and
their names and other details to a database.
im able to do uploading but my delete function is not working, please
can anybody tell me mistake n help me??
Hello Mac.
It would be easier for us if you told us exactly what errors or what you
are seeing to make you think it does not work.
Also your MySQL table structure might help too.
But with that said and from what I am seeing in your code here are a few
ideas.
>
image_uploader.php
<?
if(isset($_REQUEST['sub']))
{
//print "<pre>";
//print_r ($_FILES);
$dir_path=$_SERVER['DOCUMENT_ROOT']."/uploadproject/images/".
$_FILES['img1']['name'];
//print $dir_path;
if(move_uploaded_file($_FILES['img1']['tmp_name'],$dir_path))
{
//print "sucessfull";
}
else
{
//print "error";
}
mysql_connect("localhost","root","");
mysql_select_db("mac");
$date1=date("Y-m-d H:i:s");
$sql="insert into images(imagename,image_type,created_date)
values('".$_FILES['img1']['name']."','".$_FILES['img1']['type']."','".
$date1."')";
mysql_query($sql);
print "<font color='blue' size='3'>Image Added sucessfully...</
font>";
}
?>

<form name="frm" action="" method="post" enctype="multipart/form-
data">
<table border="1" align="center">
<tr><td colspan="2" align="center">Image upload</td></tr>
<tr><td>Choose An Image</td><td><input type="file" name="img1" /</
td>
</tr><tr><td></td><td><input type="submit" name="sub" value="Add
Image" />&nbsp;&nbsp;<a href="show_images.php" target="_blank">Show
images</a>
&nbsp;&nbsp;<a href="delete_images.php" target="_blank">Delete images</
a></td>

</table>
</form>

--------------------------
delete_images.php
---some problem with this page
<?php
mysql_connect("localhost","root","");
mysql_select_db("mac");

@$id = $_POST["id"];
//@$delete = $_POST["delete"];
if ($id) {
mysql_connect("localhost","root","");
mysql_select_db("mac");

$sql = "DELETE FROM images WHERE id='$id'";
mysql_query($sql);
print "Deleted ". $img1 ." from database";
}
mysql_connect("localhost","root","");
mysql_select_db("mac");
$sql = "SELECT imagename FROM images";
$result = mysql_query($sql);
?>
<form method="post" action="show_images.php">
Picture: <select name="imagename">
<?php
while ($row = mysql_fetch_array(($result), MYSQL_ASSOC))
print "<option>" . $row["imagename"];
?>
</select>
<input type="submit" name="delete" value="delete">
</form>
-----------------------------
Ok from what I can tell you are linking to the delete_images.php page
which gives you a list of ALL your images. You then want to select the
image and click the delete button to have it deleted. If this is
correct, you have a few problems with your processing.

The last form:
<form method="post" action="show_images.php">
Picture: <select name="imagename">
<?php
while ($row = mysql_fetch_array(($result), MYSQL_ASSOC))
print "<option>" . $row["imagename"];
?>
</select>
<input type="submit" name="delete" value="delete">
</form>
-----------------------------
Needs to refer to the same delete_image.php page.

Change:
<form method="post" action="show_images.php">
to:
<form method="post" action="delete_images.php">

Secondly you will need to POST the $id value back to the page or there
will be no reference to grab the image. You will need to rewrite your
<optionsyntax to include the $id.

change:
print "<option>" . $row["imagename"];
to:
print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];

This will create an array imagename[] (name or your select tag) and
place it in the $_POST variable.

Then in your script extract 'id' by replacing:
@$id = $_POST["id"];
with
$id = $_POST['imagename'];

This should delete your image, you can verify by looking at the list or
your DB.

Now with THAT said, this rewrite is nothing close to being the correct
way to perform this action, there are better ways to go about it, but I
am in a hurry and don't have time to point them all out. But that is
the basics.

If you don't understand what the login of the rewrite, then post back
and I will explain a bit later.

Good Luck
Scotty
Sep 13 '08 #4
FutureShock wrote:
change:
print "<option>" . $row["imagename"];
to:
print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];
I have always disliked quoting characters when it is not necessary to do
so. PHP, through the use of single and double quotes, provides a better
way.

print '<option VALUE="' . $row['id'] . '">' . $row['imagename'] .
'</option>';

Again, that is a matter of taste and style, but when I can avoid
quoting, I do.
Sep 13 '08 #5
sheldonlg wrote:
Curtis wrote:
>> print "<option>" . $row["imagename"];

echo "<option>{$imagename}</option>";

There is nothing wrong with

print '<option>' . $row['imagename'] . '</option>';

It is a matter of style. Personally, I prefer this style because it
clearly shows to me when I read it what are text pieces and what are php
variable pieces.
And I never said it was wrong, I just typed it my way. The point of
that line was to show the use of the changed variable.

--
Curtis
Sep 13 '08 #6
sheldonlg wrote:
FutureShock wrote:
>change:
print "<option>" . $row["imagename"];
to:
print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];

I have always disliked quoting characters when it is not necessary to do
so. PHP, through the use of single and double quotes, provides a better
way.

print '<option VALUE="' . $row['id'] . '">' . $row['imagename'] .
'</option>';

Again, that is a matter of taste and style, but when I can avoid
quoting, I do.
Well sheldonlg

I could of went though the whole script and did it up the way I would of
preferred it, but one I did not have the time and two, the idea was to
let him know how the logic in his code was wrong and how to fix it. I
think I even stated that at the bottom of my reply.

What you pointed out is valid idea, but not in the context of this thread.

Scotty
Sep 14 '08 #7
FutureShock wrote:
sheldonlg wrote:
>FutureShock wrote:
>>change:
print "<option>" . $row["imagename"];
to:
print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];

I have always disliked quoting characters when it is not necessary to
do so. PHP, through the use of single and double quotes, provides a
better way.

print '<option VALUE="' . $row['id'] . '">' . $row['imagename'] .
'</option>';

Again, that is a matter of taste and style, but when I can avoid
quoting, I do.

Well sheldonlg

I could of went though the whole script and did it up the way I would of
preferred it, but one I did not have the time and two, the idea was to
let him know how the logic in his code was wrong and how to fix it. I
think I even stated that at the bottom of my reply.

What you pointed out is valid idea, but not in the context of this thread.

Scotty
Scotty,

If you didn't have time to determine if your comments were related to
the problem at hand or not, you shouldn't be complaining about Sheldon's
comments on your style. His post was more on topic than yours was.

For the record, I have used both syntaxes. What I use on a particular
project depends on a lot of things. But I'm flexible enough that either
is appropriate.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 14 '08 #8
Jerry Stuckle wrote:
FutureShock wrote:
>sheldonlg wrote:
>>FutureShock wrote:

change:
print "<option>" . $row["imagename"];
to:
print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];

I have always disliked quoting characters when it is not necessary to
do so. PHP, through the use of single and double quotes, provides a
better way.

print '<option VALUE="' . $row['id'] . '">' . $row['imagename'] .
'</option>';

Again, that is a matter of taste and style, but when I can avoid
quoting, I do.

Well sheldonlg

I could of went though the whole script and did it up the way I would
of preferred it, but one I did not have the time and two, the idea was
to let him know how the logic in his code was wrong and how to fix it.
I think I even stated that at the bottom of my reply.

What you pointed out is valid idea, but not in the context of this
thread.

Scotty

Scotty,

If you didn't have time to determine if your comments were related to
the problem at hand or not, you shouldn't be complaining about Sheldon's
comments on your style. His post was more on topic than yours was.

For the record, I have used both syntaxes. What I use on a particular
project depends on a lot of things. But I'm flexible enough that either
is appropriate.
Jerry I am sure Sheldon is very happy that you have taken up a cause to
protect him, and after I reread my post I realized it sounded worse then
it was meant. It is good to have different styles of doing things
posted out, it is a great way of learning well.... different styles of
doing things. And in hindsight I should of embraced it.

As for his comment being more on topic then mine, I think you may be a
bit over defensive of Sheldon, unless I read the OP question wrong.

Lets see...

"hi all,
im creating a form wich wil upload images to a folder and
their names and other details to a database.
im able to do uploading but my delete function is not working, please
can anybody tell me mistake n help me??"

You suppose I could of mistaken that he wanted help on why his delete
function did not working, instead of wanting help on the entire script
he posted? Possibly.

So I posted my comment on how to make it work. Sheldon (sorry for
tossing him back in to it), made a comment on style, not functionality.

And I did not say I did not have time to help him with his problem. I
wanted to show him how to make what he had work, and I did, but rather
did not have time to rewrite his script to my style.

But it's OK Jerry, you still provide a valuable service to this NG and I
have learned a few things from you.

Keep on Keeping on.

Scotty
Sep 14 '08 #9
FutureShock wrote:
Jerry Stuckle wrote:
>FutureShock wrote:
>>sheldonlg wrote:
FutureShock wrote:

change:
print "<option>" . $row["imagename"];
to:
print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];

I have always disliked quoting characters when it is not necessary
to do so. PHP, through the use of single and double quotes,
provides a better way.

print '<option VALUE="' . $row['id'] . '">' . $row['imagename'] .
'</option>';

Again, that is a matter of taste and style, but when I can avoid
quoting, I do.

Well sheldonlg

I could of went though the whole script and did it up the way I would
of preferred it, but one I did not have the time and two, the idea
was to let him know how the logic in his code was wrong and how to
fix it. I think I even stated that at the bottom of my reply.

What you pointed out is valid idea, but not in the context of this
thread.

Scotty

Scotty,

If you didn't have time to determine if your comments were related to
the problem at hand or not, you shouldn't be complaining about
Sheldon's comments on your style. His post was more on topic than
yours was.

For the record, I have used both syntaxes. What I use on a particular
project depends on a lot of things. But I'm flexible enough that
either is appropriate.
Jerry I am sure Sheldon is very happy that you have taken up a cause to
protect him, and after I reread my post I realized it sounded worse then
it was meant. It is good to have different styles of doing things
posted out, it is a great way of learning well.... different styles of
doing things. And in hindsight I should of embraced it.
I am not "taking up a cause to protect him". Rather, I agree with him
on this (and other things).
As for his comment being more on topic then mine, I think you may be a
bit over defensive of Sheldon, unless I read the OP question wrong.

Lets see...

"hi all,
im creating a form wich wil upload images to a folder and
their names and other details to a database.
im able to do uploading but my delete function is not working, please
can anybody tell me mistake n help me??"

You suppose I could of mistaken that he wanted help on why his delete
function did not working, instead of wanting help on the entire script
he posted? Possibly.

So I posted my comment on how to make it work. Sheldon (sorry for
tossing him back in to it), made a comment on style, not functionality.

And I did not say I did not have time to help him with his problem. I
wanted to show him how to make what he had work, and I did, but rather
did not have time to rewrite his script to my style.

But it's OK Jerry, you still provide a valuable service to this NG and I
have learned a few things from you.

Keep on Keeping on.

Scotty
And you made irrelevant changes to the style which could serve to
confuse the original op, and not at all within the context of what the
op asked. It also had nothing to do with the changes necessary to make
the function work. However, you did not clarify that.

Sheldon's comment what much more in context - it pointed out how this
particular change was immaterial and only a matter of style. It neither
helped nor hindered the function, contrary to what your post implied,
but could easily have confused the op. I would have made the same
comment had Sheldon not beat me to it.

And if you don't have the time to respond with good code, perhaps you
shouldn't respond at all - or at least respond later when you do have
the time.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 14 '08 #10
FutureShock wrote:
Jerry Stuckle wrote:
>FutureShock wrote:
>>sheldonlg wrote:
FutureShock wrote:

change:
print "<option>" . $row["imagename"];
to:
print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];

I have always disliked quoting characters when it is not necessary
to do so. PHP, through the use of single and double quotes,
provides a better way.

print '<option VALUE="' . $row['id'] . '">' . $row['imagename'] .
'</option>';

Again, that is a matter of taste and style, but when I can avoid
quoting, I do.

Well sheldonlg

I could of went though the whole script and did it up the way I would
of preferred it, but one I did not have the time and two, the idea
was to let him know how the logic in his code was wrong and how to
fix it. I think I even stated that at the bottom of my reply.

What you pointed out is valid idea, but not in the context of this
thread.

Scotty

Scotty,

If you didn't have time to determine if your comments were related to
the problem at hand or not, you shouldn't be complaining about
Sheldon's comments on your style. His post was more on topic than
yours was.

For the record, I have used both syntaxes. What I use on a particular
project depends on a lot of things. But I'm flexible enough that
either is appropriate.
Jerry I am sure Sheldon is very happy that you have taken up a cause to
....it is MOST unusual and has happened TWICE in one day :-) -- not
that is unwelcome to get support.
protect him, and after I reread my post I realized it sounded worse then
it was meant. It is good to have different styles of doing things
posted out, it is a great way of learning well.... different styles of
doing things. And in hindsight I should of embraced it.

As for his comment being more on topic then mine, I think you may be a
I didn't understand that one at all. Yours addressed the functionality
and I made a side comment on style that I feel would be clearer to read.
bit over defensive of Sheldon, unless I read the OP question wrong.

Lets see...

"hi all,
im creating a form wich wil upload images to a folder and
their names and other details to a database.
im able to do uploading but my delete function is not working, please
can anybody tell me mistake n help me??"

You suppose I could of mistaken that he wanted help on why his delete
function did not working, instead of wanting help on the entire script
he posted? Possibly.

So I posted my comment on how to make it work. Sheldon (sorry for
tossing him back in to it), made a comment on style, not functionality.
Exactly, and that was all I intended to say.
Sep 14 '08 #11
Jerry Stuckle wrote:
FutureShock wrote:
>Jerry Stuckle wrote:
>>FutureShock wrote:
sheldonlg wrote:
FutureShock wrote:
>
>change:
>print "<option>" . $row["imagename"];
>to:
>print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];
>
I have always disliked quoting characters when it is not necessary
to do so. PHP, through the use of single and double quotes,
provides a better way.
>
print '<option VALUE="' . $row['id'] . '">' . $row['imagename'] .
'</option>';
>
Again, that is a matter of taste and style, but when I can avoid
quoting, I do.

Well sheldonlg

I could of went though the whole script and did it up the way I
would of preferred it, but one I did not have the time and two, the
idea was to let him know how the logic in his code was wrong and how
to fix it. I think I even stated that at the bottom of my reply.

What you pointed out is valid idea, but not in the context of this
thread.

Scotty
Scotty,

If you didn't have time to determine if your comments were related to
the problem at hand or not, you shouldn't be complaining about
Sheldon's comments on your style. His post was more on topic than
yours was.

For the record, I have used both syntaxes. What I use on a
particular project depends on a lot of things. But I'm flexible
enough that either is appropriate.
Jerry I am sure Sheldon is very happy that you have taken up a cause
to protect him, and after I reread my post I realized it sounded worse
then it was meant. It is good to have different styles of doing
things posted out, it is a great way of learning well.... different
styles of doing things. And in hindsight I should of embraced it.

I am not "taking up a cause to protect him". Rather, I agree with him
on this (and other things).
>As for his comment being more on topic then mine, I think you may be a
bit over defensive of Sheldon, unless I read the OP question wrong.

Lets see...

"hi all,
im creating a form wich wil upload images to a folder and
their names and other details to a database.
im able to do uploading but my delete function is not working, please
can anybody tell me mistake n help me??"

You suppose I could of mistaken that he wanted help on why his delete
function did not working, instead of wanting help on the entire script
he posted? Possibly.

So I posted my comment on how to make it work. Sheldon (sorry for
tossing him back in to it), made a comment on style, not functionality.

And I did not say I did not have time to help him with his problem. I
wanted to show him how to make what he had work, and I did, but rather
did not have time to rewrite his script to my style.

But it's OK Jerry, you still provide a valuable service to this NG and
I have learned a few things from you.

Keep on Keeping on.

Scotty

And you made irrelevant changes to the style which could serve to
confuse the original op, and not at all within the context of what the
op asked. It also had nothing to do with the changes necessary to make
the function work. However, you did not clarify that.

Sheldon's comment what much more in context - it pointed out how this
particular change was immaterial and only a matter of style. It neither
helped nor hindered the function, contrary to what your post implied,
but could easily have confused the op. I would have made the same
comment had Sheldon not beat me to it.
Actually, Jerry, that is not true. He modified the code to add a value=
statement to the option. I did not say, nor even believe, that this
change was "immaterial". What he did was a **functional change**. In
doing so, he employed quoting characters -- which prompted my comment on
style.

Here is what he said:
>>>>>change:
>print "<option>" . $row["imagename"];
>to:
>print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];
So, Jerry, while I welcome your support, in this case Scotty is correct.
Sep 14 '08 #12
Jerry Stuckle wrote:
FutureShock wrote:
>Jerry Stuckle wrote:
>>FutureShock wrote:
sheldonlg wrote:
FutureShock wrote:
>
>change:
>print "<option>" . $row["imagename"];
>to:
>print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];
>
I have always disliked quoting characters when it is not necessary
to do so. PHP, through the use of single and double quotes,
provides a better way.
>
print '<option VALUE="' . $row['id'] . '">' . $row['imagename'] .
'</option>';
>
Again, that is a matter of taste and style, but when I can avoid
quoting, I do.

Well sheldonlg

I could of went though the whole script and did it up the way I
would of preferred it, but one I did not have the time and two, the
idea was to let him know how the logic in his code was wrong and how
to fix it. I think I even stated that at the bottom of my reply.

What you pointed out is valid idea, but not in the context of this
thread.

Scotty
Scotty,

If you didn't have time to determine if your comments were related to
the problem at hand or not, you shouldn't be complaining about
Sheldon's comments on your style. His post was more on topic than
yours was.

For the record, I have used both syntaxes. What I use on a
particular project depends on a lot of things. But I'm flexible
enough that either is appropriate.
Jerry I am sure Sheldon is very happy that you have taken up a cause
to protect him, and after I reread my post I realized it sounded worse
then it was meant. It is good to have different styles of doing
things posted out, it is a great way of learning well.... different
styles of doing things. And in hindsight I should of embraced it.

I am not "taking up a cause to protect him". Rather, I agree with him
on this (and other things).
>As for his comment being more on topic then mine, I think you may be a
bit over defensive of Sheldon, unless I read the OP question wrong.

Lets see...

"hi all,
im creating a form wich wil upload images to a folder and
their names and other details to a database.
im able to do uploading but my delete function is not working, please
can anybody tell me mistake n help me??"

You suppose I could of mistaken that he wanted help on why his delete
function did not working, instead of wanting help on the entire script
he posted? Possibly.

So I posted my comment on how to make it work. Sheldon (sorry for
tossing him back in to it), made a comment on style, not functionality.

And I did not say I did not have time to help him with his problem. I
wanted to show him how to make what he had work, and I did, but rather
did not have time to rewrite his script to my style.

But it's OK Jerry, you still provide a valuable service to this NG and
I have learned a few things from you.

Keep on Keeping on.

Scotty

And you made irrelevant changes to the style which could serve to
confuse the original op, and not at all within the context of what the
op asked. It also had nothing to do with the changes necessary to make
the function work. However, you did not clarify that.

Sheldon's comment what much more in context - it pointed out how this
particular change was immaterial and only a matter of style. It neither
helped nor hindered the function, contrary to what your post implied,
but could easily have confused the op. I would have made the same
comment had Sheldon not beat me to it.

And if you don't have the time to respond with good code, perhaps you
shouldn't respond at all - or at least respond later when you do have
the time.
Jerry

Well then maybe we are talking about something different then, maybe
what Curtis and him where talking about. The line I wrote in the code
was absolutely necessary for that he was trying to do.

He (the OP) had:

print "<option>" . $row["imagename"];

which you know won't return the $id he was looking for in the $_POST.
I told him to change it to:

print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];

so he would have access to the id. How this change is irrelevant I am
lost. If you could explain I would be most humbled.

Sheldon simply made a comment about the quotes and a different style to
use. No more, no less.

Scotty
Sep 14 '08 #13
sheldonlg wrote:
FutureShock wrote:
>Jerry Stuckle wrote:
>>FutureShock wrote:
sheldonlg wrote:
FutureShock wrote:
>
>change:
>print "<option>" . $row["imagename"];
>to:
>print "<option VALUE=\"".$row["id"]."\">" . $row["imagename"];
>
I have always disliked quoting characters when it is not necessary
to do so. PHP, through the use of single and double quotes,
provides a better way.
>
print '<option VALUE="' . $row['id'] . '">' . $row['imagename'] .
'</option>';
>
Again, that is a matter of taste and style, but when I can avoid
quoting, I do.

Well sheldonlg

I could of went though the whole script and did it up the way I
would of preferred it, but one I did not have the time and two, the
idea was to let him know how the logic in his code was wrong and how
to fix it. I think I even stated that at the bottom of my reply.

What you pointed out is valid idea, but not in the context of this
thread.

Scotty
Scotty,

If you didn't have time to determine if your comments were related to
the problem at hand or not, you shouldn't be complaining about
Sheldon's comments on your style. His post was more on topic than
yours was.

For the record, I have used both syntaxes. What I use on a
particular project depends on a lot of things. But I'm flexible
enough that either is appropriate.
Jerry I am sure Sheldon is very happy that you have taken up a cause to

...it is MOST unusual and has happened TWICE in one day :-) -- not
that is unwelcome to get support.
hehe.
I was actually just playing around making light of the subject,
sometimes these threads can get pretty ugly.
>
>protect him, and after I reread my post I realized it sounded worse
then it was meant. It is good to have different styles of doing
things posted out, it is a great way of learning well.... different
styles of doing things. And in hindsight I should of embraced it.

As for his comment being more on topic then mine, I think you may be a

I didn't understand that one at all. Yours addressed the functionality
and I made a side comment on style that I feel would be clearer to read.
And you where spot on. It was one of those times when I clicked the
submit button and wish I hadn't. Just a knee JERK reaction.
Sadly enough, I never even use print(). I was narrowly thinking that if
he was used to the print statement, I would stick with it.
>
>bit over defensive of Sheldon, unless I read the OP question wrong.

Lets see...

"hi all,
im creating a form wich wil upload images to a folder and
their names and other details to a database.
im able to do uploading but my delete function is not working, please
can anybody tell me mistake n help me??"

You suppose I could of mistaken that he wanted help on why his delete
function did not working, instead of wanting help on the entire script
he posted? Possibly.

So I posted my comment on how to make it work. Sheldon (sorry for
tossing him back in to it), made a comment on style, not functionality.

Exactly, and that was all I intended to say.
And I think learning good style is a good foundation for readable &
debugggable (is that a word) code.

Peace Out

Scotty
Sep 14 '08 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB...
2
by: Joe Del Medico | last post by:
I have two tables A & B and I want to delete all the records in A that are not in B. Can I do this in the query builder? It seems like a simple problem. I can easily find the records in A that...
5
by: ms | last post by:
Why does this select query return the correct records but when I make it a delete query I get a msgbox with "Could not delete from specified tables". SELECT BMIDLog.* FROM stageBMIDLog INNER...
2
by: Dave Burt | last post by:
Hi, Access officionados, I'm new here, so please cut me slack/gently tell me off if I'm out of line or in the wrong place. OK, here's something that seems silly (and is also problematic to...
8
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a...
13
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything...
3
by: Kevin M | last post by:
I have one table and have created a form from that table. Also, I have created a delete query. I want to but a button on the form which will delete all records from the table; however, I cannot get...
1
by: Matt | last post by:
I am writing a DELETE statement and I want to filter the records using another SELECT statement. My SELECT statement is a GROUP BY query that grabs all social security numbers from the "Data...
5
by: Bob Bridges | last post by:
Start with two tables, parent records in one and child records in the other, a one-to-many relationship. Create a select statement joining the two. Display the query in datasheet mode. When I...
3
by: Phil Stanton | last post by:
I have a form based on a complex query (Lots of tables) If I delete a record, everything appears to be OK. Get the message "Youa are about to delete 1 record ....". I say yes. The record count...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.