Accessing dynamically created variables inside a function

Accessing dynamically created variables inside a function

Hi, I'm sure this is a stupid question but I've been trying to find the solution for days and have had no luck. Hopefully someone out there can help.

So I am attempting to set a variable dynamically like so:

$pid = $GET['p_id'];

This part goes smoothly but my problem arises when I attempt to pass this variable to a function in the following way.

public function InsertUpdate($uid,$update,$uploads,$pid) {

$update=mysql_real_escape_string($update);
  $time=time();
   $ip=$_SERVER['REMOTE_ADDR'];
       $p_id = **$p_id;**

.....

        $query = mysql_query("INSERT INTO `messages` (message, uid_fk, poster_id,ip,created,uploads) VALUES ('$update', '$uid',

'$pid', '$ip','$time','$uploads')") or die(mysqlerror());

.... For whatever reason the function does not see the variable unless I set it to a constant like

$p_id = 2;

Any ideas would really be appreciated!

View Answers









Related Tutorials/Questions & Answers:
Accessing dynamically created variables inside a function
Accessing dynamically created variables inside a function  Hi, I'm... to set a variable dynamically like so: $pid = $GET['p_id']; This part goes smoothly but my problem arises when I attempt to pass this variable to a function
variables are **called instance variables because they are created** whenever an object of the class is instantiated.
variables are **called instance variables because they are created** whenever... fields inside the body of the class definition. These variables are called instance variables because they are created whenever an object of the class
Advertisements
user defined function inside a jsp
user defined function inside a jsp  how to write a user defined function inside a jsp page
how to validate values in the dynamically created textboxes?
how to validate values in the dynamically created textboxes?  how to validate values in the dynamically created textboxes in HTML using javascript...;script language="javascript"> var n=1; //FUNCTION TO REMOVE TEXT BOX ELEMENT
Java Function for block inside a block
Java Function for block inside a block  Write a function in Java that attempts to place a set of squares of varying widths into another, larger square. If there is no possible layout, return undefined. Otherwise, return
Java Function for block inside a block
Java Function for block inside a block  Write a function in Java that attempts to place a set of squares of varying widths into another, larger square. If there is no possible layout, return undefined. Otherwise, return
Accessing MS ACCESS databse using a HTML webpage [created using Javascript]
Accessing MS ACCESS databse using a HTML webpage [created using Javascript]  HI team, This is Srinivas, and I have a query and i explained here... I have to save some datas in an MS ACCESS database file [*.mdb], after
How to Validate dynamically created text box in HTML using Javascript
How to Validate dynamically created text box in HTML using Javascript  Here is the HTML code to create text boxes dynamically. It works properly.... And also how to validate the text boxes created dynamically. <html>
dynamically created links id from mysql table is not getting
dynamically created links id from mysql table is not getting  guys, i'm trying to access dynamically called attributes from mysql table as a link to another page, but while i'm trying to access its value, i'm getting only
Create a input button inside js function
Create a input button inside js function  I call my js function from... using createElement() in my called function. I used something like this but doesn't seems to work. Lets show is the function being called function show
Dynamically added Row is Invisible in another javascript function..?
Dynamically added Row is Invisible in another javascript function..?  ... with below code)..but when add row its creating row in a table, but the created row is not visibile in another java script function. scripts are pasted at the bottom
How to handle the list dynamically in struts inside logic:iterate tag
How to handle the list dynamically in struts inside logic:iterate tag  I am having following code in JSP <table> <tr> <logic:iterate name="loginForm" id="inutParams" property="inutParams" indexId="i"> <
PHP variables 2
PHP variables 2       Variables in php are dynamically declared and used. We use "$" sign before any... of variableADS_TO_REPLACE_1 Variables naming conventions are similar to any other
Variables
Variables  What are the difference between Static variables, instance variables and local variables
In JSP page, inside a javascript function, can I place a java code using scriptlet tag?
In JSP page, inside a javascript function, can I place a java code using... not empty. Inside the javascript function closeWind(), I make a call... checkListValue() using scriptlet tag inside the javascript function closeWind
PHP Variable Outside Function
either outside the function or inside the function. If we declare a variable within... a variable outside the function, it will not seen inside the function.  Let's see... declared the variable outside the function and asking to print inside
Variables in Java
. Instance variables are created when the object is created with new keyword ..., variable inside a class and static class. Static variables is also called... is declared inside a class but outside the method or Constructor. These variables
What are local variables?
a block of syntax like methods. Local variables should be initialised before accessing them. For details related to Local Variables...What are local variables?   hi, What are local variables? thanks
function
function  difference between function overloading and operator overloading
PHP Variables Default Value
PHP Variables Default Value In this tutorial we will learn how to set default value in PHP variables or Functions. If there is no value in the variable passed to the function call than only the default value is used by the function
JavaScript add row dynamically to table
JavaScript add row dynamically to table  ... to add row to a table dynamically then we can also do this with the JavaScript code. In this example we will describe you how to add row dynamically to the table
java memory allocation for member variables and member functions
java memory allocation for member variables and member functions  Suppose I have created a class named test with a member function name fun... an object q of test class then when shall the memory be allotted for function fun
C Replace String
C Replace String       In this section, you will learn how to replace a string in C.  Here a function pointer replace is created in which variables st, orig, repl
PHP Variables Using Arithmetic Operators
through variables. There are many operator to perform all these function... PHP Variables Addition We already learn about how to create variable... of the variables. The output of the above example is : 10 + 20 =30.ADS
getting variables
getting variables   how to get variables from servlet program to webservice program
How to dynamically build a JSON object with Python
How to dynamically build a JSON object with Python  Hi, I have many variables with lots of data inside this. There may be new line or any type of uni code data. I tried to make json manually by adding variables but it fails. So
How to dynamically build a JSON object with Python
How to dynamically build a JSON object with Python  Hi, I have many variables with lots of data inside this. There may be new line or any type of uni code data. I tried to make json manually by adding variables but it fails. So
Environment variables
Environment variables  How to set Environment Variables in JAVA 6 n Tomcat 6 CLASSPATH, JAVA_HOME, PATH, & CATALINA variables plzzz plzz help me
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
Accessing your site
Accessing your site  I cant acess your site.I am getting good grip on java through roseindia.kindly help me so that I can acess roseindia
Accessing Database using EJB
Accessing Database using EJB     ... through the EJB example given below to find out the steps involved in accessing... AccountStatusBean.java:-This is the session bean we have created. By session bean we mean
searching inside a file for details
searching inside a file for details  i created a file with name,country,state etc...when i'm searching for the name, i have to get other details like country,state etc...please do help
accessing xml using java
accessing xml using java  I need to retrieve some elements in xml file using java   Hi Friend, Please visit the following links:ADS_TO_REPLACE_1 http://www.roseindia.net/xml/Listingnode.shtml http://www.roseindia.net
Accessing webcam in jsp
Accessing webcam in jsp  Hi Friends, I have to access the webcam through jsp and display the snap in same jsp taken after a click. I am using java media framework but i am not able to detect the device using CaptureDeviceManager
Accessing Web-cam
Accessing Web-cam  I am giving options to upload a photo to the user.. options are: 1st) upload a photo from ur hard drive. 2nd) upload a photo from web-cam. Then how to implement 2nd option using jsp ....can any one
Variables in Java
Variables       Data... variables)ADS_TO_REPLACE_1 Java Primitive Data Types Data Type... variables. A variable refers to the memory location that holds values like: numbers
Hibernate :dynamically choosing server
Hibernate :dynamically choosing server   Is it possible to dynamically choose server name in hibernate
Variables in TensorFlow
In TensorFlow constants are created with the function tf.constant(). Here...Variables in TensorFlow - Defining and using variables in TensorFlow In this section we will learn how to create and use variables in TensorFlow. TensorFlow
how to access element added via javascript dynamically using jsp code
. (because they have been created dynamically by javascript) Now,i want to save...how to access element added via javascript dynamically using jsp code ... javascript dynamically using the jsp code. i am adding empty records on .jsp page
PHP Variable variables
PHP Variables variable: Variables variable is a new kind of technique of using variables, in this technique we need to use more than one variable and we can use those variables dynamically. As in the following examples we can see
change xml dynamically
change xml dynamically  How to change an XML dynamically in Java
Java - Declaring variables in for loops
Java - Declaring variables in for loops  Java - Declaring variables in for loops
instance variables - Java Beginners
instance variables  instance variables
Accessing database with JDBC via Java
Accessing database with JDBC via Java  How to access a database with JDBC via Java application?   Accessing database with JDBC through... where stored or created your database userName: - User name of MySQL password
Dynamically adding textbox and labels
Dynamically adding textbox and labels  Sir, In my application I want to insert texbox and labels dynamically and want to insert database field value in that generated label. Plz help me, Thanks in advance
Variables In Java
This tutorial demonstrates you about the variables and their types in java
transient variables in java
transient variables in java  hello, What are transient variables in java?   hii,ADS_TO_REPLACE_1 Transient variables are variable that cannot be serialized
populate Combo Box dynamically
populate Combo Box dynamically  Hi, How to populate the Combo Box dynamically using Flex with Jsp's
Java Substituting Variables
Java Substituting Variables  Java Substituting Variables

Ads