Jump to content

unplugged_web

Members
  • Posts

    897
  • Joined

  • Last visited

Everything posted by unplugged_web

  1. I changed the code to this: var $buttonID = $j(this).attr('id'); $buttonID = $buttonID.replace("change","data"); console.log($buttonID); and it now worksde to this: var $buttonID = $j(this).attr('id'); and it now works
  2. How do I change the text of this? I'm getting the id of a button (which works) but when I try to change it the console outputs the buttons value instead. This is what I've got: $j(this).attr('id'); var $buttonID = $j(this).val(); $buttonID = $buttonID.replace("change","data"); console.log($buttonID); if I do this though the alert box shows the buttons id: alert($('.change').attr('id'));
  3. The file was automatically saved from a feed so I wasn't able to change the output. I decided to use a cvs copy of the feed instead as that wasn't changed at all
  4. This is what I've got so far but all I get is errors. This is the code I'm using to get the xml file into the database: <?php$xml = simplexml_load_file('feed.xml');foreach($xml->children() as $product) { mysql_query("INSERT INTO data (name,desc,tracking,brand) VALUES ('$product->text->name','$product->text->desc','$product->uri->Track','$product->brand->brandName')");} ?> and this is the XML file: <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE cafProductFeed SYSTEM "http://www.window.com/DTD/affiliate/datafeed.1.4.dtd"><cafProductFeed><datafeed id="36" merchantId="36" merchantName="Company"><prod id="12345678"> <brand> <brandName>Universal Pictures</brandName> </brand> <cat> <CatId>550</CatId> <Cat>Blu-Ray</Cat> <mCat>Blu-ray</mCat> </cat> <price curr="USD"> <buynow>44.99</buynow> <delivery>1.99</delivery> <store>0.00</store> </price> <text> <name>Product</name> <desc>description text</desc> </text> <uri> <Track>http://www.tracking.com</Track> <Image>http://images.domain.com/</Image> <mImage>http://www.images.domain.com</mImage> <mLink>http://www.domain.com/blu-ray/bourne-identity/the-bourne-supremacy/the-bourne-ultimatum/</mLink> </uri> <vertical/> <pId>1234567</pId> <largeImage>http://large.image.com</largeImage> <ean>1234567</ean></prod><prod id="12345678"> <brand> <brandName>Universal Pictures</brandName> </brand> <cat> <CatId>550</CatId> <Cat>Blu-Ray</Cat> <mCat>Blu-ray</mCat> </cat> <price curr="USD"> <buynow>44.99</buynow> <delivery>1.99</delivery> <store>0.00</store> </price> <text> <name>Product</name> <desc>description text</desc> </text> <uri> <Track>http://www.tracking.com</Track> <Image>http://images.domain.com/</Image> <mImage>http://www.images.domain.com</mImage> <mLink>http://www.domain.com/blu-ray/bourne-identity/the-bourne-supremacy/the-bourne-ultimatum/</mLink> </uri> <vertical/> <pId>1234567</pId> <largeImage>http://large.image.com</largeImage> <ean>1234567</ean></prod></datafeed></cafProductFeed> but all I get is errors: Warning: simplexml_load_file(): http://www.domains.co.uk/feed.xml:1: parser error : Space required after the Public Identifier in /home/domain/parse.php on line 2 Warning: simplexml_load_file(): <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/domain/parse.php on line 2 Warning: simplexml_load_file(): ^ in /home/domain/parse.php on line 2 Warning: simplexml_load_file(): http://www.domains.co.uk/feed.xml:1: parser error : SystemLiteral " or ' expected in /home/domain/parse.php on line 2 Warning: simplexml_load_file(): <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/domain/parse.php on line 2 Warning: simplexml_load_file(): ^ in /home/domain/parse.php on line 2 Warning: simplexml_load_file(): http://www.domains.co.uk/feed.xml:1: parser error : SYSTEM or PUBLIC, the URI is missing in /home/domain/parse.php on line 2 Warning: simplexml_load_file(): <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/domain/parse.php on line 2 Warning: simplexml_load_file(): ^ in /home/domain/parse.php on line 2 Fatal error: Call to a member function children() on a non-object in /home/domain/parse.php on line 3 I've never done anything like this before and would be so grateful for some help please
  5. I'm trying to get the contents of a few xml files (all on the server) into a couple of different tables of a database but don't know how to do this. Does anybody have any ideas? All of the files are the same format wise and I need to put the details into two different tables. Thanks in advance
  6. I've got a link that is sent using AJAX but no results are being sent. The link is: <a href="javascript:void(0);" data-flavour="Berry" class="nav_link Berry">Berry</a> While the AJAX is: <script type="text/javascript"> $('.nav_link').on('click', function(){ event.preventDefault(); var flavour = $(this).data('flavour');$.get('/filter/?search=' + $(flavour).val(),{flavour:flavour}).done(function(data){ if(!$('#container').hasClass('is-loaded')) { $('#container').addClass('is-loaded'); $('#container').html(data);} else { $('#container').append(data);} }); } );</script> When I get the filter page is says the search value is undefined. If I go directly to the page with what should be sent via AJAX (filter/?search=Berry) then I get all of the relevant results I don't get any errors at all either
  7. I've added this to a site I'm working on but want the card type to be included when the form is submitted but don't know how to update the input value when the card number is entered. At the moment I've got a span class which shows the card image (done using the above example) and then the user has to select their payment method before the form will send. How do I change it so that the type is added to a hidden text field?
  8. Yep coincidence I agree but I can assure you that it's not me, although you're right I used to work for a company in High Road (how did you know that one!!) although I'm no longer in London now
  9. Thanks, I'll give that a go!
  10. Probably a dumb question but how would I do that? Nah that's not me
  11. Sorry I don't understand what you mean?
  12. Essentially what I've got is a page of comments. Only ten of them are loaded. People can click to say if a comment was helpful or not. This works okay but after more comments are loaded (which are being loaded by using the code below) the code to give feedback stops working. All of the comments are being loaded dynamically so I've given the button a class rather than an id. The code to count the feedback in below where all of the comments are but all except the first ten comments are loaded but the user doing something after the page has loaded <script type="text/javascript"> var comments_offset=<?php echo $more ?>; function comments_load() { $.ajax({ url: "/more-comments.php?pid=<?php echo $id ?>&offset="+ comments_offset+"&t="+Math.random(), success: function(data){ if( data.substring( 0,5 )!="failed" ) { bits=data.split( "==DSPLIT==" ); $(bits[1]).insertBefore( "#comments-control" ); comments_offset=bits[0]; if( reviews_offset==0 ) { $("#comments-control").hide(); } } } }); } </script>
  13. I tried to use it like this: <script type="text/javascript">var newElement = $(bits[1]);newElement.click(function() {$(".rate-yes").click(function(e) { // "this" here corresponds to the button that was clicked var self = this; $.ajax({ async: false, type: "POST",url: "rate.php?rate=good&id=" + $(self).val(), data: $(self).serialize(), // self instead of the class success: function(data) { $('#helpful' + $(self).val()).fadeOut("fast", function() { $(this).before("<div class='rate'>Was this comment helpful? <span style='color: #33cc33;'>✓ Thank you for your feedback</span></div>"); }); } });}); $(".rate-no").click(function(e) { // "this" here corresponds to the button that was clicked var self = this; $.ajax({ async: false, type: "POST",url: "rate?rate=bad&id=" + $(self).val(), data: $(self).serialize(), // self instead of the class success: function(data) { $('#helpful' + $(self).val()).fadeOut("fast", function() { $(this).before("<div class='rate'>Was this comment helpful? <span style='color: #33cc33;'>✓ Thank you for your feedback</span></div>"); }); } });});});newElement.insertBefore( "#comments-control" );</script> but then none of it worked. Have I done something wrong?
  14. I'm really sorry but I don't understand what I should do? Should I use .live() or newElements?
  15. I have two pieces of code, one loads more comments and the other sends feedback. Both of the calls use AJAX and work separately but they don't work together. The code I've got is: <script type="text/javascript"> var comments_offset=<?php echo $more ?>; function comments_load() { $.ajax({ url: "/comments.php?pid=<?php echo $id ?>&offset="+comments_offset+"&t="+Math.random(), success: function(data){ if( data.substring( 0,5 )!="failed" ) { bits=data.split( "==DSPLIT==" ); $(bits[1]).insertBefore( "#comments-control" ); comments _offset=bits[0]; if( comments_offset==0 ) { $("#comments-control").hide(); } } } }); } </script> <div id="comments-control" <?php if( !$more ) { ?> style="display: none;"<?php } ?>> <br /><a class="input_button" onclick="reviews_load();" href="javascript:void(0);" style="padding: 10px; height: auto; background-color: #000; border: 1px solid white; color: #fff;">Laod more comments </a> </div> Which loads more comments And this which registers feedback for the comments. It works great for the first ten comments but when I use the other code to load more it then stops working <script type="text/javascript">$(".rate-yes").click(function(e) { // "this" here corresponds to the button that was clicked var self = this; $.ajax({ async: false, type: "POST",url: "/rate.php?rate=good&id=" + $(self).val(), data: $(self).serialize(), // self instead of the class success: function(data) { $('#helpful' + $(self).val()).fadeOut("fast", function() { $(this).before("<div class='rate'>Was this comment helpful? <span style='color: #33cc33;'>✓ Thank you for your feedback</span></div>"); }); } });}); $(".rate-no").click(function(e) { // "this" here corresponds to the button that was clicked var self = this; $.ajax({ async: false, type: "POST",url: "/rate.php?rate=bad&id=" + $(self).val(), data: $(self).serialize(), // self instead of the class success: function(data) { $('#helpful' + $(self).val()).fadeOut("fast", function() { $(this).before("<div class='rate'>Was this comment helpful? <span style='color: #33cc33;'>✓ Thank you for your feedback</span></div>"); }); } });});</script> I've tried to use $(".rate-yes").on("click",function(e) { and $(".rate-no").on("click",function(e) { instead but that doesn't work either
  16. If I don't run the first query then the second one does have a variable (it's actually the same one in both queries). That's why I though it was removing it because it's the same variable. This is the code that produces the error message: usedb( $GLOBALS['country_modules'][$GLOBALS['code']]['db_ex'],"dbExter" );$query="select * from bullets where group_id=".$GLOBALS['group_id'][$key]['id']." and country like "%".$GLOBALS['code']."%" order by pos";$bullets_group=dbselect( $query,"dbExter" ); The $GLOBALS['group_id'][$key]['id'] is the one thats in both queries
  17. I understand the the first query is stopping the second one from getting the values for id and country but what I don't understand is why it' doing that and how to stop it doing it. It also appears that the first query is preventing any following arrays from displaying the results
  18. I've trying to make too queries to different tables in the database but one query causes problems with the other. This query works okay usedb( $GLOBALS['country_modules'][$GLOBALS['code']]['db_ex'],"dbExter" );$query="select id,name from symbols,symbols_map where symbol_id=symbols.id and visible=1 and id=".$GLOBALS['group_id'][$key]['id']." order by name";$symbols_group=dbselect( $query,"dbExter" ); but if I then use this one too: usedb( $GLOBALS['country_modules'][$GLOBALS['code']]['db_ex'],"dbExter" );$query="select * from bullets where group_id=".$GLOBALS['group_id'][$key]['id']." and country like "%".$GLOBALS['code']."%" order by pos";$bullets_group=dbselect( $query,"dbExter" ); then I get this error: select * from bullets where group_id= order by pos (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by pos' at line 1) The second query works on it's own without any errors though.
  19. I tried to do that but it didn't seem to load any of the products. I thought I knew the objects properties but I guess not. Also there's quite a number of tables that hold the details of the products - will this still work?
  20. Sorry to be so dumb but which part would I change? All of it or just the actual function?
  21. I really need some help with this please. I'm trying to display a list of products rather than just one. This is what I'm using to display a group of products. But at the moment it shows one main product then a smaller list of the rest. <?php product_display( $collection[$dynaload]['products'],"More Products:",1 ) ?> If I change it to <?php product_display( $collection[$dynaload]['products'],"More Products:",,0,0,0,1 ) ?> then it shows the remain products in a vertical list Ideally I'd like to be able to display all of the products (or if not then choose how many to display) but I don't know the code well enough to know how to change that. This is the product_display function: function product_display() { # load arguments if( func_num_args()==2 ) { $products_list=func_get_arg(0); $title=func_get_arg(1); $featured=0; $sortable=0; $showall=0; $cols=5; } elseif( func_num_args()==3 ) { $products_list=func_get_arg(0); $title=func_get_arg(1); $featured=func_get_arg(2); $sortable=0; $showall=0; $cols=5; } elseif( func_num_args()==4 ) { $products_list=func_get_arg(0); $title=func_get_arg(1); $featured=func_get_arg(2); $sortable=func_get_arg(3); $showall=0; $cols=5; } elseif( func_num_args()==5 ) { $products_list=func_get_arg(0); $title=func_get_arg(1); $featured=func_get_arg(2); $sortable=func_get_arg(3); $showall=func_get_arg(4); $cols=5; } elseif( func_num_args()==6 ) { $products_list=func_get_arg(0); $title=func_get_arg(1); $featured=func_get_arg(2); $sortable=func_get_arg(3); $showall=func_get_arg(4); $cols=func_get_arg(5); } # initialise $row=1; $ctr=1; # remove old products if( is_array( $products_list ) ) { foreach( $products_list as $key=>$value ) { if( $GLOBALS['products_complete'][$key]['level']==4 ) { unset( $products_list[$key] ); } } } # check and set featured if( $GLOBALS['bit1']=="popular" ) { $featured=0; } if( $featured ) { $found=0; foreach( $products_list as $key=>$value ) { if( !$found ) { $boxed=$key; $boxedr=$GLOBALS['products_complete'][$boxed]['id']; unset( $products_list[$key] ); $found=1; } } # get bullets usedb( $GLOBALS['country_modules'][$GLOBALS['ccode2']]['db_web'],"dbLinkInt" ); $query="select * from product_bullets3 where product_id=".$boxedr." and country like "%".$GLOBALS['ccode2']."%" order by pos"; $product_bullets=dbselect( $query,"dbLinkInt" ); # set first bullet as short title if it is empty if( empty( $GLOBALS['products_complete'][$boxed]['short_title'] ) && !empty( $product_bullets[0]['text'] ) ) { $GLOBALS['products_complete'][$boxed]['short_title']=$product_bullets[0]['text']; unset( $product_bullets[0] ); } # get symbols $query="select name,image from product_symbols,product_symbols_map where symbol_id=product_symbols.id and visible=1 and product_id=".$boxedr." order by name"; $product_symbols=dbselect( $query,"dbLinkInt" ); # featured image if( is_file( $GLOBALS['install_dir']."/images/dynamic/".$GLOBALS['products_complete'][$boxed]['graphics'][10]['filename_image'] ) ) { $img="/images/dynamic/".$GLOBALS['products_complete'][$boxed]['graphics'][10]['filename_image']; } else { $img="/images/site/missing1.jpg"; } # featured box title # echo '<div class="box-head"><span>Best-seller</span></div>'; # featured main box echo '<div style="margin: 0; padding: 0;">'; echo ' details here'; echo '</div>'; echo '<script type="text/javascript">'; echo ' $(".sym").hover( function(){'; echo ' var id=$(this).attr("id").replace( "sym-","ttip-" );'; echo ' $("#"+id).show();'; echo ' },function(){'; echo ' $(".ttip").hide();'; echo ' });'; echo '</script>'; } echo $GLOBALS['html_clear']; # sorting if( $sortable ) { if( $sortable=="alpha_down" ) { if( is_array( $products_list ) ) { $products_list=array_reverse( $products_list,true ); } } elseif( $sortable=="rate_good" ) { if( is_array( $products_list ) ) { foreach( $products_list as $key=>$value ) { $temp[$key]=$GLOBALS['products_complete'][$key]['rating_cnt']+$GLOBALS['products_complete'][$key]['rating_offset']; } asort( $temp ); $products_list=$temp; unset( $temp ); } } elseif( $sortable=="rate_bad" ) { if( is_array( $products_list ) ) { foreach( $products_list as $key=>$value ) { $temp[$key]=$GLOBALS['products_complete'][$key]['rating_cnt']+$GLOBALS['products_complete'][$key]['rating_offset']; } asort( $temp ); $products_list=$temp; unset( $temp ); $products_list=array_reverse( $products_list,true ); } } elseif( $sortable=="price_high" ) { if( is_array( $products_list ) ) { foreach( $products_list as $key=>$value ) { $temp[$key]=$GLOBALS['products_complete'][$key]['price1']; } asort( $temp ); $products_list=$temp; unset( $temp ); } } elseif( $sortable=="price_low" ) { if( is_array( $products_list ) ) { foreach( $products_list as $key=>$value ) { $temp[$key]=$GLOBALS['products_complete'][$key]['price1']; } asort( $temp ); $products_list=$temp; unset( $temp ); $products_list=array_reverse( $products_list,true ); } } } # calculate last row $prods=0; if( is_array( $products_list ) ) { foreach( $products_list as $key=>$value ) { if( !isset( $GLOBALS['products_complete'][$key]['nodisplay'] ) || $showall==1 ) { $prods++; } } $lastrow=ceil( $prods/$cols ); } if( is_array( $products_list ) ) { echo '<div class="products"'; if( $cols==1 ) { echo ' style="padding: 0 12px;"'; } echo '>'; foreach( $products_list as $key=>$value ) { if( !isset( $GLOBALS['products_complete'][$key]['nodisplay'] ) || $showall==1 ) { # start line box if( $ctr==1 ) { echo '<div class="productlist-line"'; if( $row==$lastrow ) { echo ' style="border: 0; margin: 0; padding: 0;"'; } echo '>'; } # product float echo '<div class="rest'; if( $ctr==$cols ) { echo " productlist-last"; } echo'">';echo 'text here'; echo '</div>'; $ctr++; if( $ctr>$cols ) { $ctr=1; $row++; } # end line box if( $ctr==1 ) { echo $GLOBALS['html_clear'].'</div>'; } } } if( $ctr!=1 ) { echo $GLOBALS['html_clear'].'</div>'; } echo '</div>'; } }
  22. Am I wrong the use CURL_CUSTOMREQUEST? I read here that there's two options, delete and post. This is the first time I've used an API and cURL so have probably got it wrong.
  23. I changed the (CURLOPT_GETFIELDS) and (CURLOPT_GET) to curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody); and it now works perfectly!!
×
×
  • Create New...