variables

Howto declare variable and use it in the same SQL script?

Hi everybody, I am doing some tests here and write some SQLs. I try to write some reusable code and therefore I want to declare some variables at the beginning and reuse them in the script, like this: DEFINE stupidvar = 'stupidvarcontent'; SELECT stupiddata FROM stupidtable WHERE stupidcolumn = &stupidvar; I tried so far: Use a DEC...

PHP and undefined variables strategy

Hello, I am a C++ programmer starting with PHP. I find that I lose most of debugging time (and my selfesteem!) due to undefined variables. From what I know the only way to deal with them is to watch the output at execution time. Are other strategies to notice earliers these faults? (something like with C++ that a single compile gives ...

Get the 'name' of a variable in Javascript

Possible Duplicate: Determine original name of variable after its passed to a function. I would like to know if its possible to get the actual name of a variable. For example: var foo = 'bar'; function getName(myvar) { //some code return "foo" }; So for getName(foo) will return "foo" Is that possible ? Thanks. ...

PHP writing to MYSQL is variable equals 0

I am trying to write to my database if a variable is equal to 0. The problem is that it still writes to the database even when the variables equals 1. What is wrong?? echo $new_user; if ($new_user == 0) { //SENT NEW USER WELCOME MESSAGE $adminid = '9'; $welcomemessagetitle = 'Welcome to The site'; $welcomemessagecontent = 'He...

Would it make sense to have a 'constify' operation in C++?

Would it make sense to have a "constify" operation in C/C++ that makes a variable const? Here is an example where it could be useful, where obviously we don't want to declare it const yet in the first line: std::vector<int> v; v.push_back(5); constify v; // now it's const Currently, without such a possibility, you'd have to introduce...

Android onSaveInstance State not working (for me)

Hi people. I have an application that acts like a clapperboard, in which I use a variable i going to i++ every millisecond (I need milliseconds to display frames per second, and the chronometer updates only once per second), then I display it in the format HH:MM:SS:FF. I also have a quit button which goes by if (item.getTitle() == "Quit...

SQL Table "Pointer"?

Using SQl Server 2000 I have a stored procedure that joins 2 tables and then returns the data. I want this sp to be able to do this for whatever table name I pass into it, otherwise I'll have the exact same code with the exception of the table name 20 or so times in a giant if statement. Basically, how do I use a variable to point to a t...

PHP global or $GLOBAL

Hello! Is there a best practice / recommandation when I want to use a variable declared outside of a function when it comes to using: global $myVar $GLOBALS['myVar'] Thank you. ...

How to declare a public variable and a public sub in an aspx web page?

How do declare a public variable .aspx web page that can be used in all the pages within my web application? And/or create a Public Sub? ...

python+twisted+gtk: KeyboardInterrupt causes free variable?

I'm using twisted with GTK, and the following code runs when a connection could not be established: def connectionFailed(self, reason): #show a "connect failed" dialog dlg = gtk.MessageDialog( type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format="Could not connect to server:\n%s" % ( ...

Javascript character counter help

I have some code that I am using to count characters in an input/textarea and display a countdown on my page. My problem is that I want the ability to define which div I want the counter displayed in. How can I add a variable to this code in which I can define which div I want the counter to appear in???? Help me geniuses!!! (function...

Delegate variables Vs. Core Data

Hello, I wonder when I should use Core Data and when I just should keep it easy and use delegate variables? ...

PHP: pass a variable to a function, do something to the variable, return it back.

Assuming the following code: <?php function doStuff($rowCount) { $rowCount++; echo $rowCount.' and '; return $rowCount; } $rowCount = 1; echo $rowCount.' and '; doStuff($rowCount); doStuff($rowCount); doStuff($rowCount); ?> The desired output is 1 and 2 and 3 and 4 and The actual output is 1 and 2 and 2 and 2 and I ...

symfony - clean variables before sending to template

Hi! On the project I am currently working, I had created an action that generates a csv file. Here is some of my current template codem, which generated the csv file on-the-fly: <?php header('Content-Disposition: attachment; filename="file_'.date("Y-m-d_H-i",time()) .'.csv"'); ?> Branch:;<?php echo $branch; ?>; The variable $branch,...

Setting a variable with select inside coalesce

How do I fix up this part of my stored procedure? The select will either return 1, 0, or null. If the select returns 1 or 0, I want @override to be set to that value. If it returns null, then I want @override to be set to 1. Something is wrong with my syntax; I am told "incorrect syntax near 'select'" and "incorrect sytax near ')'". ...

Objective C: How to call variables from other methods

Writing an iPhone App that uses the UISlider class. The Slider returns some value in its method. I want to use that value in another method...but since that value is a local variable for the slider method, how would I go about doing this? The keyword "static" doesnt seem to work because the slider value is not constant... Appreciate ...

using the C preprocessor to effectively rename variables

I'm writing a few very tight loops and the outermost loop will run for over a month. It's my understanding that the less local variables a function has, the better the compiler can optimize it. In one of the loops, I need a few flags, only one of which is used at a time. If you were the proverbial homicidal maniac that knows where I liv...

Help me understand how is $this used in PHP...

In plain English, how is $this used in PHP? It's such a simple concept to me in JavaScript, but for some reason in PHP I can't get my head around this variable and its function. What, at any given point, is it referring to exactly? I have only tertiary experience with OOP, and I suspect that's why it's hard for me to understand its usag...

Variable variables in OOP

Hi everyone I'm having a little struggle on this one and would appreciate some help. In PHP variable variables can easily be defined like this $a = "myVar"; $$a = "some Text"; print $myVar; //you get "some Text" Now, how do I do that in a OOP enviroment? I tried this: $a = "myVar"; $myObject->$a = "some Text"; //I must be doing some...

vector of variable names in R

I'd like to create a function that automatically generates uni and multivariate regression analyses, but I'm not able to figure out how I can specify *variables in vectors...*This seems very easy, but skimming the documentation I havent figured it out so far... Easy example a<-rnorm(100) b<-rnorm(100) k<-c("a","b") d<-c(a,b) summary(k[...