Jump to content

envexlabs

Members
  • Posts

    256
  • Joined

  • Last visited

    Never

Everything posted by envexlabs

  1. You could set a cookie, or a session variable on submit, but i'm not sure if that's the best way to go about it.
  2. It still seems to be deleting the whole folder.
  3. Hey, I found this loop on the internet, but it's seems to be deleting the whole folder, not the contents. any insight? <?php /** * Delete a file, or a folder and its contents * * @author Aidan Lister <aidan@php.net> * @version 1.0.2 * @param string $dirname Directory to delete * @return bool Returns TRUE on success, FALSE on failure */ $tmpdir = $_SERVER['DOCUMENT_ROOT'].'/uploads/tmp/'; function rmdirr($dirname) { // Sanity check if (!file_exists($dirname)) { return false; } // Simple delete for a file if (is_file($dirname)) { return unlink($dirname); } // Loop through the folder $dir = dir($dirname); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Recurse rmdirr("$dirname/$entry"); } // Clean up $dir->close(); return rmdir($dirname); } rmdirr($tmpdir); ?>
  4. I was hoping there was a different way than that Thanks!
  5. Hey, I have this query: SELECT * FROM `store` LEFT JOIN `directory_link` ON store.id = directory_link.item_id WHERE directory_link.cat_id = 2 Which prints this: Array ( [id] => 16 [contact_name] => Matt Vickers [name] => Connect Four => ------- [password] => kmladhlkashldkfjhasljd [slug] => connect_four [mem_type] => 1 [pic] => 1_09172007-12-1280X1024.jpg [address] => 250 Mc Dermot [phone] => 204.229.3215 [cat_id] => 2 [paid] => 0 [item_id] => 1 [is_store] => 1 ) The problem i'm having is that directory_link.id is overwriting my store.id which is quite important. Is there a way to remove directory_item.id from the final output? Thanks, envex
  6. Hey, Just a quick question that occured today. Which method is better to grab rows from a mysql database, or are they exactly the same? method 1: $query = mysql_query(SOME QUERY); $result = mysql_fetch_assoc($query); method 2: $result = mysql_fetch_assoc(mysql_query(SOME QUERY));
  7. Hey, I have a button that fires a ajax call and executes some php code. This is the ajax call: function addtocart_landing(target_div,file,check_div) { var MyHttpRequest = false; var ErrorMSG = 'Sorry - No XMLHTTP support in your browser, buy a newspaper instead'; if(check_div) { var check_value = document.getElementById(check_div).value; } else { var check_value = ''; } if(window.XMLHttpRequest) // client use Firefox, Opera etc - Non Microsoft product { try { MyHttpRequest = new XMLHttpRequest(); } catch(e) { MyHttpRequest = false; } } else if(window.ActiveXObject) // client use Internet Explorer { try { MyHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { MyHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { MyHttpRequest = false; } } } else { MyHttpRequest = false; } if(MyHttpRequest) // browser supports httprequest { var random = Math.random() * Date.parse(new Date()); // make a random string to prevent caching var file_array = file.split('.'); // prepare to check if we have a query string or a html/htm file if(file_array[1] == 'php') // no query string, just calling a php file { var query_string = '?rand=' + random; } else if(file_array[1] == 'htm' || file_array[1] == 'html') // calling a htm or html file { var query_string = ''; } else // we have presumable a php file with a query string attached { var query_string = check_value + '&rand=' + random; } MyHttpRequest.open("get", url_encode(file + query_string), true); // <-- run the httprequest using GET // handle the httprequest MyHttpRequest.onreadystatechange = function () { if(MyHttpRequest.readyState == 4) // done and responded { //document.getElementById(target_div).innerHTML = 'Product Added to your Cart!'; // display result window.location = "http://oxygenfit.com/cart.php"; //alert('Product has been added to your cart.'); } else { //document.getElementById(target_div).innerHTML = MyHttpLoading; // still working } } MyHttpRequest.send(null); } else { document.getElementById(target_div).innerHTML = ErrorMSG; // the browser was unable to create a httprequest } } // end of "AJAX" function What my problem is, a user can click the button rapidly causing wierd outcomes with the php code. How would i go about stopping this from happening? Some sort of delay maybe?
  8. Hey, I think i've figured it out, i just a moment of brain retardation. Thanks!
  9. Hey, I am working on a site for a client and i could use a little help. We have a company that sells cars, lets call it CARS Inc. There are other dealers that sell CARS products. I want to be able to allow dealers to have a site that's http://carsinc.com/dealer1 I was hoping to just create one and and use /dealer1 to grab a variable that loads all that dealers information on the site, instead of creating a different folder for each dealer. What would be the best way to store that dealers id when a user visits the site. Thanks, envex
  10. I'm not exactly sure where to start with that?!
  11. Hey, I'm creating a secure cart which relies on session_id to grab the cart contents. Is there a way to carry over the session id when the user switches over to https from http? Thanks, envex
  12. Hey, How would i figure out what weekly time frame the user is in. ie, it's wednesday, so i want to figure out which date monday was and which day sunday will be. I'm trying to filter out jobs by weekly time frames, and i just can't figure this problem out. Thanks, envex
  13. Hey, I have a script that figures out the difference between 2 times. So lets say i have a time difference of 2:36. I need to figure out what 2:36 would be in number form and i'm not a math whiz. So if 1:15 would be 1.25 as a number, how would i figure out all the other numbers. Sorry if this is confusing, it's kind of hard to explain. Thanks, envex.
  14. if(empty($_FILES['pic']['name'])){}else{ //$ext = explode('.', $_FILES['pic']['name']); //puts the array into a variable so that it can be inputed into the database as a name.ext instead of Array[] $name = $_SESSION['username'] . '_' . $_FILES['pic']['name']; //sets the directory and name for the file $uploaddir = 'profile_pics/'; $uploadfile = $uploaddir . $name; if (move_uploaded_file($_FILES['pic']['tmp_name'], $uploadfile)) {} else { echo "Picture could not be uploaded"; } //changes the permissions of the file //chmod($uploadfile, 0777); $pic = $uploadfile; //this shrinks the image if the orignal is too big $org_size = getimagesize('http://www.yournightyourcity.com/' . $pic); //takes the larger size of the width and height and applies the //formula accordingly...this is so this script will work //dynamically with any size image $mywidth = $org_size[0]; $myheight = $org_size[1]; $target = 230; $percentage = ($target / $mywidth); //gets the new value and applies the percentage, then rounds the value $mywidth = round($mywidth * $percentage); $myheight = round($myheight * $percentage); $source_path = $pic; $destination_path = $pic; $ext = strrchr($pic, "."); $new_width= $mywidth; //Image width Change if needed $new_height= $myheight; //Image height Change if needed $destimg=imagecreatetruecolor($new_width,$new_height) or die("Problem In Creating image"); switch($ext) { case '.gif': $srcimg = imagecreatefromgif($pic) or die("Problem In opening Source Image"); break; case '.jpg': $srcimg = imagecreatefromjpeg($pic) or die("Problem In opening Source Image"); break; case '.jpeg': $srcimg = imagecreatefromjpeg($pic) or die("Problem In opening Source Image"); break; case '.png': $srcimg = imagecreatefrompng($pic) or die("Problem In opening Source Image"); break; } ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("Problem In resizing"); Imagejpeg($destimg,$destination_path,100) or die("Problem In saving"); $org = 'profile_pics/'.$name; $thumb = 'profile_pics/thumbs/'.$name; $front_thumb = 'profile_pics/front_thumbs/'.$name; $updatepic = mysql_query('UPDATE `member_info` SET `pic` = \'' . $pic . '\' WHERE `mem_id` = ' . $_POST['mem_id'] . ''); $matt_ext = explode('.', $ext); //creates memberpage thumb cropImage(125, 150, $org, $matt_ext[1], $thumb); //creates frontpage thumb cropImage(135, 105, $org, $matt_ext[1], $front_thumb); //changes permissions for all images chmod($pic, 0755); chmod($thumb, 0755); chmod($front_thumb, 0755); }
  15. Hey, I have an image uploader script which uploads then resizes the image. The script works fine except when users are trying to upload an image from a camera. This is the error people are getting: Thanks, envex
  16. thanks, works like a charm!
  17. Hey, I'm having a problem that i know the solution to but my brain just does not want to let me in on the secret. I'm creating a shopping cart for a client who wants real-time update prices etc, but that i have figured out. What i can't figure out how to do is get the total price from each product once it has been looped out. ie. Product 1 Price: $15 Product 2 Price: $25 Total (which is what i need): should be $40 Anyone know what my brain is thinking? Thanks. envex
  18. I have a search page that searches through a database of posts. Lets say i searched for "passage". I've used str_replace to bold and highlight the searched term, but i also only want to display 15 words before and after the searched term. Right now i have: Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. I want: ...Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source... Does anyone know how to go about doing this? envex
  19. Hey, I'm having some trouble update another div element from inside a php file. I have index.php which has pic_container and next divs. When you click on the next div, ajax outputs a new photo into pic_container. From that same php file, i am trying to update next with either element.update or document.getElementById.('next).innerHTML It works when outside the ajax/php file, but wont work when inside the ajax/php file. Do i have to set something as global in javascript, or am i doing something wrong? Thanks, envex
  20. Hey, I need users to be able to upload a csv file with 1 column, just names. I need to be able to write all this data to the database. Does anyone know where to start, or if there is a script already developed to do this? Thanks, envex
  21. Hey, I have a cart that displays the total of all items in the cart. The items are added/removed from the cart via ajax, and i want to be able to update the total when an item is added/removed from the cart. How would i go about creating a loop or something that is constantly checking to see if $total has been changed? Thanks, envex.
  22. Hey, $newsletter[6] = "2007-10-17" When i execute this code: echo date("D, d F Y", $newsletter[6]); I get this: Wed, 31 December 1969 Am i doing something wrong? Thanks, Envex
  23. Hey, phpmailer can use the sendmail function to send mail, which doesn't use your mail server. You may also use SMTP, but then you have to use your hosting mailserver, and i know for a fact, if you are wanting to send alot of emails in a day, 1&1 limits it. With 1&1, you can only send about 100 emails per hour.
×
×
  • 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.