Search Results

Search found 122 results on 5 pages for 'rohan prabhu'.

Page 3/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • How to convert a PHP object to a string?

    - by Rohan
    I get this error: Catchable fatal error: Object of class stdClass could not be converted to string So, my question is, how do I convert an object to a string in PHP? I don't want to serialize it though. Just a note: the code I use works in PHP 4, but not in PHP 5 Thanks!

    Read the article

  • PHP arrays & keys - fetching particular ones

    - by Rohan
    Hi Lets say I have an array with a structure like this: $arr= Array( array( "id"=>"a" "type">"apple"), array( "id"=>"b"), array( "id"=>"c"), array( "id"=>"c" "type"=>"banana") ); now I want to have a foreach loop which fetches all the array elements which have a key in them named "type". Something like foreach(all arrays which have type in them as $item) How would I do that? many thanks.

    Read the article

  • Replacing innertext of XML node using PHP DOMDocument

    - by Rohan Kumar
    I want to replace innertext of a XML node my XML file named test.xml is <?xml version="1.0" encoding="utf-8"?> <ads> <loop>no</loop> <item> <description>Description 1</description> </item> <item> <description>Text in item2</description> </item> <item> <description>Let play with this XML</description> </item> </ads> I want to change the value of loop and description tag both, and it should be saved in test.xml like: <?xml version="1.0" encoding="utf-8"?> <ads> <loop>yes</loop> <item> <description>Description Changing Here</description> </item> <item> <description>Changing text in item2</description> </item> <item> <description>We will play later</description> </item> </ads> I tried code in PHP: <? $file = "test.xml"; $fp = fopen($file, "rb") or die("cannot open file"); $str = fread($fp, filesize($file)); $dom=new DOMDocument(); $dom->formatOutput = true; $dom->preserveWhiteSpace = false; $dom->loadXML($str) or die("Error"); //$dom->load("items.xml"); $root=$dom->documentElement; // This can differ (I am not sure, it can be only documentElement or documentElement->firstChild or only firstChild) $loop=$root->getElementsByTagName('loop')->item(0);//->textContent; //echo $loop; if(trim($loop->textContent)=='no') { echo 'ok'; $root->getElementsByTagName('loop')->item(0)->nodeValue ='yes'; } echo "<xmp>NEW:\n". $dom->saveXML() ."</xmp>"; ?> I tried only for loop tag.I don't know how to replace nodevalue in description tag. When I run this page it shows output like: ok NEW: <?xml version="1.0" encoding="utf-8"?> <ads> <loop>yes</loop> <item> <description>Description 1</description> </item> <item> <description>Changing text in item2</description> </item> <item> <description>Let play with this XML</description> </item> </ads> It gives the value yes in browser but don't save it in test.xml any reason?

    Read the article

  • A pointer member variable having different values

    - by Rohan Prabhu
    Ok, to begin with, this is my code: HyperSprite::HyperSprite() { _view = 0; } void HyperSprite::publish(QGraphicsView* view) { _view = view; } void HyperSprite::getKFrame() { if(_view != 0) { qDebug()<<(void*)_view; } } Now, if I call HyperSprite::getKFrame() from within main(), I get the output: 0xbf8ffb84 I have a TCP server, which requires this QGraphicsView* variable. So whenever a new connection is made, HyperSprite::getKFrame() is called. However, whenever I make a connection to my server, this is the output: 0x1e425ff I honestly don't understand this. Shouldn't the value of a member remain same throughout? Why is the pointer value changing? As is obvious, whenever I try to use the _view pointer to access any of its members, a Segmentation Fault occurs. I tried using QSharedPointer, but it also results in the same problem. The data of the QSharedPointer automatically changes. Why is this happening?

    Read the article

  • Solution for Numeric Text Field in GWT

    - by Ashwin Prabhu
    I need a text field very similar in behavior to Gxt's NumberField. Unfortunately I am not using Gxt in my application and GWT 2.0 does not have a Numeric text field implementation as yet. So that currently leaves me with an option to simulate a NumberField by filtering out non-numeric keystrokes using a keyboardHandler. Is this the the best way to approach the problem? Does anyone here have a better solution/approach in mind? Thanks in advance :)

    Read the article

  • Can you handle both json and html datatypes in the same ajax call?

    - by Prabhu
    Is there anyway I can handle both json and html return types when posting jquery ajax: For example, this ajax call expects html back $.ajax({ type: "POST", url: url data: data, dataType: "html", success: function (response) { var $html = "<li class='list-item'>" + response + "</li>"; $('#a').prepend($html); }, error: function (xhr, status, error) { alert(xhr.statusText); } }); but I wanted to modify it so that I can return a json object if there is a model error. so I can do something like this: success: function (response) { if (response.Error){ alert(response.Message); } else { var $html = "<li class='list-item'>" + response + "</li>"; $('#a').prepend($html); } Is this possible?

    Read the article

  • BoundsChecker shows incorrect memory leak message

    - by Prabhu
    Hello All, I'm using BoundsChecker9.1 with visual c++. I have a class class Sample{ public: vector(AnotherClass) x; }. When I run my program the BoundsChecker tool reports all push_back() calls such as S.x.push_back(AnotherClass()) as memory leak.. Wouldn't all the elements in vector x will always be deallocated when the Sample class goes out of scope? If so, any idea about why BoundsChecker is showing them as memory leak?

    Read the article

  • E-commerce application how is this robustness criteria implemented?

    - by Akshar Prabhu Desai
    Consider the following use case 1. User selects a product to purchase on seller's site 2. Clicks on net-banking option and redirected to his bank website 3. Successfully makes the payment. 4. But before the payment gateway redirects him back to seller site the browser crashes. 5. Seller site reports that payment is not recived but the bank reports that payment has been made. What are the best practices to handle such cases?

    Read the article

  • How do I assign custom classes to YUI3 plugin/widget objects

    - by Akshar Prabhu Desai
    Consider the following code. var overlay = new Y.Overlay({ id:'tooltip-tag', bodyContent:"Loading.....", xy:[e.target.getX(),e.target.getY()+30] }); The overlay gets the id as given in attributes. But what if I want to add a class ? IS there something like: var overlay = new Y.Overlay({ **class:'tooltip-tag'**, bodyContent:"Loading.....", xy:[e.target.getX(),e.target.getY()+30] });

    Read the article

  • Stack allocation fails and heap allocation succeeds!! Is it possible??

    - by Prabhu
    Hello All, I have the following piece of snippet Class Sample { Obj_Class1 o1; Obj_Class2 o2;}; But the size of Obj_Class1 and Obj_Class2 is huge so that the compiler shows a warning "Consider moving some space to heap". I was asked to replace Obj_Class1 o1 with Obj_Class1* o1 = new Obj_Class1(); But I feel that there is no use of making this change as heap allocation will also fail if stack allocation fails. Am I correct? Or does it make sense to make this change ( other than suppressing the compiler warning ).

    Read the article

  • Best way to check for NULL value in MySql query

    - by PHP-Prabhu
    Can any one please let me know the best way to use IF statement in mysql query to show if the "email" field is NULL then it should show as "no email"... Postcode Telephone Email ---------------------------------------------------------- BS20 0QN 1275373088 no email BS20 0QN 1275373088 no email PO9 4HG 023 92474208 [email protected] SO43 7DS 07801 715200 [email protected] ----------------------------------------------------------

    Read the article

  • INI file reverse engineering

    - by Akshar Prabhu Desai
    I am maintaining a legacy application which prints product labels on packaging. The format of the label is stored in a INI file. I wanted to know if anyone has any hints about the meaning of this format. I have pasted a snippet here. {D1531,1000,1501|} {C|} {U2;0130|} {D1531,1000,1501|} {AX;+000,+000,+00|} {AY;+05,0|} {PC000;0922,0555,15,15,H,11,B|} {RC00;<FE/>LABELTITLE</FE>|} {PC001;0865,0555,15,15,H,11,B|} {RC01;<FE/>CURRENT</FE>|} {PC002;0796,0040,10,10,H,11,B|}

    Read the article

  • How do virtual destructors work?

    - by Prabhu
    Few hours back I was fiddling with a Memory Leak issue and it turned out that I really got some basic stuff about virtual destructors wrong! Let me put explain my class design. class Base { virtual push_elements() {} }; class Derived:public Base { vector<int> x; public: void push_elements(){ for(int i=0;i <5;i++) x.push_back(i); } }; void main() { Base* b = new Derived(); b->push_elements(); delete b; } The bounds checker tool reported a memory leak in the derived class vector. And I figured out that the destructor is not virtual and the derived class destructor is not called. And it surprisingly got fixed when I made the destructor virtual. Isn't the vector deallocated automatically even if the derived class destructor is not called? Is that a quirk in BoundsChecker tool or is my understanding of virtual destructor wrong?

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >