Jump to content

graham23s

Members
  • Posts

    890
  • Joined

  • Last visited

Everything posted by graham23s

  1. Hi Buddy, $from = "From: $visitormail\r\n"; mail("YourEmail", $subject, $message, $from); $from (this should be your email/or company email) and "YourEmail" (this is the email that the message will be sent to) to do multiple emails do: (email1,email2), $subject etc cheers Graham
  2. Hi Guys, I have a folder full of product images, like: shoes.jpg jacket.jpg etc in my database i have a field called product names that are structured like shoes jacket with this code: <?php include("inc-dbconnection.php"); $q = "SELECT * FROM `fhp_products`"; $r = mysql_query($q); $dir = 'images/'; $files = scandir($dir); foreach ($files as $file) { if ($file!='.' && $file!='..' ) { // Take away the extension of the image files to leave just the filename $image = explode(".", $file); // List of images in directory echo $image[0].'<br>'; } } echo "<hr>"; while ($a = mysql_fetch_array($r)) { $ID = $a['id']; $genericName = $a['product']; $strReplace = str_replace(" ", "-", $genericName); // This print all the products echo $strReplace.'<br>'; } ?> i manage to do some string manipulation, i have: 1) cut the extension of the images 2) replaced spaces the hyphens what this does is makes the shoes.jpg into shoes (exactly as it appears in the database) what i need to do is: UPDATE `fhp_products` SET `image`='NAMEOFTHEIMAGE' WHERE `id`='$ID'; basically so: if ($image[0] == $strReplace) { // If this is shoes then update the database accordingly etc UPDATE `fhp_products` SET `image`='NAMEOFTHEIMAGE' WHERE `id`='$ID'; } I hope i explained it properly lol thanks for any help guys Graham
  3. Hi Roopurt, Thanks a lot mate, i managed to get access to the data i wanted and i'm a little wiser on xml, the only other part is how would i go about accessing the data on all the products, i know i need a foreach like: <?php //$xmlFile = "data.xml"; //$xmlobj = new SimpleXmlElement(file_get_contents($xmlFile)); //print_r($xmlobj); $object = simplexml_load_file("data.xml"); foreach($object as $prodName) { //$xmlobj = new SimpleXMLElement($object); // <-- PRETTY SURE THIS IS REDUNDANT AND UNNECESSARY //echo $object->category['name']; echo "Product Name: " . $object->category->product['name']; echo "<br />"; //echo $object->category->product->description; //echo $prodName; } ?> any pointer son the foreach would be great, thanks for your help mate Graham
  4. Hi Mate, The most akward one is this one: <?xml version="1.0"?> <root> <bonus> <bonus bonus_id="5" qty="4" title="title1" variant="6"/><bonus bonus_id="6" qty="2" title="title2"/></bonus> <category name="Stop Smoking"><product bestseller_flag="0" brand="brandname" brand_flag="0" container="tablet" dosages="150mg" generic="genericTitle" name="productName"> <description>description goes here<description> i really just need the category name and the description values. cheers mate Graham Graham
  5. Hi Guys, In an xml file i am pulling from a site there is spaces between some of the nodes for example: category name has a space in the middle, does this matter at all, or is there a special way to deal with them? test code: <?php $object = simplexml_load_file("data.xml"); $xmlobj = new SimpleXMLElement($object); echo $xmlobj->root->category name; ?> thanks guys Graham
  6. Hi Guys, I use the following code to save to my pc, the xml data from a feed: <?php $request->asXML("data.xml"); $response = simplexml_load_file("data.xml"); ?> This works perfectly, when i view the contents of the saved xml i see: <?xml version="1.0"?> <root><bonus><bonus bonus_id="5" qty="4" title="titleName" variant="6"/><bonus bonus_id="6" qty="2" title="titleName2"/></bonus><category name="Acne Care"><product bestseller_flag="0" brand="clearasil" brand_flag="0" container="tablet" generic="yes" name="titleName3"><description> The structure of this xml is different from what i am used to lol, what would be the best way to grab all the values of each name? something=value, something=value never really done this type before. thanks for any help guys Graham
  7. Hi Buddy, That worked perfectly thanks mate Graham
  8. Hi Mate, You could append the current time to the uploaded file for example: // Find out what ther files extension is, anything after the (.) $fileExtension = substr(strrchr($file_name, '.') ,0); $fileExtension = strtolower($fileExtension); // The new file name $newFileName = $file_name . time() . $fileExtension; Graham
  9. Hi Guys, I can dump out the data from a remote xml file, but i was wondering what would be the best way to save the data to a data.xml file. code: $request = simplexml_load_file("https://site.com/feeds/xml_feed_1.0.php?wm_id=8344&site_id=8030&tracking_id=8030"); the data is returned ok i just need to save the returned data to a file. thanks for any help guys Graham
  10. Hi Mate, Strangely it does the same on my localhast (windows) amd Host account (Linux) even with the regex you gave me, i have done a little php fix to combat it, but it's definately a starnge one. thanks mate Graham
  11. Hi Guys, I have tested a few categories out with the .htaccess code: Options +FollowSymLinks RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^[^/]+-([A-Z0-9]+)\.html$ product-information.php?id=$1 [QSA,L] RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([0-9A-Z]+)-[^/]+\.html$ category.php?cat-id=$1 [QSA,L] The categories are: Books, DVD, Toys, Electricals All of them work great apart from DVD it shows me an on site error i shouldn't really see, the only difference from the DVD category to the rest of them is that the word DVD is all in capital letters would that make a difference? cheers guys Graham
  12. Hi Mate, i ended up doing: function amazon_strip_symbols($stringToClean) { $new_string = preg_replace("/[^a-zA-Z0-9\s]/", " ", $stringToClean); return $new_string; } which seems to strip the gunk from the titles pulled back from amazon THEN they are hyperlined to a url for example: www.site.com/title-with-symbol's-book.html <- this symbol (') was crashing the script. cheers mate Graham
  13. Hi Cags, Thnaks mate, i did a test on the title above and the anchor text came out like: The+Major+Works%3A+including+The+Rape+of+the+Lock+and+The+Dunciad+%28Oxford+World%27s+Classics%29-0199537615.html'>The+Major+Works%3A+including+The+Rape+of+the+Lock+and+The+Dunciad+%28Oxford+World%27s+Classics%29 what i am trying to do is make that title a hyperlink to the products page, but because of all the symbols in the title text it cuts me off, simple titles like: The Last Pope work perfect but the majority of amazons titles have symbols in them. thanks mate Graham
  14. Hi Guys, I have written a shopping cart that uses the Amazon API, a lot of amazon's products bring back some funky titles for example: The Major Works: including The Rape of the Lock and The Dunciad (Oxford World's Classics) i can't make this a hyperlink because of the ' and : symbols, is there somthing i can do to clean the titles before displaying them? thanks guys Graham
  15. Hi Mate, That is perfect thank you Graham
  16. Hi Guys, I normally use this code in my .htaccess file: Options +FollowSymLinks RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^[^/]+-([0-9]+)\.html$ product-information.php?id=$1 [QSA,L] RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([0-9]+)-[^/]+\.html$ category.php?cat-id=$1 [QSA,L] My product id's were just numeric values, but i have added some products with id's that look like: UVWL2BUAL720R which contain random number and letters, i'm not sure the proper syntax to use in the .htaccess file. any help would be appreciated guys. thanks Graham
  17. Hi Guys, I use this code below to query amazon's api and display remote shopping carts: <?php // Check if the customer has an amazon order in the database, if so show it if (amazon_cart_not_empty($cusSessionID)) { // If the cart isn't empty retrieve the cartID and HAC ID $cartID = amazon_unique_cart_id($cusSessionID); $cartHI = amazon_unique_hwac($cusSessionID); // Display top half print '<form onSubmit="return updateCartCheck();" action="cart.php?do=update" name="fcsShoppingCart" method="POST" /> <input type="hidden" name="cusSessionID" value="" /> <table border="1" class="CartContents Stylize General" cellspacing="0" cellpadding="0"> <thead> <tr> <th colspan="2">Cart Items</th> <th style="text-align: center; white-space: nowrap;">Qty</th> <th style="text-align: center; white-space: nowrap;">Item Price</th> <th style="text-align: right; white-space: nowrap;">Item Total</th> </tr> </thead> <tbody> <tr>'; // Credentials $PublicKey = "xxxxxxxxxxxxx"; $PrivateKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxx"; // Prarameters we need to send to the function $parameters = array( 'AssociateTag' => 'firschoishop-21', 'Operation' => 'CartGet', 'CartId' => $cartID, 'HMAC' => $cartHI, ); // Execute the function to return our URL $url = amazon_signed_request("co.uk", $parameters, $PublicKey, $PrivateKey); print $url; // Load the results and get the contents $response = simplexml_load_file($url); // Loop through the xml nodes foreach ($response->Cart as $item) { // Whats our cart id? $cartID = $item->CartId; $cartNM = $item->CartItems->CartItem->Title; $cartQY = $item->CartItems->CartItem->Quantity; $cartPR = $item->SubTotal->FormattedPrice; // What product group $cartPG = $item->CartItems->CartItem->ProductGroup; print $cartPG; // We need to use the function to determine what item number we need if ($cartPG == "Book"){ $identificationNumber = $item->CartItems->CartItem->ASIN; } elseif($cartPG == "DVD"){ $identificationNumber = $item->ItemAttributes->ISBN; } print '<td class="CartThumb">'; print ' <img src="imgProducts/img-th/thumb-Eczema-Free-Forever-1250421912.jpg" border=\"0\"/></a>'; print ' </td>'; print ' <td class="ProductName" colspan="1">'; print ' '.amazon_friendly_url($cartNM, $identificationNumber).' <b>- </b>(<a href=\"cart.php?do=remove&product-id=$cartProdID&customer-id=$cusSessionID\" onclick=\"return confirm(\'Are you sure you want to delete this item?\')\"><span class=\"fcs-message-intro-w\">X</span></a>)'; print ' <br />'; print ' </td>'; print ' </td>'; print '<td align="center">'.$cartQY.'</td>'; print '<td align="right"><em class="ProductPrice">'.$cartPR.'</em></td>'; print '</tr>'; } // Display bottom print '<table border="0" cellpadding="5" cellspacing="0" />'; print ' <tr>'; print ' <td class="fcs-proceed-checkout-border" align="right" colspan="2"><input type="image" src="img/img-update-cart.png" alt="Update Cart" /></span><a href="checkout.php" onClick="return cartCheck()" title="Click here to proceed to checkout"><img src="img/img-proceed-checkout.png" alt="Click here to proceed to checkout" border="0" /></a></td>'; print ' </tr>'; print '</table>'; // We don't want the script to execute any further include("inc/inc-footer.php"); exit; } ?> This works great, when i test the xml in the browser it shows up 2 products in the cart, but only 1 is showing up in my cart on site. the foreach here: // Loop through the xml nodes foreach ($response->Cart as $item) { // Whats our cart id? $cartID = $item->CartId; $cartNM = $item->CartItems->CartItem->Title; $cartQY = $item->CartItems->CartItem->Quantity; $cartPR = $item->SubTotal->FormattedPrice; // What product group $cartPG = $item->CartItems->CartItem->ProductGroup; print $cartPG; // We need to use the function to determine what item number we need if ($cartPG == "Book"){ $identificationNumber = $item->CartItems->CartItem->ASIN; } elseif($cartPG == "DVD"){ $identificationNumber = $item->ItemAttributes->ISBN; } print '<td class="CartThumb">'; print ' <img src="imgProducts/img-th/thumb-Eczema-Free-Forever-1250421912.jpg" border=\"0\"/></a>'; print ' </td>'; print ' <td class="ProductName" colspan="1">'; print ' '.amazon_friendly_url($cartNM, $identificationNumber).' <b>- </b>(<a href=\"cart.php?do=remove&product-id=$cartProdID&customer-id=$cusSessionID\" onclick=\"return confirm(\'Are you sure you want to delete this item?\')\"><span class=\"fcs-message-intro-w\">X</span></a>)'; print ' <br />'; print ' </td>'; print ' </td>'; print '<td align="center">'.$cartQY.'</td>'; print '<td align="right"><em class="ProductPrice">'.$cartPR.'</em></td>'; print '</tr>'; } seems to only loop though table html once, waht would be the best way to loop the other table out? thanks guys Graham
  18. Fixed! sorry guys $items should have been $item in the foreach. Graham
  19. Hi Guys, after afew hours i have coded an amazon api handler, i receive the response which is in xml format but i am having trouble getting the data from the returned xml. code: // Execute the function to return our URL $url = amazon_signed_request("co.uk", $parameters, $PublicKey, $PrivateKey); // Load the results and get the contents //$response = file_get_contents($execute); // Test //$xmlObject = htmlspecialchars($response); //print $xmlObject; $response = simplexml_load_file($url); /*foreach ($response->Items->Item as $item) { $Title [] = $item->ItemAttributes->Title; $img [] = $item->SmallImage->URL; } foreach($Title as $CurrentTitle) { echo "<h2>".$CurrentTitle."</h2>"; } foreach($img as $imgTitle) { echo "<img src=".$imgTitle.">"; }*/ foreach ($response->Items->Item as $item) { $title = $items->ItemAttributes->Title; $price = $items->Item->OfferSummary->LowestNewPrice->FormattedPrice; $asin = $items->Item->ASIN; $img_src = $items->Item->SmallImage->URL; $desc = strip_tags($items->Item->EditorialReviews->EditorialReview->Content); if (strlen($desc) > 300) { $desc = substr($desc,0,299); $desc = preg_replace("/\s+[,\.!?\w-]*?$/",'...',$desc); } $href = 'http://www.amazon.com/gp/product/'. $asin .'?ie=UTF8&tag=YOUR-ASSOCIATE-ID&linkCode=as2'. '&camp=1789&creative=9325&creativeASIN='. $asin; $buy = ' <a rel="nofollow" href="'. $href .'" title="'. $title .'">'. 'Buy for: '. $price .'</a>'; $html .= '<div style="clear:both;"><h3 class="title">'. $title .'</h3>'; $html .= '<div style="float:left;padding:5px 10px 5px 0;">'. '<a rel="nofollow" href="'. $href .'" title="'. $title .'"><img alt="" src="'. $img_src .'"/></a></div>'; $html .= '<div><p>'. $desc . $buy .'</p></div></div>'; } print $html; This part i have commented out works, but it's the code at the bottom i'm having trouble with, my nodes must be slightly out lol thanks for any help guys Graham
  20. Hi Mate, Yeah i have seo'd the links to contain: www.site.com/123-product-name.html i'll knock something up thanks mate Graham
  21. Hi Guys, I have an e-commerce site that has over 1200 products, i'm tidying up my SEO skills and know that a sitemap is pretty important, but i'm not sure the best way to do a dynamic sitemap, i would need to query the database and then build and loop the products i guess, is there any pre-made scripts out there at all could anyone recommend? thanks a lot guys Graham
  22. Hi Mate, That's the one i remembered after i posted i usually code in vb.net haven't done php in a while i have: $qQ1 = "SELECT DISTINCT 'PRODUCT_ID' FROM `fcp_orders_master_log` GROUP BY `uniqueCount` LIMIT $num, $max"; $rQ1 = mysql_query($qQ1); $numResultsWithClause = mysql_num_rows($rQ1); $test = $aQ1['uniqueCount']; print $test; But it's not printing me anything, the syntax seems ok. cheers Graham
  23. Hi Guys, I can't remember the query i need here lol, basically in my master logs table i have: ID | PRODUCT_ID | CART_ID | DATE 1 | 23 | 1234 | 11/10 2 | 27 | 1235 | 12/10 3 | 27 1236 | 12/10 i'm trying to group together the number product id's so i can keep track of the number sold of that product i forget the query though. thanks guys Graham
  24. Hi Guys, My categories on my site look like: 86-Health-%3E-Fitness.html it should be: 86-Health->-Fitness.html the funny thing is when i print it to screen it shows as > but when it's in the url it shows as: %3E I feed this into my function: <?php // LOOP OUT THE CATEGORIES $qC = "SELECT * FROM `fcs_categories` ORDER BY `category_name` ASC"; $rC = mysql_query($qC) or die (mysql_error()); // LOOP while ($aC = mysql_fetch_array($rC)) { // VARS $catID = $aC['id']; $catNM = $aC['category_name']; // Call the function $links = generate_seo_friendly_category_links($catNM, $catID); // Print the links print "<li class=\"\">$links</li>\n"; } ?> Then the function that converts to seo friendly urls function generate_seo_friendly_category_links($catNM, $catID) { // Clean up the product names $replacedNM = str_replace(" ", "-", $catNM); // Trim the white space $nameTrimmed = trim($replacedNM); // The string together $brandNewSEOFriendlyURLCat = "<a href='$catID-$nameTrimmed.html'>$catNM</a>"; return $brandNewSEOFriendlyURLCat; } is there a way the url can show the symbol > rather than the unsightly %3E thanks a lot guys Graham
×
×
  • 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.