Jump to content

pkSML

Members
  • Posts

    191
  • Joined

  • Last visited

Everything posted by pkSML

  1. $string_exp = "@^[a-z .'-]+$@i"; if(preg_match($string_exp,$first_name) == 0) { $error_message .= 'The First Name you entered does not appear to be valid.';} Give that a whirl. Edit: added the "i" PCRE switch to make it caseless.
  2. Yes, you are correct. But since they're calling the page by a frame, couldn't you just adjust the frame HTML code? for instance <iframe src="http://pawlectros_site.com/?referrer_id=73825" width="100%" height="300">
  3. Woops! I thought you were just discarding everything after the last dot. @thebadbad - nice to see there's another way of doing things, probably closer to 'best practice' Anyhow, here's how my code changes now that I understand what you needed to happen. <?php $pos = strrpos($str, '.'); // this will give us the position of the last dot in the string -- strpos() will give you the first occurrence $newstring = substr($str, 0, $pos) . preg_replace("/[^a-zA-Z0-9]/", "", substr($str, $pos)); // You'll have $newstring, which contains everything up to the last dot and all alphanumeric characters after the last dot in the string ?>
  4. You should be able to do that with strpos and preg_replace in PHP. <?php $pos = strrpos($str, '.'); // this will give us the position of the last dot in the string -- strpos() will give you the first occurrence $newstring = preg_replace("/[^a-zA-Z0-9]/", "", substr($str, 0, $pos)); // You'll have $newstring, which contains all alphanumeric characters from the beginning of $str until the last dot in the string ?>
  5. Put your span tag inside the a tag. <td><? echo "<a href=\"profile?user=$session->username\"><span class=\"style10\">Profile</span></a>" ?></td>
  6. Maybe you could give us the URL to see if we get the same errors. What browser are you using? Try a different browser. Otherwise, make sure you've actually saved the php file on the server. Might as well check the basics!
  7. Try the code here: LitlURL link
  8. Yah. Give me a few minutes. I'm tweaking the code. BTW, what file types will you mostly be downloading? mp3, png, jpg, gif, etc???
  9. What exactly are you trying to do? 1. Server downloads file Then: Server pipes file to user to download?
  10. What exactly is that old query error? Could you show us the snippet of code that still gives you this error?
  11. Actually, check out this link: LitlURL link Use strlen($data) rather than filesize() You'll need to manually set the filename of whatever they're downloading.
  12. Specify the content-type in a HTTP header. (You'll have to have an array of extensions mapped to content-types.) Then readfile($data); You will need extra headers to make the save file dialog box come up. You can google that too: Download file headers cross-browser
  13. Run the command line (Start --> Run --> cmd.exe) navigate to the directory with the script in it. find the location of your php.exe. type in something like this: c:\php5\php.exe -f spider.php
  14. PS If you need more help, put an example of what $invite_emails looks like in [ code ] tags.
  15. You should check out your favorite friend, Google Anyways, found this script here. <?php $url = 'http://www.assistprogramming/image.jpg'; $curl_handler = curl_init(); curl_setopt($curl_handler, CURLOPT_URL, $url); curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handler, CURLOPT_BINARYTRANSFER, 1); //return the transfer in a binary format . $data = curl_exec($curl_handler); curl_close($curl_handler); // Do whatever you want to with $data - it holds the binary content ?>
  16. Here are the arguments: mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit [, int &count]] ) So, here's how I'd do it. <?php $invite_emails = 'john@doe.com, jane@doe.com, testing@mydomain.com,me@me.net'; $search = array('@,\s@', '@,@'); $replace = array("\n", "\n"); $invite_emails = preg_replace($search, $replace, $invite_emails); echo "<PRE>" . $invite_emails . "</PRE>"; ?> This script takes this: john@doe.com, jane@doe.com, testing@mydomain.com,me@me.net and makes it this: john@doe.com jane@doe.com testing@mydomain.com me@me.net
  17. Have you tried preg_replace? You are wanting the output to be a multi-line string, correct?
  18. You can use file_get_contents to grab the HTML source and then run it through a parsing function to scape links. You won't be able to run this indefinitely-running script through your browser unless you had a customized ajax interface (think $100's). You'll need to run this on the command line.
  19. Wow, that's going to take a lot of brainpower! I would pass three variables into the script: maxWidth, maxHeight, crop. If crop is true, then the image needs to be cropped. You'll want to have a function dedicated to cropping. Preferably you'd want to crop the image, keeping the center. You set that stuff with imagecopyresampled. You tell it what parts of the source image you want to keep.
  20. Well, all this would depend on what you do with it. If you rely on GET or POST data for filenames, you're in for some trouble. MySQL injection can leak information from your database. I'd suggest that you read up on PHP security. There are gazillions of articles on the net about it. Since PHP is very powerful, the potential for bad and good is all in the hands of a security-conscious coder.
  21. You can set a timeout in the session itself. Continually update the session on every page with an expiry X amount of seconds into the future. The way you do this is with session_set_cookie_params session_set_cookie_params must be set before you run session_start On the server side, set the session.gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and cleaned up. This can be found in your PHP.ini file.
  22. I'm still trying to understand what you're doing. So you have a session-based login system. Users have one minute to start downloading a podcast, otherwise they'll be logged out???
  23. Your logic doesn't make sense to me. Assuming user A is inquiring about user B: User A would not have User B anywhere in his session. Every time someone inquires of their own session, they are definitely online. Here's the logic that makes sense: You'll need a MySQL database that records that timestamp of each user's last action (there would need to be a login system). Then your script would inquire about a user's online/offline status through the database. Session data would only serve to keep the user's username stored and available to write an updated timestamp to the database.
  24. Try this: (if needed) <?php for($i = 1; $i <= $_POST['fieldnums']; $i++) { $description = $_POST['description'][$i]; $price= $_POST['price'][$i]; mysql_query("INSERT INTO table_name_here_break_down (description,price) VALUES ('$description','$price')") or die (mysql_error()); } ?> I edited this to make it work right. (I also hope you caught the few times I forgot to escape a double-quote a few posts ago. I also forgot to add a semicolon.) Maq's example would work as well. Just insert your query in his example with the variables $desc and $price.
  25. As for this code, try this: <?php for($i = 1; $i <= $_POST['fieldnums']; $i++) { ///do stuff here } ?>
×
×
  • 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.