Accessing dynamically created variables inside a function

Ads
 

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

Ads









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
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
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
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
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
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
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 variable Variables naming conventions are similar to any other language like first
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
Variables in Java
in a class but outside method or constructor. Instance variables are created when... for each  instance variable value is created. Instance variables are in scope... variables can be  accessed directly by calling the variable name inside
function
function  difference between function overloading and operator overloading
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
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
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
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
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
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 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
Variables in Java
Variables       Data... variables) Java Primitive Data Types Data Type Description... 0.0d In this section, you will learn about Java variables. A variable
Accessing Database using EJB
Accessing Database using EJB     ... through the EJB example given below to find out the steps involved in accessing...:-This is the session bean we have created. By session bean we mean the bean which
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 TensorFlow
of Constant In TensorFlow constants are created with the function tf.constant...Variables in TensorFlow - Defining and using variables in TensorFlow In this section we will learn how to create and use variables in TensorFlow. TensorFlow

Ads