Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. The contents is irrelevant. Basically what that is doing is sending data to that url. If you look at the string "Name=$Name&Email=$Email&Message=$Message", that's what's being sent. On the other end it would be captured like a standard post. ex. echo $_POST['Name'];
  2. To see the contents of the array (for debugging or whatever) use print_r. If you want to just display the contents of the array as a string with a comma as the delimiter you can use implode() ex ... echo implode(', ', $data);
  3. There is good information available on the link I posted. You can also try http://www.askapache.com/htaccess/sending-post-form-data-with-php-curl.html or Google.
  4. You can't do it like that. I think what you want to do is something like this: You're able to specify an array as the name for the elements in a form, then $_POST['fieldname'] would be an array containing the information from all the inputs. You can then do whatever you want with that. ex ... <input type="text" name="fieldname[]" /> <input type="text" name="fieldname[]" /> ... <?php $array = $_POST['fieldname']; // Array('first input value', 'second input value'); ?>
  5. What you're trying to do is the set the source of an image to a page containing only html. What you're going to want to do is look into the PHP GD Library. What you can do is using imagecreatefrom*() (imagecreatefrompng, etc..) create the imageresource from the location then output it to the browser using image*() (imagepng(), etc..). Assuming it's a .png image it would be something like this: $id = htmlentities($_GET['id']); if($id != '') { $query = "SELECT location FROM pictures WHERE id='$id'"; $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result) > 0) { $imageData = mysql_fetch_array($result); $im = imagecreatefrompng($imageData['location']); header('Content-type: image/png'); // Set Content-type header to image/png to output an image imagepng($im); } }
  6. Depending on the version of PHP. No. I assume you're talking about PHP 4's lack of visibility keywords, but in PHP 4 the constructor was not called __construct(). Actually, public is optional for methods because things by default are public. Yes, I was referring to that. But I forgot that constructors in PHP 4 were the same name as the class. Doh.
  7. Typo? I don't think so. Maybe I didn't explain what I meant well enough. I mean like this: <?php $str = 'Blah Blah Blah. Hello World'; if(strpos($str, 'Blah') !== false) // Use !== false to see if it's present { echo 'Found'; } if(strpos($str, 'Not found') === false) // Use === false to see if it's not present { echo 'Not Found'; }
  8. I dont think === true will work since the function returns the integer position. Correct, === true will not work. Just use !== false or === false.
  9. $fh = fopen("directory/myfile.txt", "w");
  10. The strings are causing you problems. Double quotes parse variables while single quotes do not, so you need to do something like this: eg $host = '$host="' . $test . '";' . "\n";
  11. In this case $_POST['selected'] is an Array, so you're doing to want to loop through that. $value = $_POST['selected']; foreach($value as $val) { $body .= "$val<br />\n"; }
  12. Then wouldn't the method I posted previously suffice?
  13. There's a website here which does syntax checking on php files, and the source code to that is available. But even that runs the code. Is there any particularly reason that you don't want to run the code? The way I'd do it is to use file_get_contents() using the URL (so you don't just get the PHP code; assuming fopen_wrappers is enabled) and grab what the script running is outputting.
  14. right, but what exactly does "set" mean. I understand NULL Has a value other than NULL. Ex: $var = null; // is NOT set while.. $var = ''; // is set
  15. You should have a primary incrementing key field so that you can identify certain records. Then use a WHERE clause to make sure you're only updating one record (and remove that insert query..). Another problem I see if that you don't have quotes around $website_name in your UPDATE query.
  16. You should define an array containing directories that you don't want to show. Then within your foreach check to see if the current element is in that array, if it is skip that iteration using the continue keyword. ex $hide = Array('dir1', 'dir2'); ... foreach($d as $f) { if(in_array($f, $hide)) continue; echo "<option value=\"$f\" >$f</option>"; } ...
  17. You shouldn't be inserting more records then, just updating the one.
  18. I don't see anything immediately wrong with that. Are you sure website_name is the name of the column? You might want to put in print_r($row) for debugging.
  19. That alone won't save it. For saving the image after you've manipulated it use image*(), depending on the format you're dealing with. Ex: imagepng(), imagegif(), etc.
  20. More specifically look into imagecopymerge(), this will allow you take 2 images and merge them with alpha transparency, or if the watermark itself is already translucent you can just use imagecopy(). I know for a fact there are examples of this on php.net, but if you need another example just ask.
  21. It would help if you posted the error and the code that goes along with it.
  22. I wasn't thinking, this doesn't require anything too complicated. This is an easier solution: <?php function parseip($ip) { return preg_replace('~(\d+)\.(\d+)\.(\d+)\.(\d+)~', "$1.$2.*.*", $ip); } $ip = '82.132.196.45'; echo parseip($ip); //82.132.***.**
×
×
  • 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.