Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. You're cookie is called [color=green]cookie_city[/color], but when you check it to see if it's set, you're referring to is as [color=brown]choose_city[/color]. The inconsistency is what's causing the problem. Regards Huggie
  2. Sure... [code]<?php if (isset($_POST['submit'])){   $_SESSION['total']++; } ?> <input name="total incr" type="hidden" value="<?php $_SESSION['total'];?>">[/code] Regards Huggie EDIT: You're too fast for me pip3r :)
  3. No problem, I always try to provide an example in order to help understand. Huggie
  4. Thorpe got there first, but I was just going to say that this: [code]<?php $number = 1; function doubleup($num){   return $num*2; } echo doubleup($number); ?>[/code] Produces the same result as this: [code]<?php $number = 1; echo doubleup($number); function doubleup($num){   return $num*2; } ?>[/code] Regards Huggie
  5. Fair comment. Huggie
  6. If that worked then mark the topic as solved so others can take advice from it. Regards Huggie
  7. [quote author=thepip3r link=topic=119158.msg487619#msg487619 date=1166474817] Do not use $_REQUEST.  It's a security nightmare [/quote] $_REQUEST should be taken into consideration with regards to security, but to say don't use it isn't really helpful.  There are uses for it and if used correctly, can be perfectly secure. Regards Huggie
  8. You need to just do put the call to the function inside the loop... [code]<?php if ($handle = opendir('.')) {   while (($file = readdir($handle)) !== false){       echo "$file\n";       output_iptc_data($file);   }   closedir($handle); } function output_iptc_data($image_path) {    $size = getimagesize( $image_path, $info);        if(is_array($info)){        $iptc = iptcparse($info["APP13"]);       foreach (array_keys($iptc) as $s) {                    $c = count ($iptc[$s]);         for ($i=0; $i <$c; $i++){             echo $s." = ".$iptc[$s][$i]."<br>\n";         }       }                  }      } ?>[/code] Regards Huggie
  9. The latter would work better.  Below is an example using $_REQUEST, so it will pick up all the values regardless of whether POST or GET was used. [code]<?php foreach ($_REQUEST as $k => $v){   echo "$k - $v<br>\n"; } ?>[/code] Regards Huggie
  10. If you're trying to get the amount then you need to fetch that data too.  Try this code (error checking included this time)... [code]<?php $sql = "SELECT amount FROM colors WHERE color = '$color'"; $result = mysql_query($sql); if (!$result){   echo "Unable to run query: $sql<br>\n" . mysql_error(); } else {   $row = mysql_fetch_array($result, MYSQL_ASSOC);   echo $row['amount']; } ?>[/code] Regards Huggie
  11. Ted, You've taken the code from two different posts there.  My code should work with your details like this: [code]<?php // Directory path $dir = '/others/'; //this is the path to my txt files, I have three, they each have "2","3", and "3", // Open the directory $dh = opendir($dir); while (($file = readdir($dh)) !== false){   if ($file != '.' && $file != '..'){     $fullfile = $dir . $file;     $subtotals[] = file_get_contents($fullfile);   } } // Add them all together $total = 0; foreach ($subtotals as $st){   $total = $total + $st; } // Echo the total echo "$total\n"; ?>[/code] Regards Huggie
  12. OK, something like this would do it... [code]<?php $uploaddir = '/home/townsfin/public_html/business_images/'; // No need for realpath() here $uploadfile = $_FILES['Picture1']['name']; // No need for basename() here if(!empty($_FILES['Picture1'])){   var_dump($uploaddir);       var_dump($_FILES['Picture1']['size']);   var_dump($_FILES['Picture1']['error']);   var_dump($_FILE);   var_dump($_FILES['Picture1']['type']);   var_dump($_FILES['Picture1']['name']); } $fullpath = $uploaddir . $uploadfile; if (move_uploaded_file($_FILES['Picture1']['tmp_name'], $fullpath)){   echo("File Uploaded");   $sql = "INSERT INTO business_info (picture1) VALUES ('$fullpath')";   $result = mysql_query($sql);   if (!$result){       echo "Error inserting data: " . mysql_error();   } } else {   echo ("file no uploaded!");   print_r($_FILES);   echo realpath('./'); } ?>[/code]
  13. You need single quotes around your value... [color=blue]$extract="SELECT amount FROM colors WHERE color = [color=red]'[/color]$color[color=red]'[/color]";[/color] Regards Huggie
  14. I've tested that code now and it works fine.  It's adding them up correctly. You don't need to define the array first, the foreach loop should be happy with assigning each new value to [code=php:0]$subtotals[][/code] You do have the [code=php:0]$total = 0;[/code] outside the loop don't you? Regards Huggie
  15. Here's a really quick and easy guide to file permissions. http://www.htmlite.com/php042.php Regards Huggie
  16. You could, but if the comments are always delimited by the ;---- then the RegEx that Orio suggested would probably be better, if it's coming from an external source, which it is, the RegEx is possibly more reliable. Regards Huggie
  17. For standards compliant html, you should change the suggested line from this: [code=php:0]echo "<option value=\"$option\"".(($option==$_POST[test1])?" selected":"").">$option</option>\n";[/code] To this: [code=php:0]echo "<option value=\"$option\"".(($option==$_POST[test1])?" selected='selected'":"").">$option</option>\n";[/code] Regards Huggie
  18. OK, well you didn't post that part of the code. Regards Huggie
  19. Something like this would work, just replace the database column and form fields with the names you require. [code]<?php // Connect to the database include('connect.php'); // Query the database to get the values for the dropdown $sql = "SELECT id, name FROM menu_options"; $result = mysql_query($sql); if (!$result){   echo "Unable to execute $sql<br>\n" . mysql_error(); // Error if we got no result } // Start the select menu echo "<select name='menu_name'>\n"; // Echo each option of the menu while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){   echo "<option value='" . $row['id'] . "'>" . $row['name'] . "</option>"; } // End the menu echo "</select>"; ?>[/code] Regards Huggie
  20. If that worked, then mark the topic as solved and raise any new questions in a new topic, this will help people when searching titles for meaningful phrases. Regards Huggie
  21. You don't want to use nl2br() at all.  You want to leave them as new lines... If you provide your code we'll be able to help more. Regards Huggie
  22. It's just a simple html form element... [code]<input type="file" name="file_to_upload"> <input type="submit" name="submit" value="Upload">[/code] It will put the browse button in automatically. Regards Huggie
  23. [quote author=Orio link=topic=119118.msg487385#msg487385 date=1166457502] it doesnt make a diffrence in this case... Orio. [/quote] Pun totally intended :)
  24. Why are you using realpath() on a path that's already 'real'? The following should work fine: [code]<?php $uploaddir = '/home/townsfin/public_html/business_images/'; // No need for realpath() here $uploadfile = $_FILES['Picture1']['name']; // No need for basename() here if(!empty($_FILES['Picture1'])){   var_dump($uploaddir);       var_dump($_FILES['Picture1']['size']);   var_dump($_FILES['Picture1']['error']);   var_dump($_FILE);   var_dump($_FILES['Picture1']['type']);   var_dump($_FILES['Picture1']['name']); } $fullpath = $uploaddir . $uploadfile; if (move_uploaded_file($_FILES['Picture1']['tmp_name'], $fullpath)){   echo("File Uploaded");   echo("$uploaddir");   echo("$uploadfile"); } else {   echo ("file no uploaded!");   print_r($_FILES);   echo realpath('./'); } ?>[/code] Regards Huggie
  25. Use single quotes... [code=php:0]$totalCost+=$row['price'];[/code] Regards Huggie
×
×
  • 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.