Jump to content

wigpip

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Everything posted by wigpip

  1. that's right you cannot run php in javascript but you can print out javascript from php, however. In your javascript where you have a select for the years you will need to change that to a javascript for() statement instead.
  2. one thing you can do to increase security is set the permissions to 700 on the folder with your db connect file, so direct browser access will give a 403 Not Found
  3. Hi PHP folks this is the logic I came up with so basically foreach within a foreach and then use strpos function and if a match echo out the image, so here's the bones of the code. the first foreach just gets the last name from the names array assuming it's the last after the last underscore. <?php foreach($_names as $value) { $parts = explode('_',$value); $parts = count($parts); $key = $parts; $last_name = $_names[$key]; foreach($imageArray as $matching_value) { if(strpos($last_name,$matching_value)) { echo $matching_value; } } } ?>
  4. without knowing exactly your intentions I would add why not use sessions e.g. $_SESSION['setexamplesessionhere'] = $somevariable;
  5. yes with mysql_field_type() try it using the fresh $result loop not within the foreach()
  6. you could try mysql_field_type()
  7. so the basic logic might be like: if getimagesize > 0 then do nothing elseif getimagesize == 0 then ok to upload to database (that's if i follow the prevailing required logic in your requirements)
  8. one idea what you could do is use php's getimagesize function to test more thouroughly for an image upload <?php $size = getimagesize($filename); $fp = fopen($filename, "rb"); if ($size && $fp) { // do upload here } else { // do nothings or something else } ?>
  9. if there is a very short conditional that fits on one line and only has one outcome then it's ok but most agree that it's not such a good idea as when you leave out the {} from statements it can lead to problems later in the life of the code, for example you might want to add an elseif to the statement or grow the argument to multiple lines. Personally it's just easier to read code with {} added regardless.
  10. Hi like normal HTML but when you need to break into the php variable to break the html with apostrophe + comma then after the variable back into the HTML with comma + apostrophe echo'<a href="',$fquery['website'],'">',$fquery['website'],'<a/>';
  11. for your shopping cart like so just one more to end the if cart statement do everything within $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } }
  12. at a glance it looks like you didn't close of your statement here <? if ($_SERVER['REQUEST_METHOD'] == 'GET' and elseof($_GET) == 0){ $_GET['rows'] = 7; ?> should be <? if ($_SERVER['REQUEST_METHOD'] == 'GET' and elseof($_GET) == 0){ $_GET['rows'] = 7; } ?>
  13. $filename = $_FILES['upload']['name']; // Move the file over. if (move_uploaded_file($_FILES['upload']['tmp_name'], "$folder/$filename")) { echo '<p>The file has been uploaded!</p>'; } else { echo '<p><font color="red">The file could not be moved.</font></p>'; }
  14. instead of the copy() function i use the move_uploaded_file() function works better on the whole
  15. so who would recommend phpCake over Zend and why?
  16. i agree i love the 'except rule: ^', or you could do it this way with the 'i' for case insensitive, whichever $string = 'me.]'; $nw = preg_replace("/[^a-z]/i",'',$string); echo $nw;
  17. the multidimensional array ah yes $_SESSION['cart'] = array(); $_SESSION['cart']['0']['Name'] = 'product 1'; $_SESSION['cart']['1']['Name'] = 'product 2'; $nextnum = count($_SESSION['cart']) + 1; $_SESSION['cart'][$nextnum]['Name'] = 'product 3'; print_r($_SESSION['cart']); so by using the count function you always know where you are up to in the array, then add 1 for the next 'key' to assign it's 'value'
  18. hey there i had a bit of time on my hands, anywho, this one gets it right down to one URL, so you can see how each time a preg_replace is run it narrows it down a bit more, there could be other duplicates that might slip through the net, may need more testing and yes I am aware there are more elegant ways of doing this in one swoop, say with one long regex expression? anyone? $string = 'http://google.com http://google.com/ http://www.google.com http://www.google.com/ http://www.google.com/index.php'; $array1 = explode(' ',$string); foreach($array1 as $value) { echo '<br>'; $newvalue = preg_replace("/com$|com\/\$/i",'com',$value); $array2[] = $newvalue; } echo '<br>'; foreach($array2 as $value) { echo '<br>'; $newvalue = preg_replace("/^http:\/\/www\./i",'http://',$value); $array3[] = $newvalue; } echo '<br>'; echo '<br>'; foreach($array3 as $value) { echo '<br>'; $newvalue = preg_replace("/\/index\.(html?)|\/index\.(php)?$/i",'',$value); $array4[] = $newvalue; } echo '<br>'; print_r(array_unique($array4));
  19. Hey Rooster, it's a good question and one that could for the most part be done with Regular Expressions. If you run the code below you will see how it prints out : as you can see it's on it's way to finding similarities then you would use the php array distinct or diff function to wipe out the repeats. $string = 'http://google.com http://google.com/ http://www.google.com http://www.google.com/ http://www.google.com/index.php'; $values = explode(' ',$string); foreach($values as $value) { echo '<br>'; $newvalue = preg_replace("/com$|com\/\$/i",'com',$value); echo $newvalue; } http://google.com http://google.com http://www.google.com http://www.google.com http://www.google.com/index.php
  20. in some sort of statement if(isset($no_user_input)) { sleep(1000); } else { do something here; } }
  21. first function that comes to mind is sleep(int $seconds );
  22. true true, well anyway as stated to clarify i tested code as supplied and it worked fine, so as the error dictates the server doesn't seem to like the mail function, would suggest contacting your server administrator regarding their php settings around mail functions
  23. gday you need to put : ob_start(); function at very top of page
×
×
  • 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.