Re: [PHP] Unexcepted $this

2008-03-13 Thread Anup Shukla

Murat BEŞER wrote:

So what do you thing about on this thing ?



I really would like to figure out the problem.
However, my simple script to mimic your code did not throw any errors.

If you could provide some more details, maybe we can figure out the problem.

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unexcepted $this

2008-03-09 Thread Anup Shukla

I am sorry. Please disregard my previous post.
I think i am wrong on that.

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unexcepted $this

2008-03-09 Thread Anup Shukla

Murat BEŞER wrote:

Thank you Anup,

But why I getting this error ?
is this a bug ?



Its not a bug.
It has to do with operator precindence and associativity.

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unexcepted $this

2008-03-09 Thread Anup Shukla

Murat BEŞER wrote:

I can't under stood but PHP gaves me an error:

"UnExcepted $this" for " || $this->getFileExtension($file) == 'jpg' "

When I removed jpg extension check it's okay... PHP script runs well.

What is the problem :)

public function loadImages($folder) {
$result = $this->filemanager->fecthFiles($folder);
$images = array();
if (sizeof($result)>=1 && $result !== false) {
foreach ($result as $file) {
if ($this->getFileExtension($file) == 'gif' || 
$this->getFileExtension($file) == 'png' || 
$this->getFileExtension($file) == 'jpg') {


if (
   ($this->getFileExtension($file) == 'gif') ||
   ($this->getFileExtension($file) == 'png') ||
   ($this->getFileExtension($file) == 'jpg')
) {
... rest of your code
...
}



$images[] = array('name'=>$file);
}
}
}
return $images;
}




--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Where is FAM ?

2008-01-31 Thread Anup Shukla


Hi all,

The manual says,

XXXVII. File Alteration Monitor Functions
..
..
Note: This extension has been moved to the » PECL repository and is no 
longer bundled with PHP as of PHP 5.1.0.

..
..

But i am unable to locate it on PECL either.
Is there any way to use FAM/GAMIN with PHP ?

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] potentially __sleep() bug

2008-01-30 Thread Anup Shukla

Nathan Nobbe wrote:

all,

i was playing around w/ some object serialization tonight during
further exploration of spl and i stumbled on what appears to be a
bug in the behavior of the __sleep() magic method.

here is the pertinent documentation on the method
..is supposed to return an array with the names of all variables
of that object that should be serialized.

so, the idea is, *only* the instance variables identified in the array
returned are marked for serialization.
however, it appears all instance variables are being serialized no matter what.
see the reproducible code below.  ive run this on 2 separate php5
boxes, one w/ 5.2.5, another w/ a 5.2.something..



this is what i get despite having marked only member variables 'a',
and 'b' for serialization.

__sleep
object(A)#1 (3) {
  ["a1"]=>
  string(2) "a1"
  ["a2"]=>
  string(2) "a2"
  ["a3"]=>
  string(2) "a3"
}

consensus ?



To check if __sleep is proper, you should be doing
var_dump(serialize(new A()));

unserialize'ing effectively also does a __wakeup()

This should give a clearer picture

a3 = 'a3';
}

public function __sleep() {
echo __FUNCTION__ . PHP_EOL;
return array('a1', 'a2');
}
}

var_dump(unserialize(serialize(new A(;
?>

__sleep
object(A)#1 (3) {
  ["a1"]=>
  string(2) "a1"
  ["a2"]=>
  string(2) "a2"
  ["a3"]=>
  NULL
}

= and ==

a3 = 'a3';
}

public function __sleep() {
echo __FUNCTION__ . PHP_EOL;
return array('a1', 'a2', 'a3');
}
}

var_dump(unserialize(serialize(new A(;
?>

__sleep
object(A)#1 (3) {
  ["a1"]=>
  string(2) "a1"
  ["a2"]=>
  string(2) "a2"
  ["a3"]=>
  string(2) "a3"
}

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How can I do this -- method chaining

2008-01-30 Thread Anup Shukla

Nathan Nobbe wrote:

Actually, I don't think so. I believe constructors return void, while
the 'new' keyword returns a copy of the object.



im pretty sure constructors return an object instance:
php > class Test { function __construct() {} }
php > var_dump(new Test());
object(Test)#1 (0) {
}



AFAIK, constructor simply constructs the object,
and *new* is the one that binds the reference to the variable
on the lhs.

So, constructors return nothing.


but anyway, how could you even test that __construct() returned void
and the new keyword returned a copy of the object?  new essentially
invokes __construct() and passes along its return value, near as i can tell.

Christoph,
if you dont want to write a function in the global namespace, as suggested
in the article, Eric posted, just add a simple factory method in your class,
eg.
doSomething();
?>

-nathan




--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] avoid server folder reading

2008-01-20 Thread Anup Shukla

Richard Heyes wrote:

I would like to know how to avoid (using PHP code) any user to read the
content of my website folder ?
as my website is hosted by and external company, i do not have access to
apache conf file.


If your server's default file is index.php, you could use the following 
in an index.php file:




If it's index.html, you could use the following:


<!--
location.href = '/';
-->


Try the PHP version first.



Will that not result in an infinite redirection loop?
Or am i missing something very obvious !

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Any way to use header() or another function to force user to "top level"

2008-01-12 Thread Anup Shukla

Chuck wrote:

That is exactly what I am using now but the location I am redirecting
to is loading within the  tags and at the top level of the
browser.



Are you using AJAX to load the page?

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] session_start problems with FireFox on Mac

2008-01-12 Thread Anup Shukla

Terry Calie wrote:
Hey... thanks for the replies.  I installed the headers feature that 
Richard suggested and found that no headers were output.
I started to transfer my php to another site to see if the problem 
replicated and I wasn't able to recreate the problem. 
It turns out that I "require" a file before the session_start that had 
one stupid character of whitespace at the end of it.  When I transferred 
the php to recreate the problem, I replaced the "require" call with the 
actual code - eliminating the whitespace at the end of the file, so the 
problem didn't replicate.  It took me a long time to figure out that was 
the problem.  What a killer!




You may use ob_clean() just before the header()
to get rid of the extra whitespaces.

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't find .php3 files

2008-01-09 Thread Anup Shukla

Jim wrote:

Hi, Mike,

The include is more like
require "../admin/admin.php3" I don't know exactly how Apache performs 
its magic so I wasn't sure that the request for an include file would 
even pass through Apache's hands.  In my limited world, an include 
wouldn't have to involve Apache, just the file systems.




The admin.php3 seems to be 2 levels above the current dir.

What about

print realpath("../admin/admin.php3")

in the same script?

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ereg help!

2008-01-09 Thread Anup Shukla

steve wrote:

On Tuesday 08 January 2008 20:30:29 Chris wrote:

I usually use preg_* functions so here's my go:



echo preg_replace('/\.php$/', '.com', $file);


The '$' at the end makes sure it's a .php file and won't cause problems 
with files like xyz.php.txt .



(otherwise I'd just use a straight str_replace).


Thanks

Guess i was just trying to over think it. Have not done much with files.


Steve



$out = basename($file, ".html") . ".com";

fairly limited i think, but simple.

--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] is_executable() ???

2008-01-07 Thread Anup Shukla

Al wrote:

clearstatcache();
if(is_executable(PATH_TO_SOURCE_DIR . $filename)
{
code
}


is_executable() will only tell if the execute bit is set for the 
provided file.




Always returns true for:
foo.jpg
foo.php
foo.sh

And even if I feed it a non existing file.


Checking on a non-existing file basically is checking for the directory.
PATH_TO_SOURCE_DIR . $filename == PATH_TO_SOURCE_DIR if $filename == ""

Directories generally have the permission 0755 which means they have the 
execute bit set, and hence the "true" result.




I found one ref that said is_executable() doesn't work in safemode, 
seems dumb if true.


If that's so, how can I test whether an uploaded file is executable?


Any file, under unix can be executable if the execute bit in the file 
permissions is set.


Make sure you umask settings are correct, so that files created do not 
have the execute bit set or use chmod on the file after uploading.


If you intend to find if the file is an executable in the Windows 
sense... is_executable() will not help you.


Try examining the mime type of the file.. (PECL::Fileinfo),
though it may of be of little help.

Additionally, using is_uploaded_file() and move_uploaded_file() 
functions is recommended while dealing with uploaded content.




I'm on a NIX with Apache, etc.




--
Regards,
Anup Shukla

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Problem with PHP and Oracle

2003-07-02 Thread Anup Vijayaraghavan
Hello

I am having problems connecting to Oracle 9.2.0.3.0 from php. It connects
fine but crashes after 3 or four attempts.

My setup is
Redhat Advanced Server 2.1
uname -a
Linux .xx.xx 2.4.20 #2 SMP Thu Jun 12 08:35:45 NZST 2003 i686 unknown

Server version: Apache/2.0.46
Server built:   Jul  2 2003 10:28:07

ldd /opt/httpd/bin/httpd
libaprutil-0.so.0 => /opt/httpd//lib/libaprutil-0.so.0 (0x40018000)
libexpat.so.0 => /opt/httpd//lib/libexpat.so.0 (0x4002b000)
libapr-0.so.0 => /opt/httpd//lib/libapr-0.so.0 (0x40047000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0x40068000)
librt.so.1 => /lib/i686/librt.so.1 (0x40099000)
libm.so.6 => /lib/i686/libm.so.6 (0x400ac000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x400d)
libnsl.so.1 => /lib/libnsl.so.1 (0x400fd000)
libdl.so.2 => /lib/libdl.so.2 (0x40113000)
libc.so.6 => /lib/i686/libc.so.6 (0x40117000)
libredhat-kernel.so.1 => /lib/libredhat-kernel.so.1 (0x40253000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x4000)


I have configured php 4.3.2 with 

./configure --with-apxs2=/opt/httpd/bin/apxs --with-oci8=/oracle/
--prefix=/opt/php-4.3.2 --enable-sigchild 

httpd.conf has
LoadModule php4_modulemodules/libphp4.so
AddType application/x-httpd-php php

# PHP Syntax Coloring (recommended):
AddType application/x-httpd-php-source phps

I am setting ORACLE_HOME when I start httpd
++
Normal php stuff (e.g) phpinfo and other stuff still works but any page with
connection to oracle do not work. Once I restart the http server, things
work again for the first 3-4 or four attempts.

The error log of apache shows

[Thu Jul 03 09:16:53 2003] [notice] child pid 5590 exit signal Segmentation
faul
t (11)
[Thu Jul 03 09:16:53 2003] [notice] child pid 5589 exit signal Segmentation
faul
t (11)
[Thu Jul 03 09:16:53 2003] [notice] child pid 5588 exit signal Segmentation
faul
t (11)

Please let me know what I am doing wrong.

cheers
Anup

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: two submit buttons redirecting to two scripts

2002-10-14 Thread Anup

you have this:




change the name of the buttons to b1 and b2, respectively, and give them
some non-null value (as you have it)
Then in action.php you will have the following code:
if ($b1) {
redirct to script1
}
elseif ($b2) {
redirct to script2
}

/*Either b1 OR b2 will have a value, not both, and use header() to redirect
the sctipt*/




"Sonal Patel" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hello,
>
> I am very new to this group.
>
> I have a very simple question.
> Please look at this form,
> http://antriksh.com/resources/2_submit_button_form.shtml
>
> here I want to change the echo statement in the script "action.php" to
> redirect it to another script.
>
> ie, I want to change the form action dynamically.  How can I modify
> this form to do so?
>
> I tried few PHP tricks that did not work for me.  So I am asking this
> questions to anyone who may be able to help.
>
> Thank you ,
> Sonal
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: How to navigate backwards in PHP ???

2002-10-12 Thread Anup

Well, if you have control for the referring page, then create a hidden value
whose value is the URL. Then you can use that. The problem is that PHP is a
server-side language not a client-side (like JS), so PHP has no control over
the browser.

"-<>-" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> This is really puzzling me ... I've tried finding the answer in the manual
> ... but sofar without luck...
>
> What I need to is simply to be able to make a go-back link that points to
> the URL that contains the page that had the link that send the user to the
> current page ... (did that make sense?)
>
> Or to put it another way: I need to be able to have a link on page A,
> point to page B, and then have page B know the exact URL of page A
> (including all variables that's needed to build page A).
>
> The thing is that simply using 
> doesn't work because the internal links adds the hash-mark (#) after the
> URL, and then the browser needs to go one more step backwards for each
> time the user clicks on an internal link ...
>
> I could easily write a JS function to handle all of this, but my goal is
> to not use any JS at all, and really, this is something that ought to be
> easily doable in PHP ... only I can't figure out how ... does it have
> something like Document Referrer ??? which could contain the URL of the
> sender, which I'd then be able to plump into a variable, which could then
> be used when generating the links to go back to the sender page...
>
> TIA
>
> Rene
> --
> Rene Brehmer
> System developer in the making...
>
> This message was written on 100% recycled spam.
>
> My website: http://www.geocities.com/cerberus_hotdog
> Babes and computer & internet references...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: secure access

2002-10-09 Thread Anup

I belive you can have the file atleast one directory below your root web
folder (so web surfers have no access, just your script). Also since the
HTML->PHP is unsecure over HTTP, look into HTTPS , I believe this is related
to SSL (Secure Socket Layer). Without SSL, you will be POSTing your
user/pass enter from the HTML form in plain text, which is always a target
for packet sniffers.

Hopefully that will shed some light, BUT I myself am not familiar with SSL
so please check with a more experienced/knowledged person.

"Roman Duriancik" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> If I want to secure the access to the database by asking for passwd, what
> should I do ? I suppose I need a secure connection to transfer the
username
> and passwd between HTML form and the script - how do I make that ?
> How do I secure the database file with passwords and user names so that
> it cannot be accessed by anyone, just by allowed users ?
>
> thank you
> roman
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Shopping cart? Ahh!

2002-10-08 Thread Anup

Hey, I just took a look at you site. It seems you are not utilizing session
variables. By having session variables, you can go back and forward with no
problem.
"Steve Jackson" <[EMAIL PROTECTED]> wrote in message
01c26ed4$5fa50e90$[EMAIL PROTECTED]">news:01c26ed4$5fa50e90$[EMAIL PROTECTED]...
>
> I have a shopping cart which starts with two categories. The links to
> each category both have a unique userID so that shopping information can
> be added to the cart. The problem I have is this:
> My user can add and remove as many of one category to his cart, but if
> he links back to the page with both categories listed he loses state
> (userID) so loses the items in his cart when adding part of the other
> category.
>
> Currently my back button is using this code and I need a quick fix if
> possible:
>  src='../images/nuoli_left.gif' border='0' alt='Back'>";?>
>
> Where CatID is the category (currently only one or two) and the UID is
> the USerID made up of the time date and IP address.
>
> You can see what I mean by going here:
> http://www.violasystems.com/Cart/ and following the links.
> Click a device server for instance add one of them to the cart and then
> go back and try adding a starter kit. I want both to appear in the cart
> if possible.
>
> Any ideas?
> If not I'm off for a cry!
>
> Steve Jackson
> Web Developer
> Viola Systems Ltd.
> http://www.violasystems.com
> [EMAIL PROTECTED]
> Mobile +358 50 343 5159
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] detecting POST variables

2002-10-07 Thread Anup

Here's the code
$Value) {
  echo "DEBUG ::: POST Key: $Index; POST Value: $Value\n";
 }
?>
### Here's the function (this is how what I catually use).
function PrintVars () {
global $HTTP_POST_VARS;
foreach ($HTTP_POST_VARS  as $Index=>$Value) {
  echo "DEBUG ::: POST Key: $Index; POST Value: $Value\n";
}
}

The first snippet seems to work fine by itself, but if call it as a function
(as the latter snippet) then it doesn't print the variables. I have the POST
array defined as global (in the function), could that be why it takes out
the empty textbox variables?

"Justin French" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> on 08/10/02 9:13 AM, Anup ([EMAIL PROTECTED]) wrote:
>
> > Hello, I have been dealing with different form proccessing PHP scripts.
When
> > I start a new job I usually have a script that just takes the form POST
> > values and prints them to the screen, so I know what I'm working with.
Now
> > I have a question say the form has 1 field named "FirstName". If the
field
> > is left blank, sometimes my script will print the key and NO value, or
it
> > will just print out nothing, ie NO key or value.
>
> Are you certain this is happening on text fields?  Typically text fields,
> password fields and textareas allways set a key, and no value of blank.
Ie:
>
> $_POST['FirstName'] = '';
>
> Select boxes should always have a value set.
>
> Check boxes are only set IF the box was ticked.
>
> What I'd advise is that you make a quick form and test this out -- perhaps
> it was only checkboxes that were sometimes not being set?
>
>
> > any ideas.  Could it be the server (IIS or Unix/Linux) of the form and
the
> > server (IIS or Unix/Linux)  of the script.?
> > Since I do jobs for different people and environments any combination of
> > servers are possible.
>
> I've never experienced this problem on any environment -- FreeBSD, RedHat
or
> Windows.
>
>
> > The reason, for this post is that I don't know if I should always put
code
> > to check for validilty using isset all the time or should I put it in
just
> > in case the script gets moved. I want to pinpoint this so that I can
write
> > more effective code.
>
> You should be able to use isset() or empty() on text/password/textarea
form
> elements reliably.
>
> Write a SMALL test script, test it, and if it ain't working, post the code
> :)
>
>
> Justin
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: detecting POST variables

2002-10-07 Thread Anup


This  is a snippet of what I use:

 foreach ($HTTP_POST_VARS  as $Index=>$Value) {
  echo "DEBUG ::: POST Key: $Index; POST Value: $Value\n";
 }

But I just want to know why sometimes when the form has empty values, that
sometimes it prints the key's name but not the actual value.
Assume the form has a textbox with name="FirstName", sometimes I get
DEBUG ::: POST Key: FirstName; POST Value:
OR
empty string
###
it looks like the first case has FirstName as a key in the POST array, where
as the latter doesn't.






<[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> You should use
> foreach($_POST as $key => $value) {
> echo $key.':'.$value;
> }
> Btw thats just an example to get all $_POST values, all superglobals are
> arrays.
>
> --
>
> Nicos - CHAILLAN Nicolas
> [EMAIL PROTECTED]
> www.WorldAKT.com - Hébergement de sites Internet
>
> "Anup" <[EMAIL PROTECTED]> a écrit dans le message de news:
> [EMAIL PROTECTED]
> > Hello, I have been dealing with different form proccessing PHP scripts.
> When
> > I start a new job I usually have a script that just takes the form POST
> > values and prints them to the screen, so I know what I'm working with.
> Now
> > I have a question say the form has 1 field named "FirstName". If the
field
> > is left blank, sometimes my script will print the key and NO value, or
it
> > will just print out nothing, ie NO key or value.
> >
> > any ideas.  Could it be the server (IIS or Unix/Linux) of the form and
the
> > server (IIS or Unix/Linux)  of the script.?
> > Since I do jobs for different people and environments any combination of
> > servers are possible.
> >
> > The reason, for this post is that I don't know if I should always put
code
> > to check for validilty using isset all the time or should I put it in
just
> > in case the script gets moved. I want to pinpoint this so that I can
write
> > more effective code.
> >
> >
> >
> >
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] detecting POST variables

2002-10-07 Thread Anup

Hello, I have been dealing with different form proccessing PHP scripts. When
I start a new job I usually have a script that just takes the form POST
values and prints them to the screen, so I know what I'm working with.  Now
I have a question say the form has 1 field named "FirstName". If the field
is left blank, sometimes my script will print the key and NO value, or it
will just print out nothing, ie NO key or value.

any ideas.  Could it be the server (IIS or Unix/Linux) of the form and the
server (IIS or Unix/Linux)  of the script.?
Since I do jobs for different people and environments any combination of
servers are possible.

The reason, for this post is that I don't know if I should always put code
to check for validilty using isset all the time or should I put it in just
in case the script gets moved. I want to pinpoint this so that I can write
more effective code.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Pay Pal

2002-09-30 Thread Anup

Hello everybody, I thought programming pay pal would be a cinch. I can;t
find any information in programming pay pal. All I need to do is one simple
transaction to paypal. payapldev.org is down for the next week. Does any one
know any other site I can use?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Friend of function??

2002-09-18 Thread Anup

I want to use arrays (that are outside of a function) to be visible to a
function. I understand that I must you global. But I was wondering is it
possible to make it visible to only certain functions, similar to the
'friend' keyword in C (or C++ ?) ? The reason, is that I don't feel
comfortable having globals, (I was brought up that way). Also, if you
actually declare something global are there any disadvantages such as
performance hits?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] turn register_globals on

2002-09-08 Thread Anup

Hello I am working on a PHP server which has register_globals off. In my
script is there anyway to turn it on, just for my script?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] variable variables and Sessions

2002-07-30 Thread Anup

I have a question about the following

$LoadResult = mysql_query("SELECT * from Items where username='test' and
password='test'");

 $num_results =mysql_num_rows($LoadResult);
 for ($i=0; $i < $num_results;$i++) {
$myrow = mysql_fetch_array($LoadResult, MYSQL_ASSOC);
$ProductName = $myrow["ProductName"];
$Quantity = $myrow["Quantity"];


$$ProductName = $Quantity; [1]
$HTTP_SESSION_VARS[$ProductName] = $Quantity; [2]
session_register("$ProductName"); [3]
 }


/*END CODE*/
so what I want to do is through the query result, create new session
varaibles, where the name of the variable is $ProductName and whose value is
$Quantity.

for some reason if  I just have lines [2] and [3] then the session variables
are present, but once the page is reloaded/refreshed they are gone. However
if I have lines [1] and [3], then my code can't access the session variables
(through calls to $HTTP_SEESION_VARS) until the page is refreshed. It seems
odd that I have to write lines [1] AND [2] to make the code work. They seem
symantically correct.

Thanks in Advance,
Anup





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] mySQL Queries using PHP's SESSION variables

2002-07-25 Thread Anup

Hello, I am stuck here. In the name of efficiency I want to lower the number
of callls to the database. So I am trying to give the most stringent query
possible. This is the problem: I have stored the surfers shopping cart,
where each item is stored as a session variable.Now on the database I have
ALL inventory items, but I want to only display the details of what the user
has in his cart.
eg. : I want something like this:

$result = mysql_query("SELECT * from Inventory where ItemNumber is in
$HTTP_SESSION_VARS");
//  I need proper syntax to replace "is in"

where Inventory has, ItemNumber (unique), Price, ItemName.
So say the surfer has three items in the Session, then I stored the three
unique ItemNumbers.
Then with the above query I can get the rest of the information to represent
to the user.
I am looking down the avenues of a Set datastyp or maybe Enum, but I don't
know if it will help.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Passing variables to page via POST - How?

2002-07-18 Thread Anup

Hey, I'm new, but I have some advice.
Do you have to POST? becuase you can use sessions, and PHP has a bunch os
session functions.
Secondly, POST will not attach any variables to the URL, this is done by
GET.
To access the POST variables traverse through the $HTTP_POST_VARS (or $_POST
array, i think) to retrieve your values.
But if you can try using sessions, more secure, and as easy to use as POST,
just traverse $HTTP_SESSION_VARS.
"Monty" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> This is probably more of an HTML question... Is there a way to pass
> variables to another page via POST instead of via the URL? I need to pass
> several variables, one that is an array and another that is a fairly long
> string, so, I can't really do this via the URL.
>
> My initial idea was to just create a very simple form that only has hidden
> fields with the data I want to pass, along with an image Submit button
that
> would call the page and pass the hidden field variables.
>
> Is that the only/best way to accomplish this?
>
> Thanks.
>
> Monty
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Creating Dynamic Variables

2002-07-17 Thread Anup

Hello, I have captured variables from any HTML that is POSTed to me from a
'foreach' clause. Now, possibly in this foreach clause I want to register
these name/value pairs into a session var. I have tried :
session_start();
foreach ($HTTP_POST_VARS as $name=>$value) {
$name=$value;
session_register(name); //without the $
}
and get nothing.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php