Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. This is VERY strange. I was just having the same issue. I was just coming here to open a post and I see yours at the very top. I second the original poster's question. In his situation (same as mine) header redirect won't work. That just depends on the type of download. Meanwhile I am also experimenting right now on using Javascript to handle the form submissions entirely and see if that'll allow for multiple submissions. If I get something work I will post here to help you as well, and if anyone else has any other suggestions they offer here it'll help us both.
  2. I hate asp. <!-- #include file="common.asp" --> <% contact = rq("contact") bname = rq("bname") email = rq("email") comments = rq("comments") ' Set the mail server configuration Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From=email myMail.To="###########" myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="relay-hosting.secureserver.net" 'myMail.Configuration.Fields.Item _ '("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 myMail.Configuration.Fields.Update myMail.TextBody=comments myMail.Send response.redirect "contact.asp?msg=sent" %> Why isn't this sending. This is straight off the examples presented at www.w3schools.com and various other tutorials..Plus code presented on Godaddy's own knowledge base. This should very simply send an email. Instead it's returning: Any advice? Line 22, by the way, is the "myMail.Send" line.
  3. function sortfunction($a, $b) { return $a['count'] < $b['count']; } usort($anchor_master, 'sortfunction'); Perfect, thanks.
  4. Is there a way to sort this master array by the count value in the subarray. I want to sort the entire array based off of this number in Descending order. Is that possible? If so, any advice pertaining to how?
  5. <?php echo '<br /><h1>C Class Summary</h1><br />'; echo '<table><tr><th>Backlink</th><th>IP Address</th></tr>'; foreach ($unique_backlinks as $v) { echo '<tr>'; echo '<td>'.$v.'</td>'; echo '<td>'.gethostbyname($v).'</td>'; echo '</tr>'; } echo '</table>'; ?> This prints out all domains with there IP address. Is there a way to expand this to get the IP block range as well. Is there a function in PHP that'll retrieve the block range?
  6. When your doing something with PHP with an external system they can pick up the IP address. How can I change it with PHP with each request. I am using Yahoo's API and they kind of restrict based off IP. How can I change that with each running of the script?
  7. $regexp = "<a\s[^>]*href=(\"??)(http[^\" >]*?)\\1[^>]*>(.*)<\/a>"; That works. Thanks.
  8. I could loop through the matches..and do a strstr to pull out anything that isn't http...leaving me with just the external links. However that is resource intensive. If anyone knows an easier way let me know. Thanks.
  9. <?php /* Return a list of all links found on a specific "page" */ function getLinks($url) { //$url = "http://www.example.net/somepage.html"; $input = @file_get_contents($url) or die('Could not access file: $url'); $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)) { echo '<pre>'; print_r($matches); echo '</pre>'; } } ?> That function above goes and get's all the links that are present on a website. How can I make it go get only external links. I guess all external links would have to start with http so I have to check to see if it matches. I am only mediocre at Regex. Any advice?
  10. Thank you very much. Quite a helpful function there.
  11. Is there a way to take any website... whatever.com (google.com, yahoo.com, infotechnologist.biz, msn.com, phpfreaks.com, myfavoritesite.com.ca) whatever. Any site out there. And find out what the IP address of the website is using PHP?
  12. I found out why. preg_match returns only the first occurrence while preg_match_all returns all occurrences. That was the mistake I made. Thanks for the help. I am not very experienced at Regular Expressions..I have stayed away from them until now..trying to get my head around them.
  13. I am not sure I can use Ireplace on this. I think the server I am working on is PHP 4. That's why I am using the PHP 4 function. I actually wasn't even familiar of that new function, thanks for pointing that out. I changed the ^ because I found out that meant before in Regex but..that still only returns one result. I need it to return more than one result.... If it's 1 result it's not in the DMOZ record because that is showing up atleast once even when there are no results..when it shows up more than once it's considered in the DMOZ record.
  14. My code: function get_DMOZ($domain) { // Strip the http part if it's there if (strstr($domain, 'http://')) { $domain = substr($domain, 7); } // Strip the www part if it's there if (strstr($domain, 'www.')) { $domain = substr($domain, 4); } // Here is our pattern $pattern = '/^'.$domain.'/'; // Get contents as string $string = file_get_contents('http://search.dmoz.org/cgi-bin/search?search='.$domain); // Match it preg_match($pattern, $string, $results); // Echo Match (This is for debugging) echo '<pre>'; print_r($results); echo '</pre>'; // Return results return $results; } Sometimes it returns errors and the rest of the time it returns an empty array. I want to use this to return if there were occurrences of the domain on DMOZ and then could the DMOZ results..if the results are 1 or greater, then it's listed on DMOZ and I can mark it as listed. Is there anything wrong with the above code?
  15. Is there a way that someone knows of to check the DMOZ directory for a specific site (dynamically) without having to create a site stripper? Or is there currently no way to do that?
  16. Perfect a mixture of those two solutions work. And no the json.title is one variable and title is another variable. json.title was the original variable and has it's uses but I needed some slight changes for the links so I put them in title instead. Thanks for the help.
  17. function open_window(artist, title) { window.open("buy_pages/"+artist+"_"+title+".php", "newwin"); } $('#changing_content').html($('#changing_content').html()+'<center><a onClick="open_window("'+artist+'", "'+title+'");" href="#"><img src="image/buybutton.gif" style="border: none;" /></a><br /><br /><b>'+json.title+'</b></center>'); This should not be throwing a syntax error. This should be simply setting a function onclick for the link and then calling a function when it's clicked.
  18. I found out....why it wasn't working. It is strange. I guess I will never know "why" but when I was setting the session before doing all of my work with the google shopping cart it was screwing up my session..probably something the google system does internally. What I did was try a test case: <?php // Get my currently added item $newitem['product_name'] = $_POST['product_name']; $newitem['product_description'] = $_POST['product_description']; $newitem['product_price'] = $_POST['product_price']; // Get existing item list from session $itemsarray['items'] = $_SESSION['items']; // Set the new item into the array of items $itemsarray['items'][] = $newitem; Then I do all of my stuff with google (get the items together, loop through item array and bind them to the google button, create the google button. After ALL of that is done I come back and refinish my session doing. <?php $_SESSION['items'] = $itemsarray['items']; ?> That overwrites the current session with all of the new item data. This works perfectly throughout however many items I want to add. I am marking this as solved since it's solved but if anyone later knows why this happened I wouldn't mind knowing just for educational purposes later. This was a strange workaround I had to perform for something that shouldn't have been happening in the first place.
  19. Run it through an xhtml parser. There is probably one or more broken tags that is causing the browser to render the xhtml improperly (making the link not work as intended).
  20. It has something to do with the sessions themselves... I tried a different approach and it seemed to work more fluidly at first..but just like before it screws up my session array on the 3rd item entry. It still handles 2 perfectly but messes up on the 3rd and above item additions. <?php if (!empty($_SESSION['items'])) { $item['product_name'] = $_POST['product_name']; $item['product_description'] = $_POST['product_description']; $item['product_price'] = $_POST['product_price']; $_SESSION['items'][] = $item; //$_SESSION['items'][$count]['product_name'] = $_POST['product_name']; //$_SESSION['items'][$count]['product_description'] = $_POST['product_description']; //$_SESSION['items'][$count]['product_price'] = $_POST['product_price']; }else { $_SESSION['items'][0]['product_name'] = $_POST['product_name']; $_SESSION['items'][0]['product_description'] = $_POST['product_description']; $_SESSION['items'][0]['product_price'] = $_POST['product_price']; } echo '<pre>'; print_r($_SESSION); echo '</pre>'; ?> This works great for the first and second items but when the third is added it screws it up and tries to put sub-key four inside the master array and destroys a giant chunk of my array and re-arranges everything around (basically just stops working). Any advice?
  21. Also I have all of the basics in place (session_start()) above all pages and all of that good stuff as well.
  22. I am having this strange error with sessions and google checkout.. I am basically writing some of the code custom. I want to get a session of items and build the google checkout button but my sessions are behaving strangely...first time this has happened actually in the 6 years I have been working with PHP. I have checked all the necessary Session info. [phpinfo] session Session Support enabled Registered save handlers files user sqlite Registered serializer handlers php php_binary wddx Directive Local Value Master Value session.auto_start Off Off session.bug_compat_42 On On session.bug_compat_warn On On session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_httponly Off Off session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.entropy_file no value no value session.entropy_length 0 0 session.gc_divisor 100 100 session.gc_maxlifetime 1440 1440 session.gc_probability 1 1 session.hash_bits_per_character 4 4 session.hash_function 0 0 session.name PHPSESSID PHPSESSID session.referer_check no value no value session.save_handler files files session.save_path /tmp /tmp session.serialize_handler php php session.use_cookies On On session.use_only_cookies Off Off session.use_trans_sid 0 0 [/phpinfo] Those are the settings. THe code I am using looks like: <?php /* Save item in a session for later */ if (!empty($_SESSION['items'])) { $count = count($_SESSION['items'])+1; $_SESSION['items'][$count]['product_name'] = $_POST['product_name']; $_SESSION['items'][$count]['product_description'] = $_POST['product_description']; $_SESSION['items'][$count]['product_price'] = $_POST['product_price']; }else { $_SESSION['items'][1]['product_name'] = $_POST['product_name']; $_SESSION['items'][1]['product_description'] = $_POST['product_description']; $_SESSION['items'][1]['product_price'] = $_POST['product_price']; } $itemsarray = $_SESSION['items']; /* Build Shopping Cart Button */ $merchant_id = '###########'; $merchant_key = '##############'; $server_type = "production"; $currency = "USD"; $cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency); foreach($itemsarray as $items) { $googleitems = new GoogleItem($items['product_name'], $items['product_description'], 1, $items['product_price']); $cart->AddItem($googleitems); unset($googleitems); } ?> This is the area where I am setting the data into a session array then using that array to build the google checkout button. (Further down but not shown is the google checkout button because it's unrelated to this problem). Now..if I add "ONE" item. Then click the button it works. Sessions work, the google item creation works, it creates the button and let's me go to checkout...very simple. If I try to add more than 1 item...it's acting strange. If I try to add "two" items it also works fine. Does sessions right, let's me add items, let's me go to the google checkout and it works great (even passes the items to google checkout via the button. Now if I add in a third item. It messes up. So far it seems it's messing up with the sessions themselves. It ends up not counting them properly, or not assigning them properly. Is there anything obviously wrong with the above code?
  23. That's more of what I was planning on. Setting up different files for different classes, then having an auto-loader and/or loader class so I can load the ones I want. I will take a look at zend. That's one of the only frameworks so far I haven't really "used" so I will install it and take a look to see how it's structured for research purposes.
  24. After writing programs for awhile with a specific language you pick up a lot of misc code that you use for various purposes. I originally used a framework structure which was customized. Which happened to be Codeignitor. After awhile though I noticed some projects are better with code ignitor, some are better with cakephp, some are better with symphony, and sometimes even others are best for a given situation. Not to mention if I am working on a 1 page app...something very simple I generally just attach it to a class and do it without a framework. However I noticed throughout all of this (both with and without a framework) over time I end up using a lot of various code that could be easily ported to standard functions for all purposes. I am thinking of the best way to "carry" these around. I could just create me a standard class. And make ti a large class. It would be setup with all of my functions within the class and I could port them everywhere (the 1 page projects, or in mass applications that need frameworks I could still put it in as a custom calss and have all of my custom functions as well as the stuff that comes with that specific framework. So..I am thinking of the best way to set this up. I could either have: 1) A class that is one class that has all of my things in it (all of my functions). 2) A master class/loader that I use and carry around a folder of classes that contain myfunctions split up by category. Then I can instantiate my master class and load my sub-classes as needed for various use purposes (without having to load all my functions on any one project). Then if I need to use my list of classes for a third party framework I can easily attach my master class into teh framework and use it to load all of my sub-classes into the framework system (or I can build a way to auto-load all the classes when I need them to all auto-load). How do you carry your stuff around? This isn't just applicable for PHP. I noticed in C++ as well there are times when you have custom functions that are modifiable and easily imported into general functions. These as well are not always available in third party classes or in the default C++ classes. This is also applicable in ASP, and ASP.net (with C#). So..this is more of general theory and less PHP specific. Also as a note, I noticed the new icons associated with phpfreaks.com, some of those are nice.
  25. http://www.php-learn-it.com/php_foreach_loop.html Start here. Read carefully and slowly through this page. Then go to next page, and read. All throughout all the pages pertaining to loops.
×
×
  • 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.