Jump to content

SharkBait

Members
  • Posts

    845
  • Joined

  • Last visited

    Never

Everything posted by SharkBait

  1. I do and I don't. That's the trick. There is a field that is City, State and I need to leave the comma in, but all the other fields i would like to remove the comma from. I can do this manually of course, but the end result is that a persona can upload a file, have it corrected for these issues, then write it to a new file which is then loaded into a MySQL table. Unfortunately 1 field needs to be split, the others do not. its why i was trying to match against 2 characters after the comma because in the data files the state is always 2 characters, anything more and it's not a state (not the right field).
  2. Ok I'm slowly getting the idea... perhaps this will help more in explaining what I am trying to do <?php $string = '9/22/2008,Sales,Sales History Ranging From 9/15/2008 To 9/19/2008,Page # 0001,Date,Customer,City & State,ZIP Code Qty, UM,Part Number:,TR-5amp-Nf,"5GHz AP/PtP/CPE, N-female",9/16/2008,"Company. LLC","Nevada, MO",64772,1,EA,Brand Total,799'; ?> I want to drop the comma in the "5GHz AP/PtP/CPE, N-Female" but keep the comma in the "Nevada, MO" so when I explode the string it will hopefully seperate the Nevada and MO only.
  3. Ok, though if <?php $string = 'My Item, OT'; ?> I don't want to drop the comma. Though if it has a hyphen then i want to drop the comma.
  4. Ok I've been trying to figure out the use of regex and hit a bit of a snag. i am trying to massage some data and if the string after the comma is larger than 2 characters I want to drop the comma Example: <?php $string = 'My Item, N-female'; $pattern = '\(\w+),(\s+)(\w{3})/i'; $replacement = '$1 $3'; $temp = preg_replace($pattern, $replacement, $string); ?> But I think the issue I am having is with the hyphen and the above pattern will not drop the comma when but when the string is <?php $string = 'My Item, Fun'; ?> Then it does drop the comma. I am trying to make it so that it drop the comma if the characters after the comma are 2 and less. But if the 2nd character is a hyphen it doesn't drop the comma. What do I need to do?
  5. Trying to figure out how to create a query that queries the same table. A bit confusing right? id | parent_id | serial ------------------------------------- 320 | 0 | 43443 -------+---------------+------------ 423 | 320 | 00ff003300dd -------+---------------+------------ What i need to do is link those two rows together in 1 query so that I can extract the two `serial` values. As you can see parent_id is what links them together. How can this be done with 1 query? I can do it with 2 separate queries but I would like to know how/if it can be done with 1. Thanks
  6. i was following Twitter's API with HTTP to an XML file. But with more investigation it might be an issue with a newer version of the libcURL which I think has issues with sending data after being redirected in the case of say load balancing. I tried the script on 3 servers in total. The live server has a newer version of the libcURL whereas the 2 other servers are back a few revisions. But I will try using an fsockopen and seeing what i get. Thanks for the suggestion!
  7. Ok I have an weird issue and I am trying to figure out why it is working on my development server at home and not my live server. DevServer: PHP Version 5.2.3 cURL Version: 7.16.4 curl_getinfo($ch): [url] => http://twitter.com/direct_messages/new.xml [content_type] => application/xml; charset=utf-8 [http_code] => 200 [header_size] => 717 [request_size] => 260 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.199514 [namelookup_time] => 0.050506 [connect_time] => 0.086238 [pretransfer_time] => 0.086274 [size_upload] => 0 [size_download] => 1286 [speed_download] => 6445 [speed_upload] => 0 [download_content_length] => 1286 [upload_content_length] => 0 [starttransfer_time] => 0.19862 [redirect_time] => 0 Live Server: PHP Version 5.2.6 cURL VersioN: 7.18.2 curl_getinfo($ch): [url] => http://twitter.com/direct_messages/new.xml [content_type] => application/xml; charset=utf-8 [http_code] => 200 [header_size] => 717 [request_size] => 260 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.199514 [namelookup_time] => 0.050506 [connect_time] => 0.086238 [pretransfer_time] => 0.086274 [size_upload] => 0 [size_download] => 1286 [speed_download] => 6445 [speed_upload] => 0 [download_content_length] => 1286 [upload_content_length] => 0 [starttransfer_time] => 0.19862 [redirect_time] => 0 This is the script: <?php $text = 'This is a lot of fun right?'; $ch = curl_init('http://twitter.com/direct_messages/new.xml'); $userpwd = "{$username}:{$password}"; $data = 'user=' . $target . '&text=' . urlencode($text); curl_setopt($ch, CURLOPT_USERPWD, $userpwd); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_NOBODY, 0); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, $twit_plugin_name .' '. $twit_plugin_ver); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); ?> According to the live server it is not getting any POST information and I am not sure why. Is there an option in php.ini or something that might be forcing PHP cURL to use GET and not POST? Now I have set data as a STRING and as an ARRAY and both return the same error message on my Live Server. What am I missing? What other things can I look for?
  8. As a developer I always have a personal local linux box to work from and I set it up to be similar to that of many webhosts or at least the environment similar to what I use at home. My linux box is a simple machine I pieced together (probably total value is like $200-300) and runs Ubuntu Server in LAMP setup. I also set up Samba on it so editing files via my Windows box is easy as Samba makes it accessible without having to transfer files around on my machines. There is no monitor attached I just use PUTTY to log in and make changes to the server if I need to. I don't think there would be really any 'developer' webhosts out there. I mean each 'developer's needs would be slightly different right? Especially if a Client website is hosted somewhere previously (as in I didn't set it up for them) having my own DevServer allows me to work in a similar environment and when it's time to go live I upload and 99% of the time have no compatibility issues (as in missing packages). I think there has been only one client who had to get in touch with their webhost to install GD or something at one point but whatever. So if you're looking to have a server to do 'development' work on I would recommend piecing together a small cheap little server you can run *inux on locally.
  9. I know how to create WP themes and it is one thing I would _not_ want to do over IM.I mean there are great tutorials on the net already with step by step explanations of what to do when you want to create your own theme (best to start with an existing one and modifying it to your liking). The other question i would ask is, do you know any HTML, CSS, or even PHP? If not then I suggest you learn them you'll have a MUCH easier time learning how to do it. In general WP themes are fairly straight-forward. Typically there are a few files associated to a theme: header.php, footer.php sidebar.php, index.php, single.php and then the stylesheet itself. Other files might include: comments.php, search.php, functions.php etc etc I learnt how to create theme using the Kubrick WP theme (default theme) the tutorial I used (cant remember where it is but Google is a great resource) pretty much told me to gut anything in reference to the 'Kubrick' theme (functions, CSS etc) and build up from there. The WP Codex you will need to reference from time to time to find out what the various PHP functions do for a Wordpress theme. The main Codex is the Loop. If you check out my blog (the URL in my signature) it shows you the theme I created by myself in the beginning. If you have questions about aspects you can chat me up, but I'll tell you right now I'm not into holding hands with someone. I prefer them to start learning on their own and if they get stuck I can give you hints or suggestions on why you're stuck and what you might want to try to get out of it.
  10. I've used CAPTCHAs which seem to work for the most part though people (bots too) are getting smarter about getting past them. Though never display your email address in the form, or hidden. If you need to try and obscure it. You could use an image to display your email address but I know people who have programs that scan images for text etc pretty neat actually. If you use a server-side language such as PHP you can do some pretty cool validation and parsing of the information being sent, including checking to see if someone is trying to hack or force new email headers and since you can store you email address server-side in a variable they can't retrieve it and use it to spam the crap out of you. I've used forms with CAPTCHAs for multiple projects and the only spam they would receive would be form someone actually taking the time to fill it out which is really rare. I think one of the forms I have on a website has only received 2 spam emails since it has been in place for about 3 years.
  11. you could also use readonly="readonly" which would allow them to highlight if needed
  12. How do you know you are not getting an error? You're not echo'ing your $error variable anywhere that I can see in the code.
  13. Try using just \n \r\n is for windows based environments I believe where \n is for *nix environments.
  14. Wishing all the American's a happy and safe July 4th! From your neighbours in the chilly North!
  15. Ah that works nicely. and $results[1] is the filename cool. Thank you
  16. Hi, What I am trying to figure out is how to retrieve the image tag from content within my website. I looked at this post: http://www.phpfreaks.com/forums/index.php/topic,139613.0.html but it does not work when there are sentaces etc between the <img> tags. What I am trying to accomplish is pulling the first image in a paragraph and then reusing it else where. Ex: This is a post and within this post we have a <img src="image.jpg"> in which we need to locate and use else wehre but then if we have <img src="another.jpg"> image laying around the above function (in the link provided) does not seem to function correctly. How do I go about matching content (assume its in variable $body) for the first <img> tag so that I can pull the src="" value from it and use it else where? I thought about trying <?php preg_match('/<img[\s]+src/=(.*)/>/', $body, $results); ?> But that didn't really do the trick as the 2nd element in the $results array is a combination of the string and the 2nd <img> tag.
  17. That will output the session variable to the screen. if it is not set, then you wont see any text beside the Stored username: string
  18. Then before that like type in echo "Stored username: {$_SESSION['username']}";
  19. How is it being corrupt? The way I found out if something was an issue with a download I would open up the corrupt file via notepad or something. What I found when my downloads were corrupt was that the header of the file was including an error message. In my case it was because the actual filesize was different than the filesize I was passing to the header function when I would initiate the code to prompt the user to save the file to a location.
  20. SELECT T1.id, T1.description, T2.firstname, T2.surname FROM incidents AS T1, INNER JOIN users AS T2 ON (T1.contact_id = T2.id) T1.contact_id = 9 Try that?
  21. Remember that search engines don't like websites that are built for them. Websites should be built for your intended audience. You could create the URLs to be human readable IE: myplace.com/page?id=339&view=kitchen&man=LG might want to look something like: myplace.com/products/kitchen/fridges/LG54e Remember Content is King - Search Engines bots crawl your webpage in text. Load up Lynx as a browser and see how your site looks in all text (or strip your CSS to remove graphics/styles etc). Use proper tags - H1, H2, h3, <strong> etc to place emphase on things 997740 - Sure Google accounts for less than 50%, but 49.2% is still a BIG gap from the next engine being Yahoo at 23.8%.
  22. <?php if(isset($_POST['submit'])) { echo "You've submitted the form"; } ?> <form action="thisscript.php" method="post"> <input type="submit" value="submit" name="submit" /> </form> Like that?
  23. I don't think there is a way to get to the MAC address or anything like that to identify the user. Hoping also that the user's machine isn't having their MAC Address cloned in the first place (some network devices do this). IPs aren't perfect either since people can behind proxies or again other network devices. Take my connection for example. To the internet the building I work at comes from all 1 IP address, but of course internally we are on a different subnet. So if I were to log into this site, I would have the same IP external address as my buddy downstairs in a different department. As for cookies between browsers. I don't know many people who surf using different browsers. I for one do all my surfing using Firefox. I have Safari, Opera, IE(5 & 6) for development needs, but I don't regularly use them.
×
×
  • 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.