Search Results

Search found 7418 results on 297 pages for 'argument passing'.

Page 29/297 | < Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >

  • Database class is not correctly connecting to my database.

    - by blerh
    I'm just venturing into the world of OOP so forgive me if this is a n00bish question. This is what I have on index.php: $dbObj = new Database(); $rsObj = new RS($dbObj); This is the Database class: class Database { private $dbHost; private $dbUser; private $dbPasswd; private $dbName; private $sqlCount; function __construct() { $this->dbHost = 'localhost'; $this->dbUser = 'root'; $this->dbPasswd = ''; $this->dbName = 'whatever'; $this->sqlCount = 0; } function connect() { $this->link = mysql_connect($this->db_host, $this->db_user, $this->db_passwd); if(!$this->link) $this->error(mysql_error()); $this->selection = mysql_select_db($this->db_name, $this->link); if(!$this->selection) $this->error(mysql_error()); } } I've shortened it to just the connect() method to simplify things. This is the RS class: class RS { private $username; private $password; function __construct($dbObj) { // We need to get an account from the db $dbObj->connect(); } } As you can probably see, I need to access and use the database class in my RS class. But I get this error when I load the page: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\includes\database.class.php on line 22 The thing is I have NO idea where it got the idea that it needs to use ODBC as a user... I've read up on doing this stuff and from what I can gather I am doing it correctly. Could anyone lend me a hand? Thank you.

    Read the article

  • Python parsing error message functions

    - by user1716168
    The code below was created by me with the help of many SO veterans: The code takes an entered math expression and splits it into operators and operands for later use. I have created two functions, the parsing function that splits, and the error function. I am having problems with the error function because it won't display my error messages and I feel the function is being ignored when the code runs. An error should print if an expression such as this is entered: 3//3+4,etc. where there are two operators together, or there are more than two operators in the expression overall, but the error messages dont print. My code is below: def errors(): numExtrapolation,opExtrapolation=parse(expression) if (len(numExtrapolation) == 3) and (len(opExtrapolation) !=2): print("Bad1") if (len(numExtrapolation) ==2) and (len(opExtrapolation) !=1): print("Bad2") def parse(expression): operators= set("*/+-") opExtrapolate= [] numExtrapolate= [] buff=[] for i in expression: if i in operators: numExtrapolate.append(''.join(buff)) buff= [] opExtrapolate.append(i) opExtrapolation=opExtrapolate else: buff.append(i) numExtrapolate.append(''.join(buff)) numExtrapolation=numExtrapolate #just some debugging print statements print(numExtrapolation) print("z:", len(opExtrapolation)) return numExtrapolation, opExtrapolation errors() Any help would be appreciated. Please don't introduce new code that is any more advanced than the code already here. I am looking for a solution to my problem... not large new code segments. Thanks.

    Read the article

  • Method params match signature, but still getting error

    - by Jason
    I am in the midst of converting a VB library to C#. One of my methods has the following signature in VB: Private Shared Sub FillOrder(ByVal row As DataRowView, ByRef o As Order) In C# I converted it to: private static void FillOrder(DataRowView row, ref Order o) From my constructor inside my Order class, I am calling the FillOrder() method like so: DataView dv = //[get the data] if (dv.Count > 0) { FillOrder(dv[0], this); } In VB, this works: Dim dv As DataView = '[get data]' If dv.Count > 0 Then FillOrder(dv.Item(0), Me) End If However, in VS10 in the C# file I am getting a red squiggle under this call with the following error: The best overloaded method match for [the method] has some invalid arguments This was working code in VB. What am I doing wrong?

    Read the article

  • Parameter becoming zero somewhere

    - by Nick
    Hey guys, Something really weird is happening: when I call foo(100*1.0f), somewhere along the line that becomes 0. To verify I put a breakpoint on foo(), and it indeed is zero and it indeed gets called with 100*1.0f. The code is in Obj-C++. Here is the calling function in XCode's GDB frontend, as you can see, score*scoreMultiplier is 100. And here is the called function in XCode's GDB frontend, here _score is 0.

    Read the article

  • How to pass parameters for OPENDATASOURCE

    - by Rapunzo
    I can connect to a linked server with this: SELECT testNo, soruTuruId, soruNo, cevap , degerlendirenTcNo, degerlendirilenTcNo FROM OPENDATASOURCE('SQLOLEDB', 'Data Source=192.168.150.42;User ID=readerUser;Password=1').akreditasyon.dbo.tblPerfCevap But I have to pass the password as parameter. and I try like this: SET @connectionString = 'Data Source=192.168.150.42;User ID=readerUser;Password='+@pw SELECT testNo, soruTuruId, soruNo, cevap , degerlendirenTcNo, degerlendirilenTcNo FROM OPENDATASOURCE('SQLOLEDB', @connectionString ).akreditasyon.dbo.tblPerfCevap and SELECT testNo, soruTuruId, soruNo, cevap , degerlendirenTcNo, degerlendirilenTcNo FROM OPENDATASOURCE('SQLOLEDB', 'Data Source=192.168.150.42;User ID=readerUser;Password='+@pw ).akreditasyon.dbo.tblPerfCevap but didnt work:S does anyone have an idea?

    Read the article

  • Return Integer value from SSIS execute SQL Task

    - by Bokhari
    I am using SQL Server 2005 Business Intelligence Studio and struggling with returning an integer value from a very simple execute SQL Task. For a very simple test, I wrote the SQL Statement as: Select 35 As 'TotalRecords' Then, I specified ResultSet as ResultName = TotalRecords and VariableName = User::TotalRecords When I execute this, the statement is executed but the variable doesn't have the updated value. However, it has the default value that I specified while variable definition. The return of a date variable works, but integer variable isn't working. The type of User::TotalRecords specified is Int32 in a package scope. Thanks for any hints

    Read the article

  • Advice on Minimizing Stored Procedure Parameters

    - by RPM1984
    Hi Guys, I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008 database via Entity Framework 4.0. On a particular page, i call a stored procedure in order to pull back some results based on selections on the UI. Now, the UI has around 20 different input selections, ranging from a textbox, dropdown list, checkboxes, etc. Each of those inputs are "grouped" into logical sections. Example: Search box : "Foo" Checkbox A1: ticked, Checkbox A2: unticked Dropdown A: option 3 selected Checkbox B1: ticked, Checkbox B2: ticked, Checkbox B3: unticked So i need to call the SPROC like this: exec SearchPage_FindResults @SearchQuery = 'Foo', @IncludeA1 = 1, @IncludeA2 = 0, @DropDownSelection = 3, @IncludeB1 = 1, @IncludeB2 = 1, @IncludeB3 = 0 The UI is not too important to this question - just wanted to give some perspective. Essentially, i'm pulling back results for a search query, filtering these results based on a bunch of (optional) selections a user can filter on. Now, My questions/queries: What's the best way to pass these parameters to the stored procedure? Are there any tricks/new ways (e.g SQL Server 2008) to do this? Special "table" parameters/arrays - can we pass through User-Defined-Types? Keep in mind im using Entity Framework 4.0 - but could always use classic ADO.NET for this if required. What about XML? What are the serialization/de-serialization costs here? Is it worth it? How about a parameter for each logical section? Comma-seperated perhaps? Just thinking out loud. This page is particulary important from a user point of view, and needs to perform really well. The stored procedure is already heavy in logic, so i want to minimize the performance implications - so keep that in mind. With that said - what is the best approach here?

    Read the article

  • C++: How do I pass a function(without knowing its parameters) to another function?

    - by Ninja
    Hi all. I'm trying to create a function that will store and repeat another function given as a parameter for a specific amount of time or repeats given. But when you want to pass a function as a parameter you have to know all of its parameters before hand. How would I do if I wanted to pass the function as one parameter, and the parameters as another? void AddTimer(float time, int repeats, void (*func), params); // I know params has no type and that (*func) is missing parameters but it is just to show you what I mean Thanks in advance

    Read the article

  • Javascript function programming — receiving elaborate parameters

    - by Barney
    I'm writing a Javascript function that would manipulate an array written on-the-fly and sent as a parameter. The function is written as follows: function returnJourney(animation,clean){ var properties = {}; // loads of other inane stuff for(i in animation[0]) properties[animation[0][i]] = animation[0].i; // heaps more inane stuff } The animation in question is a set of parameters for a jQuery animation. Typically it takes the format of ({key:value,key:value},speedAsInteger,modifierAsString). So to kick off initial debugging I call it with: returnJouney(({'foo':'bar'},3000),1); And straight off the bat things are way off. As far as I see it this would have returnJourney acknowledge clean === 1, and animation being an array with an object as its first child and the number 3000 as its second. Firebug tells me animation evaluates as the number 3000. What am I doing wrong?

    Read the article

  • Adding an keyUp-event to form objects

    - by reporter
    Hello folks, I've got the issue to add a browser event to some input fields. The challenge I have to face is, that one parameter of my target function is the 'event'-variable and the second one an object. For a better understanding here some codes:The HTML object: <div id="1_dateFieldAdvanced" class="xp set"> <div id="1_dateFieldAdvanced_label" class="label">Birthday</div> <div id="1_dateFieldAdvanced_value" class="value date"> <input class="day" name="dayOfBirth" value="66" maxlength="2" type="text"> <input class="month" name="monthOfBirth" value="67" maxlength="2" type="text"> <input class="year" name="yearOfBirth" value="" maxlength="4" type="text"> </div> </div> The source code of target method is like below: function advancedDateFields(currentFieldAsObject, nextField, currentValueLength, ev){} Unfortunatly the HTML and the Javascript code is generated automatically, so I'm unable to refactore the code. My question is, how can I pass the key word 'event' and the other parameters? My tries did always fail. :-(

    Read the article

  • C++ vector reference parameter

    - by Archanimus
    Hello folks, let's say we have a class class MyClass { vector<vector<int > > myMatrice; public : MyClass(vector<vector<int > > &); } MyClass::MyClass(vector<vector<int > > & m) { myMatrice = m; } During the instanciation of MyClass, I pass a big vector < vector < int and I find that the object is actually copied and not only the reference, so it takes the double of the memory ... Please, can anyone help me out with this problem, I'm stuck since too many time ... And thanks a lot!

    Read the article

  • How to Pass complex objects in ASP.NET MVC using Get parameters?

    - by VJ
    I am wanting to pass something like the following to my view from my controller via GET not POST: public class MyDTO { public string val1 { get; set; } public string val2 { get; set; } public MyObject obj { get; set; } } public class MyObject { public int SomeInt { get; set; } public string ACoolValue { get; set; } public string YetAnotherCoolValue { get; set; } } And then the controller would like like this. (Note it is a GET): public ActionResult MyView(MyDTO dto) { return View(dto) } The problem is that the instance of MyObject is coming back as null, where val1 and val2 have data. Has anyone run across this?

    Read the article

  • Assigning a 2D array (of pointers) to a variable in an object for access in C++?

    - by MrMormon
    I'm sorry if I didn't pick a descriptive or concise name. A lot of questions sound similar, but I haven't been able to find what I'm looking for. What I want to do is store a 2D array of pointers somewhere and assign a variable in some object to that array to be able to access it. Here's some example code that has the same compile error I'm getting with a bigger project. #include <iostream> using namespace std; struct X{ float * b[8][8]; X(){ *(b[1][5]) = 1; cout << *(b[1][5]) << endl; } void Set(float * c[8][8]){ b = c; cout << *(b[1][5]) << endl; } }; main(){ float * a[8][8]; *(a[1][5]) = 2; X obj; obj.Set(a); } What I want to happen in this code is that an X object starts with its own 2D array, whose value pointed to by b[1][5] should be printed as "1". Then the main method's 2D array, a, is passed to the object's Set() method and assigned to its array variable. The value pointed to by b[1][5] should then be printed as "2". However, I can't figure out what type the Set() parameter, c, should be. I get error: incompatible types in assignment of ‘float* (*)[8]’ to ‘float* [8][8]’ when I try to compile. As for why I want to do this, I'm trying to use an array of pointers to objects, not floats, but it's the same error.

    Read the article

  • Changing Value of Array Pointer When Passed to a Function

    - by ZAX
    I have a function which receives both the array, and a specific instance of the array. I try to change the specific instance of the array by accessing one of its members "color", but it does not actually change it, as can be seen by debugging (checking the value of color after function runs in the main program). I am hoping someone can help me to access this member and change it. Essentially I need the instance of the array I'm specifying to be passed by reference if nothing else, but I'm hoping there is an easier way to accomplish what I'm trying to do. Here's the structures: typedef struct adjEdge{ int vertex; struct adjEdge *next; } adjEdge; typedef struct vertex{ int sink; int source; int color; //0 will be white, 1 will be grey, 5 will be black int number; adjEdge *nextVertex; } vertex; And here is the function: void walk(vertex *vertexArray, vertex v, int source, maxPairing *head) { int i; adjEdge *traverse; int moveVertex; int sink; traverse = vertexArray[v.number-1].nextVertex; if(v.color != 5 && v.sink == 5) { sink = v.number; v.color = 5; addMaxPair(head, source, sink); } else { walk(vertexArray, vertexArray[traverse->vertex-1], source, head); } } In particular, v.color needs to be changed to a 5, that way later after recursion the if condition blocks it.

    Read the article

  • fortran 90 user defined type, passing by value ?

    - by user279137
    I have an issue in fortran 90. I have a user defined type and when I call one of the MPI subroutines the data looks to be passed by values (not address, as I thought it should). The output arguments aren't modified. It seems to be specific to the MPI calls I tried the same thing in a simple test, and I can change the passed in values in the calling scope. I'm not sure why this is because I thought fortran always pass by address. Any idea what could be going on? Just to be clear the commented snippet shows how the calls are made. The in the first call, c%NSubDomains, is an output argument and should be modified in the calling scope, but its not. WHen I call with an array rather than a member of user defined type it works, in the uncommented snippet. ! ! This doesn't work output values aren't modified ?? ! call MPI_Dims_create(c%NProcs,c%NDims,c%NSubDomains,iErr) nsubs(:)=0 call MPI_Dims_create(c%NProcs,c%NDims,nsubs,iErr) c%NSubDomains=nsubs Thanks

    Read the article

  • passing timezone from client (GWT) to server (Joda Time)

    - by Caffeine Coma
    I'm using GWT on the client (browser) and Joda Time on the server. I'd like to perform some DB lookups bounded by the day (i.e. 00:00:00 until 23:59:59) that a request comes in, with the time boundaries based on the user's (i.e. browser) timezone. So I have the GWT code do a new java.util.Date() to get the time of the request, and send that to the server. Then I use Joda Time like so: new DateTime(clientDate).toDateMidnight().toDateTime() The trouble of course is that toDateMidnight(), in the absence of a specified TimeZone, will use the system's (i.e. the server's) TimeZone. I've been trying to find a simple way to pass the TimeZone from the browser to the server without much luck. In GWT I can get the GMT offset with: DateTimeFormat.getFormat("Z").fmt(new Date()) which results in something like "-0400". But Joda Time's DateTimeZone.forID() wants strings formatted like "America/New_York", or an integer argument of hours and minutes. Of course I can parse "-0400" into -4 hours and 0 minutes, but I'm wondering if there is not a more straightforward way of doing this.

    Read the article

  • Help passing reference to class subroutine in Perl.

    - by stephenmm
    I am trying to pass a routine to another subroutine within a Perl module. But when I pass the sub reference the passed in ref no longer has the object data. Maybe its not possible to do it this way. The line I have a question about is the "unless" lines below: sub get_flag_end { my $self = shift; return ( -e "$self->{file}" ); } sub wait_for_end { my $self = shift; my $timeout = shift; my $poll_interval = shift; # Is it even possible to pass the oject subroutine and retain the objects data? #unless ( $self->timeout( $timeout, $poll_interval, $self->get_flag_end ) ) { # does not work unless ( $self->timeout( $timeout, $poll_interval, \&get_flag_end ) ) { # call happens but members are empty die "!!!ERROR!!! Timed out while waiting for wait_for_end: timeout=$timeout, poll_interval=$poll_interval \n"; } } sub timeout { my $self = shift; my $timeout = shift; my $poll_interval = shift; my $test_condition = shift; until ($test_condition->() || $timeout <= 0) { $timeout -= $poll_interval; sleep $poll_interval; } return $timeout > 0; # condition was met before timeout } I know that I could change the "get_flag_end" routine to take the value as an argument to the subroutine but what if there was a bunch of stuff done in "get_flag_end" and I needed more members from the object. I simplified the code a bit to make it a little easier to follow.

    Read the article

  • Passing options in autospec with Cucumber in Ruby on Rails Development

    - by TK
    I always run autospec to run features and RSpec at the same time, but running all the features is often time-consuming on my local computer. I would run every feature before committing code. I would like to pass the argument in autospec command. autospec doesn't obviously doesn't accept the arguments directly. Here's the output of autospec -h: autotest [options] options: -h -help You're looking at it. -v Be verbose. Prints files that autotest doesn't know how to map to tests. -q Be more quiet. -f Fast start. Doesn't initially run tests at start. I do have a cucumber.yml in config directory. I also have rerun.txt in the Rails root directory. cucumber -h gives me a lot of information about arguments. How can I run autospec against features that are tagged as @wip? I think I can make use of config/cucumber.yml. There are profile definitions. I can run cucumber -p wip to run only @wip-tagged features, but I'd like to do this with autospec. I would appreciate any tips for working with many spec and feature files.

    Read the article

  • Passing IDisposable objects through constructor chains

    - by Matt Enright
    I've got a small hierarchy of objects that in general gets constructed from data in a Stream, but for some particular subclasses, can be synthesized from a simpler argument list. In chaining the constructors from the subclasses, I'm running into an issue with ensuring the disposal of the synthesized stream that the base class constructor needs. Its not escaped me that the use of IDisposable objects this way is possibly just dirty pool (plz advise?) for reasons I've not considered, but, this issue aside, it seems fairly straightforward (and good encapsulation). Codes: abstract class Node { protected Node (Stream raw) { // calculate/generate some base class properties } } class FilesystemNode : Node { public FilesystemNode (FileStream fs) : base (fs) { // all good here; disposing of fs not our responsibility } } class CompositeNode : Node { public CompositeNode (IEnumerable some_stuff) : base (GenerateRaw (some_stuff)) { // rogue stream from GenerateRaw now loose in the wild! } static Stream GenerateRaw (IEnumerable some_stuff) { var content = new MemoryStream (); // molest elements of some_stuff into proper format, write to stream content.Seek (0, SeekOrigin.Begin); return content; } } I realize that not disposing of a MemoryStream is not exactly a world-stopping case of bad CLR citizenship, but it still gives me the heebie-jeebies (not to mention that I may not always be using a MemoryStream for other subtypes). It's not in scope, so I can't explicitly Dispose () it later in the constructor, and adding a using statement in GenerateRaw () is self-defeating since I need the stream returned. Is there a better way to do this? Preemptive strikes: yes, the properties calculated in the Node constructor should be part of the base class, and should not be calculated by (or accessible in) the subclasses I won't require that a stream be passed into CompositeNode (its format should be irrelevant to the caller) The previous iteration had the value calculation in the base class as a separate protected method, which I then just called at the end of each subtype constructor, moved the body of GenerateRaw () into a using statement in the body of the CompositeNode constructor. But the repetition of requiring that call for each constructor and not being able to guarantee that it be run for every subtype ever (a Node is not a Node, semantically, without these properties initialized) gave me heebie-jeebies far worse than the (potential) resource leak here does.

    Read the article

  • Passing arguments and values from HTML to jQuery (events)

    - by Jaroslav Moravec
    What is the practice to pass arguments from HTML to jQuery events function. For example getting id of row from db: <tr class="jq_killMe" id="thisItemId-id"> ... </tr> and jQuery: $(".jq_killMe").click(function () { var tmp = $(this).attr('id).split("-"); var id = tmp[0] // ... } What's the best practise, if I want to pass more than one argument? Is it better not to use jQuery? For example: <tr onclick="killMe('id')"> ... </tr> I didn't find the answer on my question, I will be glad even for links. Thanks. Edit (pre solution) So you suggested two methods to do that: Add custom attributes to element (XHTML) Use attribute ID and parse it by regex Attribute data-* attributes in HTML5 Use hidden children elements I like first solution, but... I would like to (I have to (employer)) produce valid code. Here is a nice question and answers: http://stackoverflow.com/questions/994856/so-what-if-custom-html-attributes-arent-valid-xhtml And the second is not so pretty as the first, but valid. So the compromise is... The third is the solution for future, but here is a lot of CMS where we have to use XHTML or HTML4. (And HTML5 is the long process)

    Read the article

  • Passing optional parameter by reference in c++

    - by Moomin
    I'm having a problem with optional function parameter in C++ What I'm trying to do is to write function with optional parameter which is passed by reference, so that I can use it in two ways (1) and (2), but on (2) I don't really care what is the value of mFoobar. I've tried such a code: void foo(double &bar, double &foobar = NULL) { bar = 100; foobar = 150; } int main() { double mBar(0),mFoobar(0); foo(mBar,mFoobar); // (1) cout << mBar << mFoobar; mBar = 0; mFoobar = 0; foo(mBar); // (2) cout << mBar << mFoobar; return 0; } but it crashes at void foo(double &bar, double &foobar = NULL) with message : error: default argument for 'double& foobar' has type 'int' Is it possible to solve it without function overloading? Thanks in advance for any suggestions. Pawel

    Read the article

  • Passing in extra parameters in a URL

    - by Scott Atkinson
    I have the below column on my table what gets binded on pageload, the parameters in there work fine but i need to add an additional parameter which is the fullname which is the next column along but im having trouble figuring our the syntax, here is my ASP <asp:TemplateField HeaderText="ID"> <ItemTemplate> <asp:HyperLink ID="hyperLeadID" runat="server" NavigateUrl='<%#Eval("ID","/documents/Q-Sheet.aspx?LeadID={0}&isHappyCallReferral=yes&isHappyName={1}") %>' Text='<%#Eval("ID")%>'></asp:HyperLink> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Referral Name"> <ItemTemplate> <asp:Label ID="lblRefName" CssClass="gvItem" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Name") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> As you can see at the end of ID column i have added isHappyName={1} which i assumed it would select the next column along as it starts at 0 but it keeps throwing an error which is "Index (zero based) must be greater than or equal to zero and less than the size of the argument list." Can someone help me to pass the usersname through the URL Thanks

    Read the article

  • Passing.getText() String to another class

    - by DanMc
    I'm currently working on a first year university project and I have a problem, although I doubt it's a very complicated one, but I've been searching and I just can't find a suitable answer to it. The problem concerns two classes. A gui class (class1) and another class (class2). I have a JTextField in class1 and am trying to pass through the .getText() value to class2 and store it in a String type variable. The current code I'm trying to achieve this with is the following: (Class1) private JTextField textField = new JTextField("Something"); ... public String getTextFieldString() { return textField.getText(); } (Class2) private c1 Class1 = new Class1(); private String s = new String(); ... s = c1.getTextFieldString(); I'm pretty new to coding, I've read that maybe I need to pass through an argument somewhere and I assume that's because textField is not static in itself, it changes when somebody enters a new value. (sorry for stating the obvious there.) Anyway, help is appreciated. Thanks a lot!

    Read the article

< Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >