Jump to content

Recommended Posts

I have a script here, I am working on an approval/decline system now.
The idea is, whenever someone enters something new into the database, it does a bit, it gives the file name, a name, it does a url to the file, whatever.  I have a whole system set up for that, now I have an admin page to decline approve new entries, I have a place in the db under the proper table called approval it's default is 0.  I am having trouble doing 2 things, I have queried it, but I am having trouble making it work, I also need to know, how do I make new entries be tied into some new system to delete the data when it is declined. Because there will be new ones appearing here each time, I don't know how it will discern which entries are which, all I know is that it will pull up all entries with 0, I want if he accepts 1 it changes to 1, if he declines, it deletes the information, and deletes the file location as well.  What I need to figure out though is how to get the new entries, to where they are tied in with whatever I use for decline/approve, I also need to know how to get this query to work properly.
[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Approval</title>
</head>
<body>
<h3>Welcome Bobby</h3>
<p>These are recently pending database entries, please accept/decline.  Please note declined entries are automatically permanently deleted from the database.</p>
<?php
$connect = mysql_connect("localhost", "######", "######");
$select = mysql_select_db("funnyemailforwards");
$errorhandler = "";
$management = true;
if (!$connect || !$select) {
$errorhandler = "The database could not connect, or was not selected<br />";
$management = false;
}


if ($management == true) {
$query = mysql_query("SELECT * FROM `fileinfo` WHERE approval = '0'";);
if (mysql_num_rows($query)) {
while($row = mysql_fetch_assoc($query)) {
            extract($row);
}


}
}


if ($errorhandler != "") {
echo "$errorhandler";
$management = false;
}



?>

</body>
</html>[/code]
The first thing is building the general query, the second, is I know I am going to make it output a form for each entry, but I don't know how to make it work only with the entrys it supposed to, seeing that every entry will be different I Don't understand the general theory behidn this part.  And about the query, am I atleast on the right track?
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/
Share on other sites

So... you have people submitting something which is entered into a database table with an "approval" column with an initial setting of 0, right?  Your "...WHERE approval=0" query seems fine.  For your admin page where the administrator approves/declines submissions, you could create a talbe-in-a-form with checkboxes near each of the entries.  Upon submission of the form, a script goes through each of the $_POSTed checkboxes and either changes "approval" to 1 or deletes the entry.
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54085
Share on other sites

[quote author=businessman332211@hotmail.com link=topic=99699.msg392775#msg392775 date=1152215446]
What I don't currently understand is how to make sure it's set to each specific entry, if they click to change one of them over to approved, but want to leave another until later, how will I be able to tell them the difference in each other.
[/quote]

Okay, just a second... I have an idea; I'll type up some code.
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54093
Share on other sites

Here you go:

Use radio buttons.  Make a form with a table with each of the enteries.  Define the radio button name to be like a PHP array element and the values to on/off, true/false, whatever.  Don't have any of the radio buttons set.  Then, when the admin fills out the form, only the entries where he's selected a radio button will show up in the $_POST variable.

Take a look at this example; it just shows how to use the radio buttons w/ the ids:
[code]
<html><body>
<?php

if (isset($_POST['approval'])) echo '<pre>'.print_r($_POST['approval'],TRUE),'</pre>';

?>

<form method=POST>
allow <input type="radio" name="approval[8]" value="yes"> - deny <input type="radio" name="approval[8]" value="no"><br>
allow <input type="radio" name="approval[9]" value="yes"> - deny <input type="radio" name="approval[9]" value="no"><br>
allow <input type="radio" name="approval[2]" value="yes"> - deny <input type="radio" name="approval[2]" value="no"><br>
allow <input type="radio" name="approval[3]" value="yes"> - deny <input type="radio" name="approval[3]" value="no"><br>
allow <input type="radio" name="approval[5]" value="yes"> - deny <input type="radio" name="approval[5]" value="no"><br>
allow <input type="radio" name="approval[7]" value="yes"> - deny <input type="radio" name="approval[7]" value="no"><br>
allow <input type="radio" name="approval[x]" value="yes"> - deny <input type="radio" name="approval[x]" value="no"><br>
<input type=submit>
</form>
</body></html>[/code]

Outputs:

[code]
Array
(
    [8] => yes
    [9] => yes
    [2] => no
    [3] => no
    [x] => yes
)
allow (x) - deny ( )
allow (x) - deny ( )
allow ( ) - deny (x)
allow ( ) - deny (x)
allow ( ) - deny ( )
allow ( ) - deny ( )
allow (x) - deny ( )[/code]
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54099
Share on other sites

[code]<h3>Welcome Bobby</h3>
<p>These are recently pending database entries, please accept/decline.  Please note declined entries are automatically permanently deleted from the database.</p>
<?php
$connect = mysql_connect("#####", "#####", "#######");
$select = mysql_select_db("funnyemailforwards");
$errorhandler = "";
$management = true;
if (!$connect || !$select) {
$errorhandler = "The database could not connect, or was not selected<br />";
$management = false;
}


$result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC");
echo "<form name=\"dataupdating\" action=\"approval.php\" method=\"post\">";
while ($row = mysql_fetch_assoc($result))
{
extract($row);
$date = date("m/d/y");
$site = "http://www.funnyemailforwards.com/apex/";
$funnyurl = $site . $funnyurl;
echo "<ul>";
echo "<li><a href=" . '"' . $funnyurl . '"' . 'target="_blank">' . $nameoffunny . "</a></li>";
echo "<li>" . $date . "</li>";
echo "<li><input type=\"radio\" name=\"approve_{$row['id']}\" value=\"1\">Approve</li>";
echo "<li><input type=\"radio\" name=\"approve_{$row['id']}\" value=\"0\">Decline</li>";
echo "</ul>"; 
}
echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">";
echo "</form>";


if ($errorhandler != "") {
echo "$errorhandler";
$management = false;
}



?>[/code]
Based on your advice and one other persons I wrote up this, it properly displays ALL of the information like it should.  What I am wondering now, is this what you meant, something like
[code]
<?php
if (isset($update)) {
//1 query to change that character
//1 query to deleted what needs to be deleted and unlink the proper files.
//Right
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54356
Share on other sites

something like
[code]
while (decline_$row['id']) {
// delete from, remove file
}
while (approve_$row['id]) {
// Changes proper character to update database
}

[/code]
The one thing I don't understand, is how would I format the query for decline would it be
[code]
if (isset($_POST['update])) {
DELETE * FROM fileinfo WHERE decline_$row['id'];
and then my file delete like
unlink($fileurl);  // my file url is the full url http://www.funnyemailforwards.com/apex/uploads/filename.ext
and then to update I could have

UPDATE approval FROM fileinfo WHERE accept_$row['id] VALUES (1);
}
Is this somethign along the lines of how it would go.[/code]
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54360
Share on other sites


Why did you go with the [b]approve_n[/b] variables?  I think the array would be easier.

[code]
<?php

// Assuming approval is an array, the key is the id of the entry, and the value is 0 or 1:

foreach ($approval as $key => $value) {
    if ($value) {
        // Your SQL.  If you keep the file name as part of the db row, you may need to retreive it first, then unlink it.
        mysql_query('DELETE FROM fileinfo WHERE id='.$key);
    } else {
        mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key);
    }
}

?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54388
Share on other sites

Well, in the HTML you typed up there, you have PHP generating INPUT element names like "approve_123" which means you'll have to find every instance of array element (approve_*) within $_POST[] ($_POST['approve_*']).  It would just be easier to use a single array for the radio button form elements:

[code]
<input type=radio name="approval[8]" value="0"> <input type=radio name="approval[8]" value="1">
[/code]

Where the "8" in that example would be the id of the entry in the database.  All of the radio button values that get set will reside in the variable $_POST['approval'].  So when you loop through the $_POST'ed variable, all you'd need is this:
[code]
<?php

// Assuming approval is an array, the key is the id of the entry, and the value is 0 or 1:

foreach ($_POST['approval'] as $key => $value) {
    if ($value) {
        mysql_query('DELETE FROM fileinfo WHERE id='.$key);
    } else {
        mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key);
    }
}

?>[/code]

Did you notice the print_r of the array a few posts back?  See how the approval[n] array is set up?  You probably know that you can use form element names of the form "element_name[]" to return data from multiple elements of the same name into an array, right?  So that's all we're doing here, except we're also putting the id of the item as a key in the array (and the 0/1 will be the value).

$approval[ [i]id as key[/i] ] = [i]0 or 1[/i]

Am I on the right track with what you need?
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54411
Share on other sites

[code]<?php // script to display information
$result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC");
echo "<form name=\"dataupdating\" action=\"approval.php\" method=\"post\">";
while ($row = mysql_fetch_assoc($result))
{
extract($row);
$date = date("m/d/y");
$site = "http://www.funnyemailforwards.com/apex/";
$funnyurl = $site . $funnyurl;
echo "<ul>";
echo "<li><a href=" . '"' . $funnyurl . '"' . 'target="_blank">' . $nameoffunny . "</a></li>";
echo "<li>" . $date . "</li>";
echo "<li><input type=\"radio\" name=\"{$id[]}\" value=\"1\">Approve</li>";
echo "<li><input type=\"radio\" name=\"{$id[]}\" value=\"0\">Decline</li>";
echo "</ul>"; 
}
echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">";
echo "</form>";[/code]
So that should be how I set up my form elements right? Or am I not understanding properly.
And just for information purposes, I am not like other people, I try to avoid the personality where I refuse other people's advice, if I have been programming a specific way for 4 years, and all of a sudden someone comes by and shows me something, that is either harder, or I feel is useless, I am going to try it there way and see how I personall feel about it.


[quote]Well, in the HTML you typed up there, you have PHP generating INPUT element names like "approve_123" which means you'll have to find every instance of array element (approve_*) within $_POST[] ($_POST['approve_*']).  It would just be easier to use a single array for the radio button form elements[/quote]
I see what you mean about this possibly being difficult, I think I will try your idea, and see how it turns out, as I presented above, to get started.

[quote]Where the "8" in that example would be the id of the entry in the database.  All of the radio button values that get set will reside in the variable $_POST['approval'].  So when you loop through the $_POST'ed variable, all you'd need is this:[/quote]
So the I don't understand this fully, but I think you are telling me enough for what I created earlier, was that script up there what you meant.

[quote]Did you notice the print_r of the array a few posts back?  See how the approval[n] array is set up?  You probably know that you can use form element names of the form "element_name[]" to return data from multiple elements of the same name into an array, right?  So that's all we're doing here, except we're also putting the id of the item as a key in the array (and the 0/1 will be the value).[/quote]
But I understood none of the output like X, or the one below it, is that just to display what is selected and what is not?

Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54416
Share on other sites

[quote author=businessman332211@hotmail.com link=topic=99699.msg393129#msg393129 date=1152285004]
[code]<?php
echo "<li><input type=\"radio\" name=\"{$id[]}\" value=\"1\">Approve</li>";
echo "<li><input type=\"radio\" name=\"{$id[]}\" value=\"0\">Decline</li>";
?>[/code]
So that should be how I set up my form elements right? Or am I not understanding properly.
[/quote]

Close, but not quite.  That part should be like this:

[code]
<?php
echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"1\">Approve</li>";
echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"0\">Decline</li>";
?>[/code]

That way, when you submit the form, approval[] is keyed with the ids of only the choices you made (not the ones with no marks -- which is what you want).  Then you just need to loop through the $_POST['approval'][] array (probably with foreach) and base the behavior on the value.

[quote author=businessman332211@hotmail.com link=topic=99699.msg393129#msg393129 date=1152285004]
[quote]Did you notice the print_r of the array a few posts back?  See how the approval[n] array is set up?  You probably know that you can use form element names of the form "element_name[]" to return data from multiple elements of the same name into an array, right?  So that's all we're doing here, except we're also putting the id of the item as a key in the array (and the 0/1 will be the value).[/quote]
But I understood none of the output like X, or the one below it, is that just to display what is selected and what is not?
[/quote]
Yes, below was just to show what had been selected upon submission of the form.  Take the snippet, copy & paste it into a PHP file, and run it to see how it works.  (The "x" was just another array key like 8, 9, 2, etc.)

Mostly I'm just suggesting a slight variation on the use of PHP array-type variable names as form input names to return multiple values.  It's a very useful technique when you have alot of checkboxes or something, and when you use an array key, it can be useful for your situation, too.
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54428
Share on other sites

[quote]foreach ($_POST['approval'] as $key => $value) {
    if ($value) {
        mysql_query('DELETE FROM fileinfo WHERE id='.$key);
unlink($funnyurl); // url is set to exactly like this
// http://www.funnyemailforwards.com/apex/uploads/filename.ext
// Follows a path exactly to the file.
    } else {
        mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key);
unlink($funnyurl); // url is set to exactly like this
// http://www.funnyemailforwards.com/apex/uploads/filename.ext
// Follows a path exactly to the file.
    }
}[/quote]
That is what I have, is this going to work, because I was wondering, it seems to me
if the value exists it will update the delete, if it's not it will update
I need it to do both, or will this update both sections
OH it's on foreach ok, now I get it.
I want to ask here before using this, or I could mess up my database.  Does this work perfectly, is it true.
What I am wondering is this going to work here is my entire script now, with your advice put in there.


[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Approval</title>
</head>
<body>
<h3>Welcome Bobby</h3>
<p>These are recently pending database entries, please accept/decline.  Please note declined entries are automatically permanently deleted from the database. These are all updated together, upon submit.  The ones that are approved are set to approved status, the ones that are declined, are immediately deleted from the database, and the file is removed from it's location on the server.  If you check some of the choice, and leave some of the choice alone, they will still be here later, for instance if there are 3 items listed.  If you approve 1, decline 1, and leave the other alone for now, the approved one is updated, the declined one is deleted, and the one left alone, is not touched, and left there, for you to update later.</p>
<?php  // Connects to database
$connect = mysql_connect("localhost", "######", "######");
$select = mysql_select_db("funnyemailforwards");
$errorhandler = "";
$management = true;
if (!$connect || !$select) {
$errorhandler = "The database could not connect, or was not selected<br />";
$management = false;
}
?>

<?php // script to display information
$result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC");
echo "<form name=\"dataupdating\" action=\"approval.php\" method=\"post\">";
while ($row = mysql_fetch_assoc($result))
{
extract($row);
$date = date("m/d/y");
$site = "http://www.funnyemailforwards.com/apex/";
$funnyurl = $site . $funnyurl;
echo "<ul>";
echo "<li><a href=" . '"' . $funnyurl . '"' . 'target="_blank">' . $nameoffunny . "</a></li>";
echo "<li>" . $date . "</li>";
echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"1\">Approve</li>";
echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"0\">Decline</li>";
echo "</ul>"; 
}
echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">";
echo "</form>";

foreach ($_POST['approval'] as $key => $value) {
    if ($value) {
        mysql_query('DELETE FROM fileinfo WHERE id='.$key);
unlink($funnyurl); // url is set to exactly like this
// http://www.funnyemailforwards.com/apex/uploads/filename.ext
// Follows a path exactly to the file.
    } else {
        mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key);
    }
}


if ($errorhandler != "") {
echo "$errorhandler";
$management = false;
}
?>
<?php
if (isset($_POST['update'])) {

}
?>

</body>
</html>[/code]
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54436
Share on other sites

I looked over your script.  It looks pretty good.  There are, I think, two things that might need adjustment.

1.  Does this form/script submit to itself?  In that case, you should move the [b]foreach ($_POST['approval']...)[/b] block up toward the top -- at least before you query the database for unapproved settings.  That way the script will update the database before it checks for more unapproved submissions (and prints them).  As it is now, it looks like the script will print unapproved submissions, then delete/update, leading to discrepencies.  Also you should check that the script is, indeed, submitting information before automatically looping through that POST variable.

[code]
<?php

if (isset($_POST['approval'])) {
    foreach ($_POST['approval'] as $key => $value) {
        // .... etc
    }
}
?>
[/code]

2. The other thing I'm concerned about is the $funnyurl variable.  I assume that each submission comes with its own uploaded file; is that correct?  And that when you deny a submission, that file is deleted, right?  So it appears that $funnyurl is not being updated at all within the foreach loop.  Do you save the filename in the database entry?  If so, you'll need to query the database to fetch that filename before deleting the entry.

[code]<?php
foreach ($_POST['approval'] as $key => $value) {
    if ($value) {
        $result = mysql_query('SELECT filename FROM fileinfo WHERE id='.$key);
        unlink("http://www.funnyemailforwards.com/apex/" . mysql_result($result,0));
        mysql_query('DELETE FROM fileinfo WHERE id='.$key);       
    } else {
        mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key);
    }
}
?>[/code]

You might also want to add some error checking around the MySQL queries to make sure they're successful.  I left that out for readability.  I'm also assuming that if you've saved the filename, it's called "filename."  Change that accordingly, if necessary.


(PS:  I won't be able to check this thread until tomorrow.  Hope your project is going well.)
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54445
Share on other sites

Ok I will put these into m ind, and check on the things you listed, thank you so much for the help, I really appreciate it.  Not only did I finish my script, or am finishing it, but I also gained extra knowledge, and a few new techniques, plus a script I can duplicate the form of for later work, thank you for your help, I will ask here more if I get stuck on it, but I can wait for answers, whenever you are on and have time, I think I understand this enough, I should be able to handle the rest, all the questions I had were answered, thanks for the help.
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54446
Share on other sites

[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Approval</title>
</head>
<body>
<h3>Welcome Bobby</h3>
<p>These are recently pending database entries, please accept/decline.  Please note declined entries are automatically permanently deleted from the database. These are all updated together, upon submit.  The ones that are approved are set to approved status, the ones that are declined, are immediately deleted from the database, and the file is removed from it's location on the server.  If you check some of the choice, and leave some of the choice alone, they will still be here later, for instance if there are 3 items listed.  If you approve 1, decline 1, and leave the other alone for now, the approved one is updated, the declined one is deleted, and the one left alone, is not touched, and left there, for you to update later.</p>
<?php  // Connects to database
$connect = mysql_connect("localhost", "#####", "####");
$select = mysql_select_db("funnyemailforwards");
$errorhandler = "";
$management = true;
if (!$connect || !$select) {
$errorhandler = "The database could not connect, or was not selected<br />";
$management = false;
}
?>
<?php

if (isset($_POST['update'])) {
      foreach ($_POST['approval'] as $key => $value) {
    if ($value) {
        mysql_query('DELETE FROM fileinfo WHERE id='.$key);
unlink($funnyurl); // url is set to exactly like this
// http://www.funnyemailforwards.com/apex/uploads/filename.ext
// Follows a path exactly to the file.
    } else {
        mysql_query('UPDATE fileinfo SET approval=1 WHERE id='.$key);
    }
}// closes foreach
}// closes isset control structure
?>

<?php // script to display information
$result = mysql_query("SELECT * FROM fileinfo WHERE approval=0 ORDER BY entrydate ASC");
echo "<form name=\"dataupdating\" action=\"approval.php\" method=\"post\">";

while ($row = mysql_fetch_assoc($result))
{
extract($row);
$date = date("m/d/y");
$site = "http://www.funnyemailforwards.com/apex/";
$funnyurl = $site . $funnyurl;
echo "<ul>";
echo "<li><a href=" . '"' . $funnyurl . '"' . 'target="_blank">' . $nameoffunny . "</a></li>";
echo "<li>" . $date . "</li>";
echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"1\">Approve</li>";
echo "<li><input type=\"radio\" name=\"approval[$id]\" value=\"0\">Decline</li>";
echo "</ul>"; 
$management = true;
}
if ($management === true) {
echo "<input name=\"update\" type=\"submit\" value=\"Update Database\">";
echo "</form>";
}




if ($errorhandler != "") {
echo "$errorhandler";
$management = false;
}
?>

</body>
</html>[/code]
That is what I have but it's giving me troubles, it's working out properly when I use it, but 2 things are messing up, when I update, it updates the db properly for both, but ont he one that deletes it, it leaves the file, it tells me no file name, the file is in 2 folders, it is in this directory
http://www.funnyemailforwards.com/apex/uploads/filehere
The area for where I am using this script that does the updating here is in
http://www.funnyemailforwards.com/administration/approval.php
I need to figure out how to get it to access the file, I am currently trying to tell it the file location is
http://www.funnyemailforwards.com/apex/uploads/file.ext
That is what I am pointing it to, but it's not deleting it, it tells me the file does not exist.  Also when there are no entries in the database, a lot of things act up, for one it tells me my foreach statement
[code]foreach ($_POST['approval'] as $key => $value) {[/code]
It's telling me this, when there are none listed
[quote]Warning: Invalid argument supplied for foreach() in /home/all/funnyemailforwards/public_html/administration/approval.php on line 23[/quote]
Can anyone help me figure this out real quick?
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54450
Share on other sites

[quote author=businessman332211@hotmail.com link=topic=99699.msg393185#msg393185 date=1152291333]
That is what I have but it's giving me troubles, it's working out properly when I use it, but 2 things are messing up, when I update, it updates the db properly for both, but ont he one that deletes it, it leaves the file, it tells me no file name, the file is in 2 folders, it is in this directory
http://www.funnyemailforwards.com/apex/uploads/filehere
The area for where I am using this script that does the updating here is in
http://www.funnyemailforwards.com/administration/approval.php
I need to figure out how to get it to access the file, I am currently trying to tell it the file location is
http://www.funnyemailforwards.com/apex/uploads/file.ext
That is what I am pointing it to, but it's not deleting it, it tells me the file does not exist. 
[/quote]

You're not setting the $funnyurl variable during that loop.  You need to set it to the location of the file you want to delete.  Did you save it in the database?  If so, you'll need to extract that information before you delete the entry so you can delete the file.  Of course, if your filename is based on the entry id, you might not need to do that.  See the code under "2." in my last post.

[quote author=businessman332211@hotmail.com link=topic=99699.msg393185#msg393185 date=1152291333]
Also when there are no entries in the database, a lot of things act up, for one it tells me my foreach statement
[code]foreach ($_POST['approval'] as $key => $value) {[/code]
It's telling me this, when there are none listed
[quote]Warning: Invalid argument supplied for foreach() in /home/all/funnyemailforwards/public_html/administration/approval.php on line 23[/quote]
[/quote]

Yep, that's because you're checking for $_POST['update'] instead of $_POST['approval'].  'update' is set upon submission of the form, but 'approval' is not necessarily set (if you don't check any of the radio buttons, it's not set).  You should really check for the variable you're about to use.  If you still want to check 'update', use an '&&' in there (check for both).
Link to comment
https://forums.phpfreaks.com/topic/13882-phpsql/#findComment-54799
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.