variables

psql passed variable

故事扮演 提交于 2020-01-02 12:39:29
问题 New to psql scripting. I try to pass a variable to a psql script but get an error: psql -v dateav="2012-01-28" mcdb -p 5555 -U admin -q -t -A -c 'select count (client_name) from v_activities where scheduled_start_date like :'dateav';' ERROR: syntax error at or near ":" LINE 1: ...) from v_activities where scheduled_start_date like :dateav; Any ideas? 回答1: Would work like this: echo "select count (client_name) from v_activities \ where scheduled_start_date like :'dateav'" | \ psql -v dateav=

Passing PHP variables into MySQL

纵然是瞬间 提交于 2020-01-02 12:15:03
问题 I have a function in PHP which inserts values into MYSQL tables. function insertRow($db, $new_table, $ID, $Partner, $Merchant) { $insert = "INSERT INTO " .$new_table. " VALUES(number, "string", "string")" $q = mysqli_query($db, $insert); } I am struggling customizing the VALUES part. I need the number, string, and string to be ID, Partner, and Merchant variables from PHP respectively. I've tried function insertRow($db, $new_table, $ID, $Partner, $Merchant) { $insert = "INSERT INTO " .$new

Pass value of a include to a variable

谁都会走 提交于 2020-01-02 11:31:32
问题 Is it possible to pass the result of an include to a variable? Let's consider this simple file 'example.html': <p>some HTML</p> In a PHP file, how can we pass the content of this file to a variable? I tried: $my_variable = include('example.html'); It includes the file, but the value of $my_variable is 1 . 回答1: If you just want to get the content of file you can use this : $data = file_get_contents("example.html"); echo htmlentities($data); or this : ob_start(); readfile("example.html"); $data

print the memory location of a variable (or pointer)

☆樱花仙子☆ 提交于 2020-01-02 10:04:57
问题 I want to print where a variable is stored. I Google it and I found this: int *p; printf("memory location of ptr: %p\n", (void *)p); If I write this, is it right? printf("memory location of ptr: %p\n", &p); I compiled it and I didn't get any errors or warnings. However, the above two commands didn’t return the same value! 回答1: Lets say you have these declarations: int i; int *p = &i; It would look something like this in memory: +---+ +---+ | p | --> | i | +---+ +---+ If you then use &p you

Application variables global to Webgarden

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-02 09:55:14
问题 I am currently trying to program an online drawing program using the HTML5 canvas. The thing is, I need to have the current canvas saved somewhere globally. Static variables work, but they do not get shared across a Webgarden. This results in two different drawings being created. I will have to somehow create a new application object which is shared. I figured I will need an external application holding them. 1) How do I replace the application object with my own? So either I will have to

Learning OO coding with PHP, static != expressions, but PHP manual says everything that has a value is an expression, confused

人走茶凉 提交于 2020-01-02 08:24:13
问题 I started to learn OO a few days back, I'm quite OK with procedural coding but obviously that is not enough and I want to become a well versed coder with a lot of experience and knowledge, so first thing to learn completely must be OO followed by the right design patterns I think. Anyhow, I have one thing where I'm stuck which I don't quite follow... Static variables... I understand that a static variable doesn't lose it's value even if the containing function is finished executing, and will

Access Session Variable within a class

时光总嘲笑我的痴心妄想 提交于 2020-01-02 08:03:07
问题 Is it considered normal using session_start on a class constructor when session values need to be retrieved or keep? Best practices? Session variable coudn't be retrieved from class unless session_start is called from __contruct. session_start(); if(isset($_REQUEST['siteid'])){ $siteid = $_REQUEST['siteid']; $_SESSION['siteid'] = $siteid; echo $siteid; }else{ $siteid = ""; } require_once 'common/lib_constant.php'; require_once 'common/database.php'; require_once 'common/common.class.php';

get variables substituted when I cat a file

倾然丶 夕夏残阳落幕 提交于 2020-01-02 07:35:25
问题 Is it possible, in a clean way to get the variable values when I cat a file, instead of the variable names, as written in the file. It's hard to explain, but here goes a simple example: $ cat <<EOF $HOME EOF /home/myself cat returns /home/myself because it is already expanded by the shell. $ echo \$HOME >/tmp/home $ cat /tmp/home $HOME cat simply reads the file, I want $HOME to be expanded here somehow by cat, because the file will contain variable names (not like HOME=/home/myself) My

how to call non static method from static method in android

假如想象 提交于 2020-01-02 07:26:45
问题 I am facing a big problem in calling non static method from static method. This is my code Class SMS { public static void First_function() { SMS sms = new SMS(); sms.Second_function(); } public void Second_function() { Toast.makeText(getApplicationContext(),"Hello",1).show(); // This i anable to display and cause crash CallingCustomBaseAdapters(); //this was the adapter class and i anable to call this also } I am able to call Second_function but unable to get Toast and CallCustomBaseAdapter()

Store Variable Name in String in VB.NET

旧城冷巷雨未停 提交于 2020-01-02 06:57:09
问题 I'm trying to store the names of some variables inside strings. For example: Dim Foo1 as Integer Dim Foo1Name as String ' -- Do something to set Foo1Name to the name of the other variable -- MessageBox.Show(Foo1Name & " is the variable you are looking for.") ' Outputs: ' Foo1 is the variable you are looking for. This would help with some debugging I'm working on. 回答1: Well, you can clearly just set Foo1Name = "Foo1" - but I strongly suspect that's not what you're after. How would you know