Sum Of Two Variables.

Nov 13, 2007

Im creating a small stats counter (god knows why after all the trouble it ahs caused me!) for my site, and getting all of the relevant data from the server log files. Getting the data isnt a problem, and slicing it up is fine but..

Ive created a rule that is trying to emulate a google analytics feature (the feature will count a visitor twice if they return after a certain amount of minutes even if its the same ip), but the code doesnt work. There are loads of different ip's in the log so I just cant understand why the code is interpreting just one ip. Code:


Functions Can Recognize My Global Variables Without Sending These Variables As Parameters In The Function Headers?

Aug 19, 2001

If I define a variable $var, and then define a function Func(), then I can't use the variable $var inside the function because the variable is defined outside the function. If I want to use the variable $var inside the function, then I have to send it as a parameter in the function header like this, Func($var).

But the problem is that I have many global variables, and many function. I don't want to pass all these variables to all the functions! Isn't there a way that the functions can recognize my global variables without sending these variables as parameters in the function headers?

View 7 Replies View Related

Http Headers - Send Redirect Page Pass Variables As Post Variables From A Script?

Dec 19, 2010

you can find a similar question here PHP Post Request inside a POST Request but this is not working in my context. I have a form (reservation form for a tour website) and when the form is submitted, the values are processed in a script like validation and calculation of values and sending email. after processing the variables, i want to send it to a page for payment and this page will post payment details to paypal.

My question is after the reservation form is submitted, after processing values retrieved from reservation from, how can i redirect the page in such a way that the variables will be passed as post variables. (I am not looking from response from the other form, i want to redirect to the other form).

View 3 Replies View Related

Variables Not Holding / Variables From The Previous .php Script Dont' Transfer Over?

May 2, 2011

I have a .php script with 2 variables. $company and $user. During this .php script I require_once "/var/www/etc/etc/etc/etc/"

The .php file that I require_once, the variables from the previous .php script dont' transfer over. I can't figure out why, or what I am doing wrong. Ex.

master.php script

$company = "Some Company";

$user = "John";

require_once "/var/www/$company/$user/example.php

example.php script

$myFile = "/var/www/$company/$user/Template/Download/example.php";

The data that is held in the variables $company & $user doesn't hold through on the example script. I can't understand why.

View 3 Replies View Related

Regex - Passing Variables To Perl - Using Spaces Between Variables Method?

Aug 16, 2010

i had been using this method to call perl (before i started trying to do this with regular expressions).. passing in a regex string as a variable causes all sorts of problems, such as using " ( )" anywhere makes it not work, among other things.. I am wondering if there is a better way to do this, than the string of variables after the perl filename method as it seems to have some glaring limiations.

the way I do it currently:

$file = "/pathtomy/ $var1 $var2 $var3" ;
$perlreturn = ob_get_contents();
return $perlreturn;

View 2 Replies View Related

Linux - Testing Two Double-variables Gives Different Result Without Changing The Variables?

May 19, 2010

in my code i have two double values. Lets call them $a and $b. now I want to test which one of them is larger, so I wrote the following:

print ($a > $b ? "larger
" : "smaller
print ($a > $b ? "larger
" : "smaller

does anybody encountered a similar problem before? This problem only appears on our embedded linux system using php-cgi.

Here is the whole code: I need to decode a hex value into a decimal value regarding the sign and eventually useng numbers larger than the integer-size


View 1 Replies View Related

Assign Variables To The Value Of The Post Variables Using The Field Names?

Jun 25, 2006

IâÄôve been using an older version of PHP up until recently. Using the older build I had 'register_long_arrays' on. However this depreciated some time ago and I want to start working with 'register_long_arrays' set to off.

My question is; if, for example you have a form with 25 fields is there a quick way assign variables to the value of the post variables using the field names? Code:

View 3 Replies View Related

Setting Variables Ahead Of Time With Gobal Variables

Jun 8, 2005

I just obtained a book that teaches you how to use php to handle form info. I created the example form as well as the php script to handle the form input. But when I run the form the $name(Variable) and $email(Variable) will not populate. I tried setting variables ahead of time with gobal variables, but didn't work. Ex.


View 1 Replies View Related

Convert $_GET Variables To Regular Variables? About 10 Times

Jul 27, 2007

Do you guys always convert your GET and/or POST variables to regular variables $variable = foo;? On a page, I'm using a GET variable about 10 times, would it be more efficient to convert it to a regular variable (I'm sure there's a name for this type of variable) at the beginning?

Does it have anything to do with load on the PHP (interpreter, like it goes to check the variable from the URL every time, which is maybe more of a strain than from the document itself), or just mere file size?

View 5 Replies View Related

Funny Behaviour Of Cookie Variables And Session Variables?

Nov 14, 2010

I wrote a little PHP script below to demonstrate my question. Run the code below like this:[URL]You will see that the number echo'ed to your screen is always 1 digit behind the url number?! Maybe because I cant a cookie and immediately read the same cookie?

//If query string has $test, store in session, and cookie for later.
$_SESSION['test'] = $_GET[test];
setcookie("test", $_GET[test], time()+60*60*24*30*12*10); //10 years
//If user comes back later, then get $test from cookie
if (isset($_COOKIE["test"])){.......

View 3 Replies View Related

Class Design - Variables In Array Instead Of Distinct Variables?

Mar 12, 2010

I'd like some suggestions/critique/opinions on the following setup of class "bar". Both classes "bar" and "foo" hold the same data and do the same stuff, the difference being that in one case data is held in an array whereas in the other there are distinct variables. Is there anything fundamentally wrong with that approach that would make you say "I would never do that"? Obviously it's not easily possible to convert the variables in the array to "public" - but I do not intend to do so - I prefer using accessors and mutators for exposing class variables.

The advantage that I see is that I can build a "lazy" constructor where I can simply fill the whole class-data in one swoop - for example from an array that I got through a datareader class that retrieves them for me from a DB.


View 4 Replies View Related

Change PayPal Posted Variables Into Local Variables?

Jul 15, 2011

How can I change PayPal posted variables into local variables? I just want to echo out the amount in my page. And I want to send visitors to my page directly when they click paynow button I want to skip other step. Now paypal show the 2 links 1 is go to my site and 2 is paypal account overview when they hit the paynow button. i dont want to show those links. Here is my code:

<form action="" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="">


my page code

$amount = $_POST['amount'];
echo $amount;

View 1 Replies View Related

Call Private Variables And Var_dump() Shows Three Variables?

May 21, 2009

var_dump() shows all three variables, but can't seem to call them directly.

PHP Code:abstract†class†FormInput


View 1 Replies View Related

Same Named Variables.. Or Addressing Variables In A Loop

Mar 5, 2001

I'm just starting to program in PHP.. fairly new to programming in general... and I've run across a (probably simple) programming problem I hope someone can help me with. I'm sending variable names through an HTTP get that are generated through a foreach loop. The names are along the lines of name1=, begin1=, end1=, name2=, begin2=, end2=.. etc. The number is the number of the current cycle through the loop. My problem is addressing the variables on the next page... namely how do I evaluate those variables in a loop? I want the value of name1.. but obviously

for (i=1; i<3; i++)
echo "$name$i";

is not working. Is there an easy way to do this?

View 7 Replies View Related

Converting Post Variables Into Session Variables

Jun 3, 2006

I have a script in which I take a whole lot of data from a number of pages of a form, compile it into one, and let the user edit it before it's eventually thrown into a SQL database. The data coming from the forms is in post, and I've created arrays of all of the fields in the form, like: Code:

View 5 Replies View Related

Get New Variables Added To Previous Variables On Page?

Oct 13, 2009

My question is, in other words, how can I get new variables added to previous variables on the page? Imagine this being [URL] but after submitting this form it'll go to [URL] What I would expect would be: Imagine this being [URL] How could I resolve this?


View 1 Replies View Related

Passing Variables To A WCF Web Service - Variables Are Blank

Apr 22, 2011

I have a WCF Service, the interfaces work fine when connecting with a c# application but when I connect using a PHP application all variables passed to the service are null.

This is the PHP code used to connect to the service and send the data.

$SelectedFolder = $_REQUEST['folder'];


The var dump displays the following

string 'Pictures/Sample/' (length=16)

This is the service code

List<VersionedFileDataModel> GetAllLatestVersionsString(string partUri);

I've tried passing a static value instead of a variable and both times the value received by the service is null.

View 1 Replies View Related

Session Variables Lost Between Pages Or Use Same Variables?

Jan 2, 2011

I have Wamp Server(2.2.11) with PHP(5.2.9.-2). I know I did something wrong but I didn't find myself.Before I wrote this e-mail I red many document with different search items. I test a same application with different User IDs. When I use "session.use_cookies = 0", session variables lost between pages for SAME UserID. When I use "session.use_cookies = 1", same session variables are used DIFFERENT User IDs.

My php.ini's session settings at below:

session.save_handler = files
session.save_path = "c:/wamp/tmp"


View 1 Replies View Related

Session Variables Interchanged With Local Variables?

Sep 23, 2010

I've encountered a very odd issue in regards to session variables and local variables in php. if I am not understanding something about sessions in php or if this is an issue with the php version my host is using.Here is a very simple code to demonstrate the weird issue:


It looks to me like the session variable 'kenny' and local variable $kenny become aliases to one and the other after running the script more than once. hmm... I really don't think this is how session variables and local variables work in php.My web host is running php 5.2.2. When I try this exact same code on other hosts running php 5.2.1, 5.2.14 and 5.3.1, they always give me what I expect:

1st time:NULL NULL NULL string(3) "def" string(3) "abc" string(3) "def"


NULL string(3) "def" NULL string(3) "def" string(3) "abc" string(3) "def"

I checked the change log on and didn't find anything that I can relate to that may address this issue. But like I mentioned, an earlier build (5.2.1) works ok, so that's very puzzling to me.If anyone runs any other version of php 5.2.x, please give it a try and let me know if you see the same issue.

View 1 Replies View Related

SESSION Variables Clash With Normal $ Variables?

Mar 12, 2010


$_SESSION['username'] = 'steve';
$username = 'steve';

I am using these two variables in my program, but somewhere I have a bug and I'm having trouble fixing it.Is it possible for these two variables to clash in some way since they have the same name? I keep loosing the value held in $_SESSION['username'], whilst all the other $_SESSION variables remain intact.Does doing this cause ambiguity in some way?

View 1 Replies View Related

Variables Outside Functions A Kind Of Global Variables?

Jun 5, 2011

$foo = 1;
function meh(){


View 6 Replies View Related

Global Variables = Off To Pass Variables To SECOND & THIRD Page?

Apr 17, 2009

Currently using PHP 4.4.9 and I am having a hard time figuring this one out. I can get this to work with Global variables set to ON but I do not want to use this setting and want it to be OFF. I have done many searches and have not turned up anything that works. All examples seem to be only for passing variables to the next page.....and unfortunately that isn't working either Here is my scenario.PAGE 1:I define variable $usrID = 5; on this page as something that needs to be passed to other pages.PAGE 2:I want to echo $usrID or use it for somethingPAGE 3:I want to echo $usrID or use it for somethingI have session_start(); located at the top of each page. I have tried many different combinations of $_SESSION, $_REQUEST, $_POST, etc etc etc but cannot seem to figure out how to pass the variable that is defined on PAGE 1 to be display on any other page and it is killin me a slow death I can successfully pass a value from one page that is a FORM and $_POST the values to the next page, but like above, I cannot get those values to $_POST to another page after they have been submitted to a DB for example and then later show them on another page.If someone could show me a really easy example as far as what to put on each page it would be greatly appreciated as then I can test it out and then start applying my more complex example.

View 4 Replies View Related

Read Variables From The URL And Scripts Declaring Variables?

Sep 2, 2009

Declare $_GET['firstname]'to NULL(nothing or whatever)then I have totally destroyed the original purpose of the GET variable.which is to read variables from the URL.How can I ever read variables from the URL if at the top of all the scripts declaring those variables as being equal to nothing.

View 5 Replies View Related

Putting Variables Inside Predefined Variables?

May 22, 2010

I would check for a cookie something like this


But how can I do this ...

$cn = "cookie_name";

I can't get it to work. Is there a special way of assigning a variable to a global predefined?

View 5 Replies View Related

Cross-file Variables / Make A Ton Of Permanent, Global Variables That Will Be Valid On Any File On The Current Installation??

May 3, 2011

I have a bunch of database addresses and other random long strings that I must input into functions again and again all over my site. Is there a way to make a ton of permanent, global variables in PHP that will be valid on any file on the current PHP installation?

Or should I just make a vars.php with all of the variables defined, and always include that file?

View 3 Replies View Related

Passing Variables & Dummy Variables

Apr 22, 2007

Hi! thanks for all the previous help - I've made some progress & have dropdowns and a checkbox; however I have 2 probs which I can't figure out: grateful for any further help. THANKS!

1. Not sure how to code so that user can query from just 1 or all of the dropdowns (at the moment unless they select the correct answers from each dropdown - no results!) = defeats the whole purpose of searching. By selecting from menu options user selects from 2 diff tables.

[the page allows user to search catalogue by selecting year of release, artist, music type - results from 2 tables need to be selected & sent to mysql.

I just don't know how to code it so that user must make an initial selection to get any results, and whichever menu options they choose "add them together" if you like to make a complete query.... sorry my coding just isnt deep enough!

A friend suggested using a dummy variable but as I'm a bit out of my depth; I need to get some help!

The coding I've done so far;

View 1 Replies View Related

Passing Variables And Session Variables

Jun 1, 2003

I'm currently working on a shopping cart script that works just fine with register_globals turned on but when turned off i get all kind of errors. The following page displays a detail of the book with the "Add to cart" link at the bottom. PHP Code:

View 2 Replies View Related

Passing My Variables With Forms Variables

Feb 20, 2001

how to carry variables onto the next page along with the forms variables. I need to carry my own over too, but when I press submit on the form page only the forms variables carry over, not my own ?? I have two drop down menues on my form that provide two values "start & end" which I require to go with my own variables.I have tried "a href=" link which carries my variables but not the forms variables.

echo"<form method=get action=somepage.php?one=$one&two=$two&three=$three&four=$four>";?>
also tried
<a href=somepage.php?one=$one&two=$two&three=$three&four=$four&start=$start&end=$end

View 2 Replies View Related

Persistant Variables - Application Variables

Jul 1, 2002

In the books I have read about PHP I haven't been able to find any descriptions of how to set variables that persist in the servers memory, in the way that Application variables persist in Cold Fusion.

In CF, if I set an application variable then any of the application pages that are run will have access to those variables. And you can put complex arrays of data in the Application Variables and then access these variables at any time, without having to reload those variables for each page when it loads. I expect you can do this is PHP, but I can't find any info about how to do this.

View 14 Replies View Related

Variables That Change Session Variables

Jul 16, 2005

I'm currently writing a mulit-page form app that uses a session to
retain data from each form element in order for the user to jump
between pages, then the final data is passed to a calculation script.

However, I've noticed that if I assign a session variable to another
variable, which then performs a mathematical calculation, the session
variable changes.

i.e. $_SESSION["inflation"] = 4;

$temp_inf = $_SESSION["inflation"];
if ($_SESSION["inflation"] =="RPI") {
$inflation = $rpi;}
else {$inflation = ($temp_inf/100.0);}

now it equals = 0.04

How can I take a value from a session and perform operations on it
without altering the original session value.

View 1 Replies View Related

Can You Set FILES[] Variables To Session Variables?

Oct 17, 2006

I have some code to upload files to my site. it works when the <input
type="file" is posted once even when I use session variables from the
posted variables but when I carry those session variables to a new page the
upload will not work.

despite the variables being set. I have echoed then on
the second page and they display correctly but they just dont work in the
move_uploaded_file() function. Code:

View 7 Replies View Related

Convert Variables To JavaScript Variables?

Nov 2, 2009

I am trying to insert php variables into javascript.

Here is the broken code:

var tokens = [<?
$result = mysql_query("SELECT * FROM accounts ORDER BY id DESC") or die (mysql_error());
while ($row = mysql_fetch_array($result)) {
$user_name = $row['user'];
$user_id = $row['id'];
echo "['$user_name','$user_id'],";

View 3 Replies View Related

OOP Class Variables Vs Object Variables?

Mar 23, 2011

when making a class in php what is the difference between these two :

class Search
function __construct()
$this->variable1= 1234;


if i need to access a value across different methods does it make any difference which approach i chose?

View 4 Replies View Related

Get Variables From A Shell Script Into Variables?

Jun 27, 2009

run a shell script from php and he needs to get the variables created in the script back into the php code when the shell script is finished. creates the variables in php and send those to the shell script instead; he could do this but would prefer to use the shell script if possible. This is the code I am using to call the shell script:

PHP Code:



View 10 Replies View Related

Form Variables To Session Variables

Nov 30, 2007

I am writing a small script that consists of two pages:† page one displays a bunch of values from a DB (ie. First Name, Last Name, Phone Number).† On this page you will find a form that follows this format:

<input type="text" name="edit_firstname" size="20" maxlength="35" value='Bob'>
<input type="text" name="edit_lastname" size="20" maxlength="35" value='Smith'>
<input type="text" name="edit_phone" size="20" maxlength="35" value='5552222'>

So when you see the page there will already be a 'default' value in each line (which is information extracted from a DB).† This works perfectly and has been tested thoroughly.

On the second page I have the following code:

$editfirstname = $_POST['edit_firstname'];
$editlastname = $_POST['edit_lastname'];
$editphone = $_POST['edit_phone'];

What I am trying to do is this:† the default value for edit_firstname from the form is 'Bob' by default, but the user can change this in the input field on the first page.† This value, whether changed or unchanged, should then be stored as edit_firstname and by calling up the function $_POST[''] on the second page I want to transfer the value to the variable $editfirstname.†

However, it seems that $_POST['edit_firstname'] and the other fields do not return a value at all, hence $editfirstname = '' or $editfirstname = 'NULL'.† I have never tried to do things this way before.†

View 3 Replies View Related

Defining Variables - Print The Variables

Apr 22, 2007

Can it be done? I ve been searching the net for ages looking for tutorials or examples and i cant find anything. What im trying to do is something like this:

if ($variable == "blah")
$a = 1;
$b = 2;
$c = 3;
echo ($e . $f . $g);

Ive tried about a hundred different ways of doing it, but none of them print the three variables. what im doing wrong or give me the correct coding for this?

View 1 Replies View Related

Check Variables Line By Line In Text File And Store Unique Variables?

Jun 10, 2011

I store my variables in text file.Next I get another vars, they most store in text file if they arent duplicate and old data must be clear.Check each new vars by vars stored in file. and only store unique vars.for example first I have:



View 1 Replies View Related

Pull All Instance Variables Of An Object As Local Variables Into The Scope Of An Method From That Object?

Jan 1, 2010

I have an class with some instance variables. It's purpose is for templating.

So this class has a fetchTemplate() method which includes a PHP template file.

In my template file, I can access any variable that has been assigned to the template, by writing:

echo $this->theVariable

If there was a way to "pull" all arbitrary instance variables into the local variables scope of fetchTemplate(), it would be possible to simply write:

echo $theVariable

View 1 Replies View Related

Make The Variables In @include("variables.php") Global?

May 5, 2010

My php script looks something like this. Is there someway to make the variables in variables.php global so that I don't have to read the file with every function?

PHP Code:

View 5 Replies View Related

Store Variables From Db Select To Class Variables When The Table Field Names Are Identical To The Class Variable Names

Jul 10, 2011

I am selecting data from a database. The database field names are exactly the same as the class variable names. Is there a way to store this data into the class variables without specifying each one individually?

//gets info about a specified file.
//chosen based on a supplied $fileId
function getFileInfo($fileId)


View 4 Replies View Related

Variables As Session Variables

Mar 22, 2007

From a main form I submit and reach different other forms/scripts and eventually return to the main form. When I return to my main form I find that the form's variables are empty (their values no longer exist) and what I need is that each time I return to my main form, I want to still have the values.

Is it common practice to have forms directly stored in session variables to overcome this problem?

For example:

<textarea name=_SESSION['lineArray'][$line][firstName] > $_SESSION['lineArray'][$line][firstName] </textarea>

View 4 Replies View Related

Variables Within Variables In Functions

Aug 27, 2007

I have created the following function. PHP Code:

function matrix($r)
    $m1 = file("m1.txt");
    $m1r{$r} = explode(" ",$m1[$r]);

You give it a line number ($r) and it returns that line from m1.txt as an array.
Each line in m1.txt is a series of numbers separated by spaces. This all works fine.

However lets say I have several text files and do not want to create a separate function for each array. How do I replace 1 with a variable? Code:

View 4 Replies View Related

Put Variables Inside Of Variables?

Apr 24, 2010

For example, take this code:

$ch = curl_init($resultSet['url']."?get0=get0&get1=".$get1."&get2=".$get2."&get3=".$get3);

This of course, looks very ugly, and kind of a pain in the ass to read. So my question is, would I be able to use something like this:

$allgets ="?act=phptools&host=".$host."&time=".$duration."&port=".$port;
$ch = curl_init($resultSet['url'] . $allgets);

Very simple question I suppose, but my server is undergoing maintenance, so I can't upload it and test it myself. I suppose a yes or no answer will suffice, but if you have a more efficient way of doing this, that would be even better.

View 2 Replies View Related

Append Variables To Url Which Already Has Variables?

May 3, 2009

I would like to run to a snippet of HTML and extract all the links referring to my own domain. Next I want to append these URL's with a predefined string of GET vars. For example, I want to append '?var1=2&var2=4' to [URL]

The method I'm currently applying is a simple preg_replace function (PHP), but here is when it gets interesting. How do i create valid appended url's when they already have some GET vars at the end? For example, it could create a url like this: [URL] thus breaking the GET data.

So to conclude, what I'm looking for is a reg exp which can cope with these scenarios, create my extended url and write it back to the HTML snippet.

This is what I have so far:

$sHTML = preg_replace("'href="($domainURL.*?[/$])"'", 'href="1' . $appendedTags . '"', $sHTML);

View 3 Replies View Related

POST Variables Being Sent As GET Variables?

Apr 24, 2010

The problem is, that for a basic form with a post method, the variables are being send as get variables :S. I have enough experience with forms and sending variables through post and get, even together at the same time in one form. I am working on a new site, on a new server, so I think it's got be something to do with the php settings I think, but can't find what it is. Maybe its a simple thing, that's why I post it here... Just in case, my very basic form code:

Code: [Select]<form name="vrm" method="post" action="index.php">
<table class=tmax style='width:350px;'>
<tr><td width=150>Username</td><td><input style='width:200px;' type=text name=username value="<?php†echo†$username;?>" /></td></tr>


View 13 Replies View Related

Mod_rewrite With Multiple Variables - Passing Multiple Variables With Mod_rewrite Using An Underscore As A Delimiter

May 10, 2010

I'm using a PHP script that dynamically generates transparent PNGs for use as CSS backgrounds from a query string that takes RGBa and HSLa values. The original script can be found here, I've only added HSLa support. Because background URLs with PHP query strings aren't very pretty, and because it seems to break the IE 6 transparent PNG hack, I thought of using mod_rewrite to allow the script to be called when a .png with this syntax is called :

/assets/colors/h[0-360 value]_s[0-100 value]_l[0-100 value]_a[0-100 value].png
which would be rewritten to : /assets/colors.php?h=[0-360 value]&s=[0-100 value]&l=[0-100 value]&a=[0-100 value]

Here's the issues I'm encountering: passing multiple variables with mod_rewrite using an underscore as a delimiter I know this could be done by passing a single variable and then exploding it in the PHP script, however I would prefer it to be done by Apache.

View 2 Replies View Related