Jump to content

Ult1matek1ll

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Ult1matek1ll's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks but the problem was resolved on the sql forum. $result = mysql_query("DELETE * FROM Products WHERE id=$_POST['which']"); there was the error so im solved XD
  2. damn i feel stupid thank you though ive been looking at this for a while and couldnt figure out what was wrong
  3. I need to select a row so i can get some information from it for a directory delete function and then i need to delete that row from the table... the select works fine as does the dir delete function the problem im having is that it doesnt generate an error but it still doesnt delete the row... <?php $con = mysql_connect("localhost","...","..."); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("...", $con); $result = mysql_query("SELECT * FROM Products WHERE id=$_POST[which]"); $row = mysql_fetch_array($result);unset ($result); $temp = $row['num']; $result = mysql_query("DELETE FROM Producs WHERE id=$_POST[which]"); mysql_close($con); ?> <?php $mydir = 'assets/images/' . $temp . '/'; $d = dir($mydir); while($entry = $d->read()) { if($entry!="." && $entry!="..") { unlink('assets/images/' . $temp . '/' . $entry); } } rmdir('assets/images/' . $temp); ?> Any and all help is greatly appreciated
  4. I'm trying to set it so that it will delete an entire populated directory based upon a value in the database then after finishing that to go back and delete that row in the database. my current code is <?php $page_title = "Central Valley LLC | Photo Addition" ?> <?php include("header.php"); ?> <?php include("nav.html"); ?> <div id="content"> <form action="delprod.php" method="post" enctype="multipart/form-data"> <label for="which">Choose A Product To Remove:</label> <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT * FROM Products"); echo "<select name=\"which\">"; while($row = mysql_fetch_array($result)) { echo "<option "; echo "value=\"" . $row['id'] . "\">"; echo $row['Name'] . "</option>"; } echo "</select>"; mysql_close($con); ?> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div><!--#content--> <?php include("footer.html") ?> and the delete script <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT id FROM Products WHERE id=$_POST['which']"); $row = mysql_fetch_array($result) chdir('assets'); chdir('images'); $mydir = $row . '/'; $d = dir($mydir); while($entry = $d->read()) { if($entry!="." && $entry!="..") { unlink($_POST['which'] . '/' . $entry); } } rmdir($mydir); $result = mysql_query("DELETE * FROM Producs WHERE id=$_POST['which']"); ?> Thank you in advance for all your help. any easier ways of approaching this will be welcome as well
  5. found the problem it was at the beginning with the unlink item. former code while($entry = $d->read()) { if($entry!="." && $entry!="..") { unlink($entry); } } new code while($entry = $d->read()) { if($entry!="." && $entry!="..") { unlink('assets/images/' . $_POST['which'] . '/' . $entry); } } Thank you so much for all of your help guys
  6. ok works for the most part the only issue i am having is if there are more images than i am uploading to replace it holds on to them still such that 1.jpg 2.jpg 3.jpg 4.jpg 5.jpg and i upload only 3 imgs per say: one.jpg,two.jpg,three.jpg(names used as examples the php upload script renames them as listed in the first part) my output would be one.jpg two.jpg three.jpg 4.jpg 5.jpg
  7. Thank you drummin That worked so far will proceed with some more test and reply again
  8. oh sorry that is precisely what you wanted here you go Array ( [uploads] => Array ( [name] => Array ( [0] => SD card with Aiden 001.JPG [1] => SD card with Aiden 002.JPG [2] => SD card with Aiden 003.JPG [3] => SD card with Aiden 004.JPG ) [type] => Array ( [0] => image/jpeg [1] => image/jpeg [2] => image/jpeg [3] => image/jpeg ) [tmp_name] => Array ( [0] => /tmp/php5CvGcY [1] => /tmp/phpSzBVMP [2] => /tmp/phpyymYpH [3] => /tmp/phpGoJc6y ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 ) [size] => Array ( [0] => 2619687 [1] => 2429027 [2] => 2720262 [3] => 3640722 ) ) )
  9. when yes radial button pressed for empty dir nothing echoed... when no radial button pressed for empty dir nothing yet again... when yes radial button pressed for populated dir nothing echoed... when no radial button pressed for populated dir nothing yet again... sadly nothing is being echoed what-so-ever if you would like me to add an echo into the code and test it i will thank you for your help
  10. <?php $page_title = "Central Valley LLC | Photo Addition" ?> <?php include("header.php"); ?> <?php include("nav.html"); ?> <div id="content"> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="which">Choose A Product:</label> <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT * FROM Products"); echo "<select>"; while($row = mysql_fetch_array($result)) { echo "<option "; echo "value=\"" . $row['num'] . "\">"; echo $row['Name'] . "</option>"; } echo "</select>"; mysql_close($con); ?> <br /> <h3 id="center">Do You Wish To Replace Current Images?</h3> <br /> <input type="radio" name="replace" value="y" />YES<br /> <input type="radio" name="replace" value="n" />NO <br /> <input name="uploads[]" type="file" multiple="multiple" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div><!--#content--> <?php include("footer.html") ?> <?php $count = 1; if($_POST[replace]=='y') { $mydir = 'assets/images/' . $_POST['which'] . '/'; $d = dir($mydir); while($entry = $d->read()) { if($entry!="." && $entry!="..") { unlink($entry); } } } else { $loop = true; while($loop == true) { $filename = 'assets/images/' . $_POST['which'] . '/' . $count . '.jpg'; if(file_exists($filename)) { $count++; } else { $loop = false; } } } if(!is_dir("uploads/".$id)) { //this checks to make sure the directory does not already exist mkdir("uploads/".$id, 0777, true); //if the directory doesn't exist then make it chmod("uploads/".$id, 0777); //chmod to 777 lets us write to the directory } $uploaddir = 'assets/images/' . $_POST['which'] . '/'; foreach($_FILES["uploads"]["name"] as $bla=> $boo) { //we have to do a loop to get all the filenames $file=$uploaddir.$boo; //we will check the filename in the upload directory, see if it exists if (file_exists($file)) { //if it exists then ...... die("Filename already exists, please rename this file"); //if filename exists in the directory then we die!!! } } foreach ($_FILES["uploads"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { echo"$error_codes[$error]"; // let you know if there was an error on any uploads move_uploaded_file( //php function to move the file $_FILES["uploads"]["tmp_name"][$key], //from the temporary directory $uploaddir. $_FILES["uploads"]["name"][$key] //to the directory you chose ) or die("Problems with upload"); } } foreach($_FILES["uploads"]["name"] as $bla=> $boo) { $file=$uploaddir.$boo; $movepoint = $uploaddir . $count . '.jpg'; rename($file, $movepoint); $count++; } ?> It currently fails to upload any files and i was curious if i was approaching this at all in the right manner
  11. My goal is to allow the user to select whether or not they want to replace the current img files. If so delete all current ones in select dir and upload into it. If not then began uploading at a specific point such that. 1.jpg 2.jpg 3.jpg ... and so on (replace yes deletes all and no deletes none) The directories are assigned previously and are accessed via sql database These are the two current sets i have <?php $page_title = "Central Valley LLC | Photo Addition" ?> <?php include("header.php"); ?> <?php include("nav.html"); ?> <div id="content"> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="which">Choose A Product:</label> <?php $con = mysql_connect("localhost","phoenixi_cv","centraladmin"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("phoenixi_cvproducts", $con); $result = mysql_query("SELECT * FROM Products"); echo "<select>"; while($row = mysql_fetch_array($result)) { echo "<option "; echo "value=\"" . $row['num'] . "\">"; echo $row['Name'] . "</option>"; } echo "</select>"; mysql_close($con); ?> <br /> <h3 id="center">Do You Wish To Replace Current Images?</h3> <br /> <input type="radio" name="replace" value="y" />YES<br /> <input type="radio" name="replace" value="n" />NO <br /> <input name="uploads[]" type="file" multiple="multiple" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </div><!--#content--> <?php include("footer.html") ?> and this is the upload script so far } } foreach ($_FILES["uploads"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { echo"$error_codes[$error]"; // let you know if there was an error on any uploads move_uploaded_file( //php function to move the file $_FILES["uploads"]["tmp_name"][$key], //from the temporary directory $uploaddir. $_FILES["uploads"]["name"][$key] //to the directory you chose ) or die("Problems with upload"); } } foreach($_FILES["uploads"]["name"] as $bla=> $boo) { $file=$uploaddir.$boo; $movepoint = $uploaddir . $count . '.jpg'; rename($file, $movepoint); $count++; } ?> ' target='_blank'><?php $count = 1; if($_POST[replace]=='y') { $mydir = 'assets/images/' . $_POST['which'] . '/'; $d = dir($mydir); while($entry = $d->read()) { if($entry!="." && $entry!="..") { unlink($entry); } } } else { $loop = true; while($loop == true) { $filename = 'assets/images/' . $_POST['which'] . '/' . $count . '.jpg'; if(file_exists($filename)) { $count++; } else { $loop = false; } } } if(!is_dir("uploads/".$id)) { //this checks to make sure the directory does not already exist mkdir("uploads/".$id, 0777, true); //if the directory doesn't exist then make it chmod("uploads/".$id, 0777); //chmod to 777 lets us write to the directory } $uploaddir = 'assets/images/' . $_POST['which'] . '/'; foreach($_FILES["uploads"]["name"] as $bla=> $boo) { //we have to do a loop to get all the filenames $file=$uploaddir.$boo; //we will check the filename in the upload directory, see if it exists if (file_exists($file)) { //if it exists then ...... die("Filename already exists, please rename this file"); //if filename exists in the directory then we die!!! } } foreach ($_FILES["uploads"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { echo"$error_codes[$error]"; // let you know if there was an error on any uploads move_uploaded_file( //php function to move the file $_FILES["uploads"]["tmp_name"][$key], //from the temporary directory $uploaddir. $_FILES["uploads"]["name"][$key] //to the directory you chose ) or die("Problems with upload"); } } foreach($_FILES["uploads"]["name"] as $bla=> $boo) { $file=$uploaddir.$boo; $movepoint = $uploaddir . $count . '.jpg'; rename($file, $movepoint); $count++; } ?> Thanks in advance for any help that you can give me.Also if you can suggest any easier ways i would certainly be obliged.
×
×
  • 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.