How do I convert the value of a PHP variable to string? I was looking for something better than concatenating with an empty string:
$myText = $myVar . '';
like the ToString() method in Java or .NET.
how pass a parameter to onload function??
<body onLoad="myFunction(<%=myVar%>)">
It crashes.
The parameter is a vb variable defined with Dim
The function is a vbscript function
Urgent HELP
Hello!
I want to enable debug (DEBUG = True) For my Django project only if it runs on localhost. How can I get user IP address inside settings.py? I would like something like this to work:
#Debugging only on localhost
if user_ip = '127.0.0.1':
DEBUG = True
else:
DEBUG = False
How do I put user IP address in user_ip variable inside settings.py file?
Lets say I have a variable that will always be a string.
Now take the code below:
if($myVar === "teststring")
Note $myVar will always be a string, so my questions is
Which is quicker/best, using === (Indentity) or the == (Equality)?
Hi,
I have one abstract class -let's say myBase. And I want all the classes derived from myBase to have one static field called
public static List<string> MyPArameterNames
{
get {return _myParameterNames;}
}
So, every child class can tell what parameter names it uses; I want static because I do not want to create an instance just for this.
How can I achieve this?
We have server on Python and client + web service on Ruby. That works only if file from URL is less than 800 k. It seems like "socket.puts data" in a client works, but "output = socket.gets" - not. I think problem is in a Python part. For big files tests run "Connection reset by peer". Is it buffer size variable by default somewhere in a Python?
My string looks like:
$fullPath = $dirName . "/" . $file;
If I replace / with \, it gives error: "Expecting identifier or variable". I want to store in the latter way itself. How to override anything coming in between?
I want to generate a bat file for multiple tag processing and the command lines look like this:
"C:\Program Files (x86)\tools\tag.exe" -t Genre="%genre%" "%_folderpath%\%track%. %title%.%_extension%"
IF ERRORLEVEL==1 PAUSE
I can populate all variables automatically but can I replace the %title% variable with a wildcard?
Could anyone help me please in JQuery?
I have two tables on my site leftTable and rightTable with same column names. The leftTable I fill up from a DB, but the rightTable it just contains some rows. What I would like to do is to not show (or remove) in the leftTable those rows which are exist in the rightTable!
I Tryed this:
$("#tableLeft tr").each(function ()
{if ($(this).find("td")[0].innerHTML == $("#tableRight tr").find("td")[0].innerHTML) {$(this).remove;}});
Hi all, how to read unlimited characters in to a char* variable without specifying the size. For ex: I want to read the address of an employee it may take multilines also. Thanks in advance.
Hey,
I want to use a method of an object.
Like $myObject->helloWorld().
However there are a couple of methods so I loop through an array of method names and call the method like this:
my $methodName ="helloWorld";
$myObject->$methodNames;
This works quite nice but some objects don't have all methods.
How can I tell wether $myObject has a method called helloWorld or not?
Let's say I have a custom AddMethod to jQuery Validate like:
$.validator.addMethod('min-length', function (val, element) {
// do stuff
// the error message here needs to be dynamic
}, 'The field cannot be less than than '
+ element.attr('data-min') + // it is within the closure, but it can't grab it
' length.');
I can't figure out a way to get the element variable in question, and get any values from it. What am I missing here?
I have a Perl script to open this page http://svejo.net/popular/all/new/ and filter the names of the posts but except headers everything seems encrypted. Nothing can be read. When I open the same page in a browser everything looks fine including the source code. How is it possible to encrypt a page for a script and not for a browser? My Perl script sends the same headers as my browser (Google Chrome).
I'm looking for a bash function that will shorten long path names to keep my PS1 variable from getting excessively long. Something along the lines of:
/this/is/the/path/to/a/really/long/directory/i/would/like/shortened
might end up as:
/t../i../t../p../to/a/r../l../d../i/w../like/shortened
something that the took the path and a maximum acceptable number of characters to shorten to would be perfect for my .bashrc file.
Hi,
I have the DataTable with following columns:
id, Name, Description, ParentId
and would like to create a WPF control (.NET 4.0 framework) which implements a combobox which displays the names which are bound to values of id. So when the user selects a name displayed in the combobox the behind logic has to retrieve its id value.
I would be very thankful if anyone could show the way of doing the described above.
What happens to state information held by a class's variable after coming back from a low memory situation?
I know that views will get unloaded and then reloaded later but what about some ancillary classes & data held in them that's used by the controller that launched the view?
Sample scenario in question:
@interface MyCustomController: UIViewController
{
ServiceAuthenticator *authenticator;
}
-(id)initWithAuthenticator:(ServiceAuthenticator *)auth;
// the user may press a button that will cause the authenticator
// to post some data to the service.
-(IBAction)doStuffButtonPressed:(id)sender;
@end
@interface ServiceAuthenticator
{
BOOL hasValidCredentials; // YES if user's credentials have been validated
NSString *username;
NSString *password; // password is not stored in plain text
}
-(id)initWithUserCredentials:(NSString *)username password:(NSString *)aPassword;
-(void)postData:(NSString *)data;
@end
The app delegate creates the ServiceAuthenticator class with some user data (read from plist file) and the class logs the user with the remote service.
inside MyAppDelegate's applicationDidFinishLaunching:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
ServiceAuthenticator *auth = [[ServiceAuthenticator alloc] initWithUserCredentials:username password:userPassword];
MyCustomController *controller = [[MyCustomController alloc] initWithNibName:...];
controller.authenticator = auth;
// Configure and show the window
[window addSubview:..];
// make everything visible
[window makeKeyAndVisible];
}
Then whenever the user presses a certain button, 'MyCustomController's doStuffButtonPressed' is invoked.
-(IBAction)doStuffButtonPressed:(id)sender
{
[authenticator postData:someDataFromSender];
}
The authenticator in-turn checks to if the user is logged in (BOOL variable indicates login state) and if so, exchanges data with the remote service. The ServiceAuthenticator is the kind of class that validates the user's credentials only once and all subsequent calls to the object will be to postData.
Once a low memory scenario occurs and the associated nib & MyCustomController will get unloaded -- when it's reloaded, what's the process for resetting up the 'ServiceAuthenticator' class & its former state?
I'm periodically persisting all of the data in my actual model classes. Should I consider also persisting the state data in these utility style classes? Is that the pattern to follow?
I must have done something wrong. I have a C# project in Visual Studio 2008. All of a sudden I see a lock on my classes and when I hover the class names on the top tab I see the class name as : C:\Myprojects\Oder.cs[Read Only] !
Has something weird like that happened to you before ?
Thanks
I am new to C++ programming, but I have experience in Java. I need guidance on how to pass objects to functions in C++.
Do I need to pass pointers, references, or non-pointer and non-reference values? I remember in Java there are no such issues since we pass just the variable that holds reference to the objects.
It would be great if you could also explain where to use each of those options.
Let's say that on the C++ side my function takes a variable of type jstring named myString. I can convert it to an ANSI string as follows:
const char* ansiString = env-GetStringUTFChars(myString, 0);
is there a way of getting
const wchar_t* unicodeString = ...
Using python and wsgiref.handlers, I can get a single variable from a form with self.handler.request.get(var_name), but how do I iterate through all form variables, be they from GET and POST? Is it something like this?
for field in self.handler.request.fields:
value = self.handler.request.get(field)
Again, it should include both fields included in the POST and fields from the query string, as in a GET request.
Thanks in advance folks...
I want to use a database which name is stored in a variable. How do I do this?
I first thought this would work but it doesn't:
exec('use '+@db)
That will not change database context
Suggestions anyone?
Hi, what happens when you cin letter to int variable? I tried simple code to add 2 int numbers, first read them, than add them. But when I enter letter, it just fails and prints tons of numbers to screen. But what causes this error? I mean, I expected it to load and use ASCII code of that letter.
My classifieds website uses mainly PHP and MySql.
On error, (for example if a variable isn't found), I would like to have an error-page to show, is this possible? And I mean for every error to point to the same error-page.
I am thinking about htaccess, but maybe there are other ways also?
Same with MySql, how is it done there?
Thanks