variables

Rails: variable access: from ApplicationController to ActionView

How do I access in an ActionView a variable, that has been defined in the ApplicationController? In my case, I'd like to make my layout respond to a variable that's been set-up in the ApplicationController. If it were a view, associated with a controller's action, I'd only need to set-up an instance var in the corresponding action and ...

How to get scalar result from prepared statement?

Is it possible to set the result from a prepared statement into a variable? I am trying to create the following stored procedure but it is failing: ERROR 1064 (42000) at line 31: 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 'stmt USING @m, @c, @...

how to stop PHP variable being printed.

Hello All, I have this function I created to give my wordpress site a body tag... function give_body_class( $print = true ) { global $wp_query; $c = ""; // Generic semantic classes for what type of content is displayed is_archive() ? $c = 'archive_page' : null; is_date() ? $c = 'date_pag...

jquery theme settings options

Creating this theme, I'm pretty new to jquery and struggling as usual. Just watched this tutorial and decided to have a shot at making my own theme settings to simplify customization. This is what i have so far: (function($){ $.fn.themeSettings = function(options) { var slideshow = { ...

HTML onload - using variables as parameters

Hi, I want to use something like: <body onLoad="init('A sentence with "quoted text" as parameter')"> Unfortunately, this does work, as the quotes in the parameter are not treated properly. Escaping the quotes also does not work <body onLoad="init('A sentence with \"quoted text\" as parameter')"> (Above also does not work). How ...

Class variable within its definition?

This is probably a dumb question. I am trying to make a text-mud. I need each Room class to contain other Room classes that one can refer to when trying to move to them or get information from them. However, I can not do that because I obviously can not declare a class within its definition. So, how do I do this? Here's what I mean when ...

jQuery: Storing content of select-box to variable?

I have a select field at my HTML page that is populated with a few default items. With the help of AJAX, I replace the content (options) in the select field with appropriate options. How can I store the contents (options) of my select field into a variable and then load it into the select again? It would be helpful to be able to get bac...

$_SERVER question!?

Can anyone explain how I can use $_SERVER['REQUEST_URI'] How can I make it required like: In order to access this page, you have to come from THIS page (both are internal)? I thought $_SERVER can do this for me, and found the example above in php.net. How can I make use from it? Thanks ...

How would you create a non localized variable in a function so that it is accessible by other functions in javascript?

I have a variable in a function that I want to be accessible by other functions. How would you do that? ...

Magento - Passing data between a controller and a block

Really quick and simple question but I can't find a decent answer to this - What is the best way to pass data from a controller to a block in Magento. Incase it makes a difference, I am loading the layout as follows: $this->loadLayout(array('default', 'myModule_default')); $this->_initLayoutMessages('customer/session') -...

PHP: Check if variable exist but also if has a value equal to something

PHP Question: Hi there, this is just something I was wondering today, what I'm doing: I have (or not) a variable $_GET['myvar'] coming from my querystring and I want to check if this variable exists and also if the value corresponds to something inside my if statment: What I'm doing and think is not the best way to do: if(isset($_GET...

python - undefined variable?

Does python have some undefined variable / debug mode which will output a notice/warning? PHP allows you to modify the error_reporting to turn on notice warnings which mean doing <?php echo $foo; will throw an "Undefined variable foo on line 2....... does python have something similar? I had a bug where I was doing db.connect in...

What's the name of the Makefile 'match' special variable?

What is the name of the special Makefile variable that contains the match of %, to use in the rule body? As an example, I would like to use it like this: %.o: %.c @echo Matched $MATCH $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ where I put $MATCH there because I can't remember the actual name of that special pa...

using jquery contains inside a function?

Hi all, I'm trying to use the jquery :contains (or .contains()) selector inside a function, however I can't seem to get it to work. Basically I'm passing a string to a function and I want to check the variable if it contains X, do something else do something else. If that makes sense. Here's my code. function checkMe(myVar) { if ($...

Create a new variable as named from input in Python?

This is something that I've been questioning for some time. How would I create a variable at runtime as named by the value of another variable. So, for example, the code would ask the user to input a string. A variable would then be created named after that string with a default value of "default". Is this even possible? ...

Setting variables during component initialization in Flex

I am loading a component which makes a HTTPService call to get data that will then be used to set certain variables in the component. I make the HTTPService call in an init() function (for the initialization event) and then set the variables according to the data received in the HTTPService result handler. However, the variables are st...

Variable scope in multithreading, why my object reference is lost ?

Briefly under a single producer - single consumer scenario, I used a mutable object for synchronization and passing data and messages between producer and consumer. Shared buffer is a ConcurrentQueue of byte arrays. To implement a circular buffer and prevent heap fragmentation and frequent object swapping by GC I used a ConcurrentBag of ...

PHP: How to put a variable in an array?

Just a quick newbie PHP syntax question. I have a variable, let's call it $tabs which always contains a string of numbers separated by commas, like so: 24,35,43,21 I also have a variable that's an array: $args = array('post_type' => 'page', 'post__in' => array(27,19,29), 'order' => 'ASC'); That's of course WordPress. What I need to ...

array into variable

Say I get {1,2} from function f(a,b) (it doesnt matter what f is/does), and I want to store it into int s[2]. How would I do it? It seems that I can't just do int s[2] = f(a,b), and I can't separate the output of f, since there is no variable to get the values from. f(a,b)[0] does not work. ...

Using Jquery to test two select items and their values and return result from within one of two arrays?

Hi All, This has got me for some reason the code below is translating the currency variable to a string and then not getting the actual value from the self named variable... $("#quantity").change(function() { var euroPrice = new Array("12.95", "14.95", "18.95", "21.95"); var gbpPrice = new Array("10.95", "11.95", "16.95", "18.9...