By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

delete query

P: n/a
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
Share this Question
Share on Google+
13 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.