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:

View 11 Replies


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

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

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

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

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

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

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

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

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

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

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

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

Setting Variables Ahead Of Time With Gobal Variables

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

Convert $_GET Variables To Regular Variables? About 10 Times

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

Funny Behaviour Of Cookie Variables And Session Variables?

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

Class Design - Variables In Array Instead Of Distinct Variables?

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

Change PayPal Posted Variables Into Local Variables?

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

Call Private Variables And Var_dump() Shows Three Variables?

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

PHP Code:abstract class FormInput
private $_value = "value";
private $_name = "name";


View 1 Replies

Same Named Variables.. Or Addressing Variables In A Loop

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

Converting Post Variables Into Session Variables

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

Get New Variables Added To Previous Variables On Page?

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

Passing Variables To A WCF Web Service - Variables Are Blank

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

Session Variables Lost Between Pages Or Use Same Variables?

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

Session Variables Interchanged With Local Variables?

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

SESSION Variables Clash With Normal $ Variables?


$_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

Variables Outside Functions A Kind Of Global Variables?

$foo = 1;
function meh(){


View 6 Replies

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

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

Read Variables From The URL And Scripts Declaring Variables?

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

Putting Variables Inside Predefined Variables?

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

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

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

Passing Variables & Dummy Variables

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

Passing Variables And Session Variables

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

Copyrights 2005-15, All rights reserved