[PHP] Sessions : overriding variable values

2002-07-25 Thread Petre

Hi
I am still battling alot with understanding how sessions work (don't 
work in my case).

Firstly: I am trying to find a reliable method for coding with sessions 
that will work on basically any server and any browser; meaning no 
cookies and passing the SID to all url's manually.
My app has the following ( amongst others)
index.php = login page with form and 2 fields (username / password), 
session_start()
On the action page, I session_start() again, and then 
session_register("username","password") and I don't need to give them 
values as the form fields are called that and PHP generates them for me 
(register_globals = on).
This works great, on ALL subsequent pages in the app, I can simply call 
$username and $password, and it works.

BUT, my app has alot of iterations, and now I'm battling to understand 
how to change these session variables "on the fly" in a sensible manner; 
in particular when it comes to forms that "generate" their own variables 
on submit.

It seems like my problem comes in that I can only set a session variable 
once it "exists" , ie, on the action page, and then also, that the app 
goes "backwards" allowing you to change your options, yet, when yuou do, 
the variables does not contain the new variables.

The fact that the app also doesn't have a specific "end" means I also 
don't know where to place the session_destroy()...

I have made 4 small pages to illustrate :

index.php



  
  
Username  
  
  
  
Password  
  
  
  
  

  



page2.php


This is username: 
This is password: 

  
  
First Variable
  
  
  
Second Variable
  
  
  


  



page3.php


This is username: 
This is password: 
This is first variable: 
This is second variable: 
To Page 2
To Page 4

page4.php


This is username: 
This is password: 
This is first variable: 
This is second variable: 
To Page 3


Also, not sure if it is browser related, but on mine, I sometimes get 2x 
SESSIONID= added to the end of the URL, even though I 
clearly put it in once only...

Am I missing the point here?
Plz help to make things clearer to me...
The only way I can get above scanario to work is to add the variable 
manually to all the url's as I've been coding all along.


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




[PHP] Good books on sessions

2002-07-29 Thread Petre

What are good books/websites about sessions.
I'm looking for more advanced stuff, I have the Luke Welling/Laura 
Tompson book, and have read the manual, but I still have issues that are 
unresolved.

Thanks



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




Re: [PHP] Good books on sessions

2002-07-30 Thread Petre

Well, I have asked a couple of questions on this list, but they havn't 
really helped alot. Maybe you can help?

My situation background is as follow:
I have always written my apps in the following way: register_globals=on, 
so I allowed PHP to "generate" my variables for me on the action page, 
and if I cannot use a form to "send" variables to the next pages, I 
added them manually to the url.
So, then I discovered sessions and thought my probelms were solved, only 
to discover that it uses cookies by default, and has to have the 
--trans-sid option compiled to have PHP handle the app if you don't want 
cookies ( like me, don't want cookies at all, or for that matter, 
anything that relies on the client's side). So, I couldn't just jump in 
and use sessions as I would not be sure that my app would work on any 
PHP4 system regardless of the options it was compiled with. ( Oh, I am 
writing my apps to work with register_globals=off now, so that shouldn't 
be a problem).
So I started to look for a way to code with sessions that will not 
require cookies nor require any special compile features; the answer 
came in adding  to all relative URL's in my app.
Alas, that is where I'm at, and it's still not working as I would have 
expected.
My problem is with the way my proposed app works/should work.

I am trying to write an app that allows the user to log in, then 
add/remove projects to his list, then, when a project is selected, he 
should have access to all the relevan documents in that project, again 
allowing him to add/remove documents from the project here, and in the 
last step, when a document is selected, allows hime to add/remove/edit 
chapters to the document.

My first attempt at using sessions with this failed miserably ( keeping 
in mind my approach of adding SID at end of urls). I have a "back" link 
on all the pages that takes the user to the previous  step(s) and thus 
on the last page ( the chpaters edit/remove/add page), there is a link 
to go back one level, two and three levels. Yet, using these causes 
unexpected results.
I think the problem comes in with overriding the value of the session 
variable.
For instance, on the first page you have a login form, on the action 
page I session_register("username","password"), and that works fine even 
when using the back buttons as the values are never changed. But, on the 
2nd page I have the drop down select containing all the project names ( 
gets built with a while that reads all the project names from the 
project_table) and send over the project_id.
On that actio page, I session_register("project_id"); and it also works 
fine for all pages "down stream", however, when I come back to that page 
to select a new project, it keeps the old variable...
At first I did nothing special in the sence of assigning a value to the 
session variables, as I let the register_globals=on do it's trick, but 
later I explicitly said
$project_id = $HTTP_POST_VARS["project_id"];

But that also did not overwrite the value of the session var. In the end 
I was forced to again add all my variables to the end of the url, 
keeping the session solely for the username and password.

I don't know if you would like  me to post my code (  it is quite a bit 
already ) but I would really appreciate it if someone could look at it, 
and then point out where I'm missing the picture, as then I would have 
two pictures that I can compare and see where my reasoning failed.

Thanks for your time.
 

Rasmus Lerdorf wrote:

>What issues?  Just ask.
>
>-Rasmus
>
>On Mon, 29 Jul 2002, Petre wrote:
>
>>What are good books/websites about sessions.
>>I'm looking for more advanced stuff, I have the Luke Welling/Laura
>>Tompson book, and have read the manual, but I still have issues that are
>>unresolved.
>>
>>Thanks
>>
>>
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>



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




Re: [PHP] Good books on sessions

2002-07-30 Thread Petre

Yes, it is a forward link to the page, but as mentioned, that page 
contains a form with the selection options, and on that form's action 
page is where I don't see the values change, so the question should 
probably be something like "how do I change the value in the session_var 
with the newly selected value?
And oh, I almost forgot:
Due to that fact that this type of app doesn't really have a logical end 
page, I cannot issue a session_destroy() anywhere logically ( except 
using a logout button), but that's not going to ensure that people use it...
I would ideally like to have this "app" run on an intranet, where people 
will most probably have this app open indefinately, and thus  I also 
battle with my logic of keeping a session alive.

Thanks
.

Rasmus Lerdorf wrote:

>Well, how exactly do you implement the back button?  If it is a normal
>client-side back, then of course the previous value will be shown.  If it
>is actually a forward-link to the previous page, then your logic on that
>target page is bogus.
>
>By the way, trans-sid is compiled in by default in PHP so should always be
>available.  And it will fallback to sid mangling only if cookies are
>disabled.  You would probably be better off just letting php manage this
>for you.
>
>-Rasmus
>
>On Tue, 30 Jul 2002, Petre wrote:
>
>>Well, I have asked a couple of questions on this list, but they havn't
>>really helped alot. Maybe you can help?
>>
>>My situation background is as follow:
>>I have always written my apps in the following way: register_globals=on,
>>so I allowed PHP to "generate" my variables for me on the action page,
>>and if I cannot use a form to "send" variables to the next pages, I
>>added them manually to the url.
>>So, then I discovered sessions and thought my probelms were solved, only
>>to discover that it uses cookies by default, and has to have the
>>--trans-sid option compiled to have PHP handle the app if you don't want
>>cookies ( like me, don't want cookies at all, or for that matter,
>>anything that relies on the client's side). So, I couldn't just jump in
>>and use sessions as I would not be sure that my app would work on any
>>PHP4 system regardless of the options it was compiled with. ( Oh, I am
>>writing my apps to work with register_globals=off now, so that shouldn't
>>be a problem).
>>So I started to look for a way to code with sessions that will not
>>require cookies nor require any special compile features; the answer
>>came in adding  to all relative URL's in my app.
>>Alas, that is where I'm at, and it's still not working as I would have
>>expected.
>>My problem is with the way my proposed app works/should work.
>>
>>I am trying to write an app that allows the user to log in, then
>>add/remove projects to his list, then, when a project is selected, he
>>should have access to all the relevan documents in that project, again
>>allowing him to add/remove documents from the project here, and in the
>>last step, when a document is selected, allows hime to add/remove/edit
>>chapters to the document.
>>
>>My first attempt at using sessions with this failed miserably ( keeping
>>in mind my approach of adding SID at end of urls). I have a "back" link
>>on all the pages that takes the user to the previous  step(s) and thus
>>on the last page ( the chpaters edit/remove/add page), there is a link
>>to go back one level, two and three levels. Yet, using these causes
>>unexpected results.
>>I think the problem comes in with overriding the value of the session
>>variable.
>>For instance, on the first page you have a login form, on the action
>>page I session_register("username","password"), and that works fine even
>>when using the back buttons as the values are never changed. But, on the
>>2nd page I have the drop down select containing all the project names (
>>gets built with a while that reads all the project names from the
>>project_table) and send over the project_id.
>>On that actio page, I session_register("project_id"); and it also works
>>fine for all pages "down stream", however, when I come back to that page
>>to select a new project, it keeps the old variable...
>>At first I did nothing special in the sence of assigning a value to the
>>session variables, as I let the register_globals=on do it's trick, but
>>later I explicitly said
>>$project_id = $HTTP_POST_VARS["project_id"];
>>
>>But that also did not overwrite the value of the session var. In the end
>>I was forced to again a

Re: [PHP] Good books on sessions

2002-07-30 Thread Petre

Thanks, will work through this immediately.
Just to be clear.
If I DO stick with your suggestion of letting PHP do the url mangling, 
and taking your code below, I can simply remove the

ini_set('session.use_trans_sid',false); and  from your code to make it work 
exactly as is?

Thanks


 
Rasmus Lerdorf wrote:

>The trick is to not name your form vars the same as your session vars.
>Keep them separate so you have full control of what ends up where.  Also,
>note that if you are not relying on trans_sid or cookies then don't use
>SID.  Call session_id() explicitly to get the session id.  So, a quick
>little mockup to illustrate this.
>
>login.php:
>ini_set('session.use_cookies',false);
>ini_set('session.use_trans_sid',false);
>session_start();
>$sid = session_name().'='.session_id();
>session_register('username');
>$username = 'petre';
>?>
>Next Page
>
>page1.php:
>ini_set('session.use_cookies',false);
>ini_set('session.use_trans_sid',false);
>session_start();
>$sid = session_name().'='.session_id();
>?>
>
>
>
>
>page2.php:
>ini_set('session.use_cookies',false);
>ini_set('session.use_trans_sid',false);
>session_start();
>$sid = session_name().'='.session_id();
>session_register('foo');
>$foo = $_POST['form_foo'];
>echo "You entered $foo\n";
>?>
>Back
>
>
>I am ini_setting on each page to force PHP to not do trans-sid/cookies.
>Would be easier to simply turn these off in the php.ini file.
>
>When you hit the back link, $_SESSION['foo'] will exist on page1.php and
>the form will get filled in with the previous value.  You can then change
>it, hit enter again and the session value will take on the new submitted
>value because I have decoupled the form data from the session data and I
>set the session var in page2.php.
>
>There are other ways to do this, but this is probably the easiest method
>to understand.  Play with this simple example until you understand how it
>works.
>
>But again, I'd suggest letting PHP do session id handling for you by
>letting it default to cookies and fall back to url mangling in the few
>cases where cookies are turned off.
>
>-Rasmus
>
>On Tue, 30 Jul 2002, Petre wrote:
>
>>Yes, it is a forward link to the page, but as mentioned, that page
>>contains a form with the selection options, and on that form's action
>>page is where I don't see the values change, so the question should
>>probably be something like "how do I change the value in the session_var
>>with the newly selected value?
>>And oh, I almost forgot:
>>Due to that fact that this type of app doesn't really have a logical end
>>page, I cannot issue a session_destroy() anywhere logically ( except
>>using a logout button), but that's not going to ensure that people use it...
>>I would ideally like to have this "app" run on an intranet, where people
>>will most probably have this app open indefinately, and thus  I also
>>battle with my logic of keeping a session alive.
>>
>>Thanks
>>.
>>
>>Rasmus Lerdorf wrote:
>>
>>>Well, how exactly do you implement the back button?  If it is a normal
>>>client-side back, then of course the previous value will be shown.  If it
>>>is actually a forward-link to the previous page, then your logic on that
>>>target page is bogus.
>>>
>>>By the way, trans-sid is compiled in by default in PHP so should always be
>>>available.  And it will fallback to sid mangling only if cookies are
>>>disabled.  You would probably be better off just letting php manage this
>>>for you.
>>>
>>>-Rasmus
>>>
>>>On Tue, 30 Jul 2002, Petre wrote:
>>>
>>>>Well, I have asked a couple of questions on this list, but they havn't
>>>>really helped alot. Maybe you can help?
>>>>
>>>>My situation background is as follow:
>>>>I have always written my apps in the following way: register_globals=on,
>>>>so I allowed PHP to "generate" my variables for me on the action page,
>>>>and if I cannot use a form to "send" variables to the next pages, I
>>>>added them manually to the url.
>>>>So, then I discovered sessions and thought my probelms were solved, only
>>>>to discover that it uses cookies by default, and has to have the
>>>>--trans-sid option compiled to have PHP handle the app if you don't want
>>>>cookies ( like me, don't want cooki

Re: [PHP] Good books on sessions

2002-07-30 Thread Petre

Yes , I agree,But that is exactly where my problem comes in, when I link 
the person forward, it DOES NOT take the new value for the project_id, 
as it is a form element and it only becomes variable on the action page. 
This is where I'm unsure about how to "initialize" the variable. As 
mentioned earlier in my posts, I simply do a 
session_register("project_id"); on the action page, I DO NOT say 
anything like

$_SESSION['project_id'] = "45"; or any other form of assignment whatsoever, as I leave 
the work to register_globals=on and it's normal expected behaviour. And I think this 
is where the problem lies.
It seems I MUST actually do that for things to work??? Unfortunately I cannot test 
this yet, as I'm busy with something else, and just trying to get the basic academics 
right. I understand the way you are explaining sessions 100%, but when I put that 
knowledge to practise, things doesn't seem to work... :( . 
I am still to test yours and Rasmus' sugestions and will come back shortly.

Thanks for the help so far.




Justin French wrote:

>*shakes head a bit*
>
>I'm not REALLY sure what the problem is here, but let's take a step back.
>
>A session ID is a unique, random number assigned to a user as they kick
>around your site.
>
>To maintain state (a session) across multiple pages, you pass the session id
>around.  This can be done with the URL or cookies.  Yes, trans_sid is in
>there as well, but all it does is re-write URLs.
>
>No surprises so far.
>
>
>You then assign variables to the session.  If you're using PHP >= 4.1, I'd
>use $_SESSION['varname'] = "value"; rather than session_register(), because
>it's a lot more logical, and clearer to think through.
>
>Furthermore, the manual tells us NOT to mix use of session_register('var')
>and $_SESSION['var'] = 'value'... so, pick a method, and stick to it...
>since the $_SESSION array is the new way, I'd be going with it.
>
>
>So, the first two session vars YOU assign after the user logs in is the
>username and password (I wouldn't register the password).
>
>$_SESSION['username'] = "justin";
>$_SESSION['password'] = "secret";
>
>
>Then a few pages later, they pick an option from a pull-down list, and you
>assign another variable to the session:
>
>$_SESSION['project_id'] = "45";
>
>The user clicks through a few more pages, and later wants to work on a
>different project, so you link them through (forward) to the options page.
>
>They select a new project from the pull down, so you need to overwrite the
>old project_id session var with a new one:
>
>$_SESSION['project_id'] = "74";
>
>
>Now, when they kick around through pages, they will be doing it under
>project_id 74.
>
>If you wanted to delete the project_id all together (no project), you could
>use unset().
>
>
>Now, go back, and have a look at your code, check out the logic, and I'm
>sure you'll see the mistake(s).
>
>
>As far as the "maintaining session forever" thing, I'd highly recommend
>it... it's highly insecure (walk away from your computer, someone else has
>access to everything)... besides, sessions are a temporary thing by nature,
>with garbage cleanouts, etc etc.
>
>If you really wanted to maintain state 'forever', you would have to set a
>cookie with the username and password to that person's computer, hence your
>website would 'remember them' all the time.
>
>Of course there are plenty of reasons why your shouldn't do this.  I guess
>the client should be informed of the options here:
>
>1. log in every so-often as needed (if there is lots of activity, the
>session probably won't die all day anyway), and have heaps more security
>
>2. log in once only, and have the whole system wide-open forever
>
>
>I'd pick 1 over 2 anytime.
>
>I'd also provide a logout button with either system, so that people CHOOSE
>TO DESTROY THEIR SESSION.  Personally, I log-out when I leave my desk, just
>in case.
>
>Imagine if you left a session open which disclosed everyone's pay rates in
>an office... not good for your career at all :)
>
>
>Hope this all helps,
>
>Justin French
>
>
>
>
>on 30/07/02 6:04 PM, Petre ([EMAIL PROTECTED]) wrote:
>
>>Yes, it is a forward link to the page, but as mentioned, that page
>>contains a form with the selection options, and on that form's action
>>page is where I don't see the values change, so the question should
>>probably be something like "how do I ch

Re: [PHP] Good books on sessions

2002-07-30 Thread Petre

Hi Rasmus
Thanks, I think I got it now.
Seems my problem with understanding was with the actual setting of the 
variables.
The logic dictated that the session variables should stay the same 
throughout the session unless "changed" via a form selection, so I 
simply added a

session_register("session_var");
if ($_POST["my_var"]) {
   $session_var = $_POST["my_var"];
}

to my code and it works like a charm as the $_POST var will be empty if 
it comes from one of my "back" links to the page...



Rasmus Lerdorf wrote:

>Yup, get rid of both ini_set() calls and take out the $sid=...
>and  stuff and it should simply work.
>
>On Tue, 30 Jul 2002, Petre wrote:
>
>>Thanks, will work through this immediately.
>>Just to be clear.
>>If I DO stick with your suggestion of letting PHP do the url mangling,
>>and taking your code below, I can simply remove the
>>
>>ini_set('session.use_trans_sid',false); and  from your code to make it work 
>exactly as is?
>>
>>Thanks
>>
>>
>>
>>Rasmus Lerdorf wrote:
>>
>>>The trick is to not name your form vars the same as your session vars.
>>>Keep them separate so you have full control of what ends up where.  Also,
>>>note that if you are not relying on trans_sid or cookies then don't use
>>>SID.  Call session_id() explicitly to get the session id.  So, a quick
>>>little mockup to illustrate this.
>>>
>>>login.php:
>>>>>ini_set('session.use_cookies',false);
>>>ini_set('session.use_trans_sid',false);
>>>session_start();
>>>$sid = session_name().'='.session_id();
>>>session_register('username');
>>>$username = 'petre';
>>>?>
>>>Next Page
>>>
>>>page1.php:
>>>>>ini_set('session.use_cookies',false);
>>>ini_set('session.use_trans_sid',false);
>>>session_start();
>>>$sid = session_name().'='.session_id();
>>>?>
>>>
>>>
>>>
>>>
>>>page2.php:
>>>>>ini_set('session.use_cookies',false);
>>>ini_set('session.use_trans_sid',false);
>>>session_start();
>>>$sid = session_name().'='.session_id();
>>>session_register('foo');
>>>$foo = $_POST['form_foo'];
>>>echo "You entered $foo\n";
>>>?>
>>>Back
>>>
>>>
>>>I am ini_setting on each page to force PHP to not do trans-sid/cookies.
>>>Would be easier to simply turn these off in the php.ini file.
>>>
>>>When you hit the back link, $_SESSION['foo'] will exist on page1.php and
>>>the form will get filled in with the previous value.  You can then change
>>>it, hit enter again and the session value will take on the new submitted
>>>value because I have decoupled the form data from the session data and I
>>>set the session var in page2.php.
>>>
>>>There are other ways to do this, but this is probably the easiest method
>>>to understand.  Play with this simple example until you understand how it
>>>works.
>>>
>>>But again, I'd suggest letting PHP do session id handling for you by
>>>letting it default to cookies and fall back to url mangling in the few
>>>cases where cookies are turned off.
>>>
>>>-Rasmus
>>>
>>>On Tue, 30 Jul 2002, Petre wrote:
>>>
>>>>Yes, it is a forward link to the page, but as mentioned, that page
>>>>contains a form with the selection options, and on that form's action
>>>>page is where I don't see the values change, so the question should
>>>>probably be something like "how do I change the value in the session_var
>>>>with the newly selected value?
>>>>And oh, I almost forgot:
>>>>Due to that fact that this type of app doesn't really have a logical end
>>>>page, I cannot issue a session_destroy() anywhere logically ( except
>>>>using a logout button), but that's not going to ensure that people use it...
>>>>I would ideally like to have this "app" run on an intranet, where people
>>>>will most probably have this app open indefinately, and thus  I also
>>>>battle with my logic of keeping a session alive.
>>>>
>>>>Thanks
>>>>.
>>>>
>>>>Rasmus Lerdorf wrote:
>>>>
>>>>>Well, how exactly do you implement the back button?  

[PHP] Disabling Browser "BACK" button

2002-07-31 Thread Petre

HI
Is there a way I can disable the client's browser back button, forcing 
them to use the navigation I built into the page?
Ideally, when they try to press "BACK" on browser, a popup asking them 
to use the navigation instead would win first prize.

The reason I'm asking is again to do with sessions, I have an app 
running 100% now without using cookies, but if the user hits BACK and 
ignores the expire warning, the app produces unwanted results ( adds 
form data again to the db etc.)
Just want to patch the holes.

Maybe write my own little browser that has no back button??



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




Re: [PHP] Disabling Browser "BACK" button

2002-07-31 Thread Petre

Well, OK, then, How do you  design the app NOT to allow the form to POST 
again when the user hits "BACK"

Martin Clifford wrote:

>There is never a way to disable back, forward, home, etc buttons.  They all have 
>shortcuts that will ALWAYS work, so there's really no point.  Additionally, it's all 
>nice and good that your site works fine without using cookies, and don't take this 
>offensively, but if the client cannot use the back button without getting mishapen 
>results, then it doesn't sound as if the site is designed very efficiently.
>
>Just my opinion.
>
>Martin Clifford
>Homepage: http://www.completesource.net
>Developer's Forums: http://www.completesource.net/forums/
>
>
>>>>Petre <[EMAIL PROTECTED]> 07/31/02 01:16PM >>>
>>>>
>HI
>Is there a way I can disable the client's browser back button, forcing 
>them to use the navigation I built into the page?
>Ideally, when they try to press "BACK" on browser, a popup asking them 
>to use the navigation instead would win first prize.
>
>The reason I'm asking is again to do with sessions, I have an app 
>running 100% now without using cookies, but if the user hits BACK and 
>ignores the expire warning, the app produces unwanted results ( adds 
>form data again to the db etc.)
>Just want to patch the holes.
>
>Maybe write my own little browser that has no back button??
>
>
>



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




Re: [PHP] Disabling Browser "BACK" button

2002-07-31 Thread Petre

I hear you, but how do I know if the POST comes from a valid form 
submit, or from a "back" ? I cannot simply unset the $_POST vars, as 
that will prevent anything from being posted correctly, right?


César Aracena wrote:

>I think that would be easy just by UNSETTING or emptying the variables
>that the form passed after they are processed. Do I make sence?
>
>César
>
>>-Original Message-
>>From: Petre [mailto:[EMAIL PROTECTED]]
>>Sent: Wednesday, July 31, 2002 2:43 PM
>>To: Martin Clifford
>>Cc: php-general
>>Subject: Re: [PHP] Disabling Browser "BACK" button
>>
>>Well, OK, then, How do you  design the app NOT to allow the form to
>>
>POST
>
>>again when the user hits "BACK"
>>
>>Martin Clifford wrote:
>>
>>>There is never a way to disable back, forward, home, etc buttons.
>>>
>They
>
>>all have shortcuts that will ALWAYS work, so there's really no point.
>>Additionally, it's all nice and good that your site works fine without
>>using cookies, and don't take this offensively, but if the client
>>
>cannot
>
>>use the back button without getting mishapen results, then it doesn't
>>sound as if the site is designed very efficiently.
>>
>>>Just my opinion.
>>>
>>>Martin Clifford
>>>Homepage: http://www.completesource.net
>>>Developer's Forums: http://www.completesource.net/forums/
>>>
>>>
>>>>>>Petre <[EMAIL PROTECTED]> 07/31/02 01:16PM >>>
>>>>>>
>>>HI
>>>Is there a way I can disable the client's browser back button,
>>>
>forcing
>
>>>them to use the navigation I built into the page?
>>>Ideally, when they try to press "BACK" on browser, a popup asking
>>>
>them
>
>>>to use the navigation instead would win first prize.
>>>
>>>The reason I'm asking is again to do with sessions, I have an app
>>>running 100% now without using cookies, but if the user hits BACK and
>>>ignores the expire warning, the app produces unwanted results ( adds
>>>form data again to the db etc.)
>>>Just want to patch the holes.
>>>
>>>Maybe write my own little browser that has no back button??
>>>
>>>
>>>
>>
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>



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




Re: [PHP] Disabling Browser "BACK" button

2002-07-31 Thread Petre

Exactly.
The only way I've seen that this can be prevented is if the form action 
is PHP_SELF, so, you call the page onto itself and use a isset($submit), 
but I have reasons for not going that route, one being that I have 
already have a navigation laid out, and changing that will be a nightmare!


Chris Boget wrote:

>>Page1 (fill in data)->Page2(write data, instant redirect to p1,
>>unless dies from php/mysql) 
>>Then the only way to repost, is to push the forward button.
>>
>
>Unless, of course, they hit the "Submit" button again and I think
>that was the point the original poster was getting at.  If the user
>cannot hit the back button, they cannot hit submit again.
>
>Chris
>
>



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




Re: [PHP] StripSlashes Problem

2002-08-02 Thread Petre

I would suggest you rather do the following ( over and above the 
htmlentities as already suggested )

In stead of doing
echo " ";
to rather
echo '';

The reason is; there is a difference between echo 'stuff' ; and echo 
"stuff";
The first (single quotes) is treated as literal content, ie, PHP justs 
echo's, does no parsing, while the double-quotes means PHP will look at 
the content between the quotes and parse any variables etc.
So, if you are not echoing anything that needs to be parsed, use single 
quotes.

eg.
';
echo "$var";
?>
produses:

$var
testing

It just saves on overhead, and in your case, you would not have run into 
this problem...




Mark Colvin wrote:

>John,
>
>Thank you for your reply. My magic_quotes_runtime is set to 'Off'. As you
>said, I shouldn't have to use StripSlashes but would I still need to use
>AddSlashes when inserting/updating? I can see the slashes in the database
>when I look at the tables but I am fairly sure that I do not add slashes
>twice? Are they being added automatically somewhere as a result of a setting
>in the php.ini file?
>With regards to my use of mysql_result as opposed to mysql_fetch_*
>functions, I was ignorant of the performance hit and I will now re think
>around my database code.
>
>
>
>
>This e-mail is intended for the recipient only and
>may contain confidential information. If you are
>not the intended recipient then you should reply
>to the sender and take no further ation based
>upon the content of the message.
>Internet e-mails are not necessarily secure and
>CCM Limited does not accept any responsibility
>for changes made to this message. 
>Although checks have been made to ensure this
>message and any attchments are free from viruses
>the recipient should ensure that this is the case.
>
>



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




Re: [PHP] No Idea - Comparing Lines

2003-01-06 Thread Petre Agenbag
When you read the first line, split the data into it's components , then
assign each value to a variable.
Call them:
$octet_1,$unix_time_1 etc.
Now, start the loop.
Inside the loop, read the next line, assign to $octet_2, $unix_time_2
etc.
Do your calculations ( $answer = $octet_2 - $octet_1 etc. )
Now, before exiting the loop:
$octet_1 = $octet_2;
$unix_time_1 = $unix_time_1;
etc

 
On Mon, 2003-01-06 at 15:51, Christopher J. Crane wrote:
> Ok, this is the first time I will post a message without a line of code. I
> am not sure how to go about this task. So I will describe it and maybe
> someone will have some thoughts.
> 
> I use PHP to connect to our many routers and get data using snmp. I have
> written a script that refreshes itself every 10 secs. It writes the data to
> a text file. The key element of this data is the Octet counters, or the
> amount of data that has been transfered both in and out. To keep it simple,
> I will only talk about outs. In order to find the amount od data being
> transfered, I have to compare two lines. Then run a calculation on that and
> then push that data into an array to plot on a chart later on.
> 
> Here is an example of the file the data is written to:
> OctetsIn:4300492881|OctetsOut:4300544503|UnixTime:1041629017
> OctetsIn:4305184236|OctetsOut:4305234971|UnixTime:1041629031
> OctetsIn:4308716675|OctetsOut:4308782481|UnixTime:1041629044
> OctetsIn:4312595737|OctetsOut:4312685815|UnixTime:1041629058
> OctetsIn:4315910414|OctetsOut:4315961443|UnixTime:1041629072
> OctetsIn:4318948400|OctetsOut:4318975102|UnixTime:1041629085
> OctetsIn:4322040239|OctetsOut:4322091605|UnixTime:1041629098
> OctetsIn:4324981522|OctetsOut:4325033235|UnixTime:1041629111
> OctetsIn:4327971528|OctetsOut:4328029496|UnixTime:1041629125
> OctetsIn:4332318792|OctetsOut:4332379277|UnixTime:1041629138
> OctetsIn:4335594241|OctetsOut:4335635318|UnixTime:1041629153
> OctetsIn:4339008729|OctetsOut:4339048246|UnixTime:1041629166
> OctetsIn:4342539875|OctetsOut:4342591776|UnixTime:1041629180
> OctetsIn:4346070439|OctetsOut:4346127821|UnixTime:1041629193
> OctetsIn:4350288360|OctetsOut:4350355417|UnixTime:1041629206
> 
> I can open the file and read the contents line by line
> split up but the delimiters and get the data I needbut this is what has
> to happen.
> If PHP is on line 1, do nothing (it's needs two lines to compare against)
> 
> If it's on line 2, then subtract Line 1, OctetsOut from Line Line 2
> OctetsOut. Then do the same with the UnixTime. Now run a calculation on that
> data and push that into an array as the first data point. Now move on, with
> a loop I would assume, and do the same for lines 2 and 3, and so on, until
> we reach the end.
> 
> There could be 5 lines or 500 lines.
> 
> I can loop through the file and do everything, the biggest problem I am
> having is getting the data on the line PHP is currently on, and then
> subtracting the line prior to it. I just can't seem to get a grasp on it.
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




RE: [PHP] PHP sendmail configuration

2003-01-07 Thread Petre Agenbag
The problem you are having took me a while to grasp. Basically, what
happens is that sendmail sends the mail as the user php/apache was
installed as (usually nobody@ or apache@ yourdomain.com).
Setting the Return-Path does not work, as you cannot override the
Return-Path set by the server in this way, that's why messages bounce to
your root account when sent with a php mail() function. If you only host
one domain on a server, you can fix this by editing the sendmail.cf file
and setting the Return-Path: to something more meaningful: However, most
people don't have the luxury of having a "one domain" hosting solution.

Your only other option is to invoke sendmail with the -f switch:
sendmail -f sender@address recipient@address  richard check your php.ini & the mail stuff in there .. it's most likely
> using the address either there or ur web server config file
> 
> > -Original Message-
> > From: Richard Baskett [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, 7 January 2003 10:49 AM
> > To: PHP General
> > Subject: [PHP] PHP sendmail configuration
> >
> >
> > Ok I know it's off topic, but I've been working on this for over
> > 5 hours now
> > and I almost have it configured, but something is definitely wrong!
> > Basically I can send email using sendmail by this command:
> >
> > echo "Just a test" | mail -s "test" [EMAIL PROTECTED]
> >
> > Now [EMAIL PROTECTED] receives the email, but the From address is
> > [EMAIL PROTECTED] and I have no idea where it is getting that
> > address from!  Does anyone know how I can change that from address?
> >
> > And what would stop the above command from delivering to certain
> > valid email
> > addresses?
> >
> > This is definitely causing problems with my php server also when trying to
> > send emails...
> >
> > Rick
> >
> > "Only a life lived for others is worth living." - Albert Einstein
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




RE: [PHP] Dreaded Return-Path and mail()

2003-01-07 Thread Petre Agenbag
Almost exactly the same question as the message with subject: Sendmail
configuration

The problem you are having took me a while to grasp. Basically, what
happens is that sendmail sends the mail as the user php/apache was
installed as (usually nobody@ or apache@ yourdomain.com).
Setting the Return-Path does not work, as you cannot override the
Return-Path set by the server in this way, that's why messages bounce to
your root account when sent with a php mail() function. If you only host
one domain on a server, you can fix this by editing the sendmail.cf file
and setting the Return-Path: to something more meaningful: However, most
people don't have the luxury of having a "one domain" hosting solution.

Your only other option is to invoke sendmail with the -f switch:
sendmail -f sender@address recipient@address  Hmm... I would expect that your sendmail.cf (if you are using sendmail)
> hasn't got
> your webserver (running as eg www or apache etc) in it's trusted users
> file / listing.
> 
> 
> 
> HiTCHO has Spoken! 
> Timothy Hitchens (HiTCHO)
> [EMAIL PROTECTED] 
> 
> > -Original Message-
> > From: David T-G [mailto:[EMAIL PROTECTED]] 
> > Sent: Tuesday, 7 January 2003 10:34 AM
> > To: PHP General list
> > Cc: Monty
> > Subject: Re: [PHP] Dreaded Return-Path and mail()
> > 
> > 
> > Monty --
> > 
> > ...and then Monty said...
> > % 
> > % Okay, I've read just about everything on the Internet about 
> > how the change % the Return-Path header in an e-mail sent 
> > using mail(), but, I STILL can't % get it to work. All e-mail 
> > sent via PHP says Return-Path: [EMAIL PROTECTED] % and 
> > Received: (from nobody@localhost).
> > 
> > How interesting.
> > 
> > What do you get if you put
> > 
> >   $to = "[EMAIL PROTECTED]" ;
> >   $subj = "here is a subject" ;
> >   $body = "this is the message body" ;
> >   $hdrs = "From: [EMAIL PROTECTED]\r\nReturn-Path: 
> > [EMAIL PROTECTED]" ;
> > 
> >   mail($to,$subj,$body,$hdrs) ;
> > 
> > in a php script and execute it?  If it doesn't work, what do 
> > the mail server lots on your web server say?  I just tested 
> > this code on my box and it worked, so if you have problems 
> > then you can figure it's your mail setup and not your code.  
> > If it works, expand from there in small steps :-)
> > 
> > 
> > HTH & HAND
> > 
> > :-D
> > -- 
> > David T-G  * There is too much animal courage in 
> > (play) [EMAIL PROTECTED] * society and not sufficient 
> > moral courage.
> > (work) [EMAIL PROTECTED]  -- Mary Baker Eddy, 
> > "Science and Health"
> > http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf 
> > Qrprapl Npg!
> > 
> > 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




Re: [PHP] Mail Function Parameters

2003-01-23 Thread Petre Agenbag
You have to use sendmail with the -f flag. 
I have written a small test util to do this:




On Thu, 2003-01-23 at 16:12, Adam Voigt wrote:
> I have a site with a PHP auto-mailer where the owner of the site gets a
> report
> generated from the DB, it all works fine, except his server has spam
> filtering enabled
> so the FROM header in my PHP-Generated email, which says
> "apache@hostname"
> doesn't work because what the hostname is set to, isn't resolveable
> outside our network.
> Now I know I can just set the servers hostname to a valid DNS name, but
> this brings
> up another problem, even though I'm manually setting the "From" and
> "Reply-to" headers
> in the PHP mail command (the last parameter), when the email's are
> listed in his box, it works,
> if you open the headers in the email near the very top it still says
> "From: apache@hostname" and a little ways below it says the From and
> Reply-to I set.
> 
> So, is there anyway to override the top From which says apache@hostname?
> Maybe
> setting additional parameters on my sendmail command line in the
> php.ini? Any ideas?
> I appreciate it.
> 
> -- 
> Adam Voigt ([EMAIL PROTECTED])
> The Cryptocomm Group
> My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc



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




[PHP] best way to save form data on user side

2003-01-28 Thread Petre Agenbag
Hi
I have a rather annoying problem regarding forms. 
I have built an app that allows the users to fill in a rather large form
(much like a claim form) and then have the data pumped into a mysql db.
The problem is: the users want to be able to "save" their forms on their
systems as a) backup/proof that they have filled it in and b) for their
records for future use and c) the hope is that it would also allow for a
reliable method to complete the form off-line and then submit it when
online again.

So, I'm not sure what the best way is to tackle this situation. My gutt
says it would need some kind of client stand alone app, but I wouldn't
want to go there unless I am proven beyond reasonable doubt that it is
the only way.

The users are mostly in computer limbo, and if they had their way, they
would want to use "Word or Excel" to complete the forms, save it to
their hard drive and "click to send it away"...

Help!, Please?!






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




RE: [PHP] best way to save form data on user side

2003-01-28 Thread Petre Agenbag
Hi Bryan

Thanks for the suggestions.
Can you elaborate on the pdf option? Wouldn't that mean the users would
need a copy of adobe acrobat writer?
 
On Tue, 2003-01-28 at 21:53, Bryan Brannigan wrote:
> 3 choices as I see it..
> 
> a) create a PDF for download
> b) let the users create the form in Excel and then figure out a way to
> import that into your database using a webapp
> c) client side app :(
> 
> > -Original Message-
> > From: Petre Agenbag [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, January 28, 2003 2:35 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] best way to save form data on user side
> > 
> > 
> > Hi
> > I have a rather annoying problem regarding forms. 
> > I have built an app that allows the users to fill in a rather 
> > large form
> > (much like a claim form) and then have the data pumped into a 
> > mysql db.
> > The problem is: the users want to be able to "save" their 
> > forms on their
> > systems as a) backup/proof that they have filled it in and b) 
> > for their
> > records for future use and c) the hope is that it would also 
> > allow for a
> > reliable method to complete the form off-line and then submit it when
> > online again.
> > 
> > So, I'm not sure what the best way is to tackle this 
> > situation. My gutt
> > says it would need some kind of client stand alone app, but I wouldn't
> > want to go there unless I am proven beyond reasonable doubt that it is
> > the only way.
> > 
> > The users are mostly in computer limbo, and if they had their 
> > way, they
> > would want to use "Word or Excel" to complete the forms, save it to
> > their hard drive and "click to send it away"...
> > 
> > Help!, Please?!
> > 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 



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




Re: [PHP] best way to save form data on user side

2003-01-28 Thread Petre Agenbag
Hi Chris

On Tue, 2003-01-28 at 22:09, Chris Shiflett wrote:
> --- Petre Agenbag <[EMAIL PROTECTED]> wrote:
> > I have a rather annoying problem regarding forms. 
> > I have built an app that allows the users to fill
> > in a rather large form (much like a claim form)
> > and then have the data pumped into a mysql db.
> > The problem is: the users want to be able to
> > "save" their forms on their systems as a)
> > backup/proof that they have filled it in and b)
> > for their records for future use and c) the hope
> > is that it would also allow for a reliable method
> > to complete the form off-line and then submit it
> > when online again.
> 
> Well, this sounds like a bad idea in general, but if you
> have no choice in the matter, I suppose cookies can fulfill
> the need.
> 
> Anything you implement like this is going to lessen the
> security of the data, because rather than the client
> sending it to you once, you are going to expose it over the
> Internet several times. If this risk is acceptable for
> whatever reason, then cookies are probably no less secure
> for this data than anything else.
> 
> Normally, I would highly recommend *not* storing client
> data on cookies, because that opens you up to several types
> of attacks, but you can accomplish what you want to do with
> this method. Only "punish" those who want this feature by
> setting these cookies only for those who choose to save
> this data locally. You could help the situation by
> encrypting the data in your cookies, so that only
> presentation attacks are a concern, but your users wouldn't
> be able to easily look at their data as verification of
> anything.
> 
> My recommendation is to leverage your position as the
> technical expert to advise a more proper solution, one that
> you agree to, not them. They should not be consulted
> regarding application design unless they have experience
> with it. Rather, they should be describing their needs and
> let you (or the technical lead / project manager) do the
> technical design.
This is exactly what I'm looking to do; but my problem remains: I don't
know what the best solution is.
The problem is clear: the users actually need an electronic copy of the
data they submit; they must revisit certain issues annually, and would
need to access the data they submitted the previous year; either for
review purposes, or to make the new submission a speedy matter of simply
changing the details that are different from last year.
It's much like a normal office scenario: each person works on Word docs
that need to be shared with others, yet needs to be editable and must be
saved etc, BUT the difference here is that the data of all the
collective sources must be entered into a central db. So the "non
technical" solution would be for the users to do the forms in "word",
then fax it to the central office, where you have a temp type the data
into the db... we can't have that now...
Any ideas?

PS, I don't think cookies are going to do this. Remember, the user needs
to be able to access and re-submit the form at any stage.
> 
> Good luck to you.
> 
> Chris



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




Re: [PHP] Echo # problem

2003-02-12 Thread Petre Agenbag
Two ways:
a) echo "blabla # $blabla";

or 
b) echo 'blabla # '.$blabla;

The # character must just be inside the echo's quotes.



On Wed, 2003-02-12 at 13:36, Paul McQ wrote:
> I am writing an application in which I need to redirect to an url using the
> Header function.  This redirection must include the # character so that the
> user is taken to the relevant part of the following page.
> 
> PHP sees the # as a comment no matter what I do and therefore the
> redirection doesn't work as I would like.  Does anyone know how you can use
> PHP to echo the # character?
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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




[PHP] ftp file to client machine

2003-02-13 Thread Petre Agenbag
HI
I am trying to do the following:

I have an ftp server configured, but instead of the user having to use
an ftp client, I'd like them to use the browser: So I'm trying to make a
mini web-based ftp client. Idea is to get their username and password (
and maybe the ftp address as well?) and to then have php log into the
server and list the contents of the folder (no need to handel subfolders
etc.). Then I would want them to be able to click on the file to
download it.

I have done the first part with no problem as per below:

";
die;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}

// get dir listing
$file_list = ftp_nlist($conn_id,"");

foreach ($file_list as $num=>$val) {
echo "$val 
";
}

ftp_close($conn_id);
?>


But I am baffeled for the rest, ie, what to do on the download.ftp page.
First I tried the ftp_get() with the $file used as the local and remote
files, but it seems that that will not download the file to the client
machine, but rather to the server itself.
So, how can I have the file download to the client's machine ( ps, the
files are NOT inside a webfolder, so I cannot simply make links to them,
and yes, it is done for security reasons; basically I am trusting/using
vsftp's security instead of having to devise my own method..)

Please point out my obvious lack in knowledge of these matters.

Thanks





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




[PHP] encrypt passwords on URL

2003-02-13 Thread Petre Agenbag
HI
This is a sort-of continuation on my previous question regarding being
able to "puch" a file to a client machine using PHP.

I have created a login page that connects to the ftp server and then
lists the contents of the folder. My original hope was that I could
somehow have the user just click on the file he want's to download it,
but since the files are not in a webfolder, I couldn't just make links
to them...

Another scenraio that could work is to simply have the user go to

ftp://username:[EMAIL PROTECTED]

BUT, that leaves the password on the URL and the data is sensitive. So,
my question:

Can I encrypt the password with PHP and then generate the link as above
but with the encrypted password?







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




[PHP] script to check if server is up

2003-02-18 Thread Petre Agenbag
Hi
I have two servers on two different networks. I would like to implement
some sort of a watchdog application between the two to inform me should
either of the machines go down or has a connection problem.
I was thinking along the line of using a PHP script running from cron on
an hourly basis to "ping" the server as well as another server such as
google.com (they seem to be always up) and to only raise the alarm when
google can be reached, but NOT the other server.

My only problem is with the actual recognition of a "failed" ping, or
for that matter a successful one?

Can anyone give me some brain food as to the code for detecting a
up/down connection?

pseudo code:

make connection with server1
get result of connection_server1
make connection with google.com
get result of connection_google

if connection_google && !connection_server1
sms me
else
chill out


and a plus would be to do this ONLY if the result of the next cron-run
is the same, ie, don't sms me if the problem has been fixed within an
hour.
I just don';t know what to use to "make connection" and "get result of
connection"

Thanks.






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




[PHP] reminder mail when date is within a month of today.

2003-02-25 Thread Petre Agenbag
HI
I'm having a bad thinking day. I know it's going to be a very easy
solution, but please humour me.
I have a mysql table with a bunch of subscribers and the date that they
subscribed.
I want to query the table to find all the subscribers who will come up
for renewal within the current month. So, each time I access the page,
it must generate a table with those who's subscription is going to
expire in this month, as well as those who might already be past the
renewal date.
I can handle the generation of the table and all, I'm just not coping
with the query string.

Thanks





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



[PHP] reminder mail cont.

2003-02-25 Thread Petre Agenbag
Sorry, forgot to mention, the subscription is annual, so the
subscription date I have for the subscriber is lets say 2002-02-28 , so
I want to "capture" that he will need to renew by 2003-02-28 as well as
all people past today's date...





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



Re: [PHP] reminder mail when date is within a month of today.

2003-02-25 Thread Petre Agenbag
Thanks for the quick response.
Just to clarify:
$query=mysql_query("select * from TableName where  
month(FieldNameForDate)=month(FieldOfDate)+1");

Which one of the dates in your query is the system's date and which is
the one from the db?
Also, I need not just the ones that are true, but also the ones that are
already past, so I presume you should have a > then?



On Tue, 2003-02-25 at 12:10, Sunfire wrote:
> well...
> 
> $query=mysql_query("select * from TableName where
> month(FieldNameForDate)=month(FieldOfDate)+1");
> 
> that should do it.. or at least it does on mine anyways...
> 
> 
> - Original Message -
> From: "Petre Agenbag" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, February 25, 2003 4:07 AM
> Subject: [PHP] reminder mail when date is within a month of today.
> 
> 
> > HI
> > I'm having a bad thinking day. I know it's going to be a very easy
> > solution, but please humour me.
> > I have a mysql table with a bunch of subscribers and the date that they
> > subscribed.
> > I want to query the table to find all the subscribers who will come up
> > for renewal within the current month. So, each time I access the page,
> > it must generate a table with those who's subscription is going to
> > expire in this month, as well as those who might already be past the
> > renewal date.
> > I can handle the generation of the table and all, I'm just not coping
> > with the query string.
> >
> > Thanks
> >
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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



Re: [PHP] [mysq] help with displaying table {off Subject}

2003-03-03 Thread Petre Agenbag
I presume you are talking about phpMyAdmin here.

The Browse link only works when there are entries in the tables, ie., it
won't work on empty table.
You must first insert data into the tables, and for that you uise the
INSERT link.
You can change the tables by using the PROPERTIES link.


On Tue, 2003-03-04 at 09:18, Karl James wrote:
> hey guys im trying to figure out why the browse 
> link wont work in mysql is there anything 
> special to edit so that i can view the tables so 
> i can edit them and add value
> 
> 
> 
> 
> ultimatefootballleague.com/index.php
> [EMAIL PROTECTED]
>  
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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



Re: [PHP] Form input security

2003-03-09 Thread Petre Agenbag
It all depends on what you will do with the data... The use will dictate
the level of cleaning up.
You MUST clean it up for DB entries as you mentioned, but if you are
only going to e-mail the contents "as-is" to yourself etc, then cleaning
up the data becomes of lesser importance.

On Sun, 2003-03-09 at 21:18, Chris Cook wrote:
> Hello all,
> 
> When using forms, when do I have to worry about cleaning up user data? I 
> know to use escapeshellarg() when using system functions, but how about when 
> using the user data for database inserts? Also, if I do not insert the data 
> into the database or use any system commands, do I still need to clean the 
> data?
> 
> Thanks,
> Chris
> 
> 
> 
> 
> _
> Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
> http://join.msn.com/?page=features/featuredemail
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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



Re: [PHP] session

2003-03-10 Thread Petre Agenbag
Garbage collection is a random process. You can however set the
probability of it starting on every session call in the php.ini file,
along with the elapsed time of a session variable, after which it is
considered garbage.
On my system, my probability is set to "1", meaning there is a 1% chance
of the garbage process starting when I call a new session, and my
"garbage define time" is 1440, meaning if the data is older than that
amount of seconds, then it is to be considered garbage by the next
garbage process, and hence, destroyed...

On Mon, 2003-03-10 at 15:30, Shaun van den Berg wrote:
> When does the carbadge collector start ?
> 
> Thanks
> Shaun
> 
> --
> Novtel Consulting
> Tel: +27 21 9822373
> Fax: +27 21 9815846
> Please visit our website:
> www.novtel.co.za
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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



Re: [PHP] session

2003-03-11 Thread Petre Agenbag
Well, I guess it's all about the type of application you're writing and
the kind of resources you have at your disposal...
Making garbage collection 100% will basically cause the system to go
through the steps of determining what should be disposed and what not,
and that would be determined by the time-out setting... So making it
100% and keeping the time to 24 minutes would mean that a session
wouldn't last much longer than 24 minutes on your system. Is that good?
Only you will know; if your application demands long visit times for
users, then it is not a good idea, as they will find the session
destroyed after 24 minutes of use...
Running the process too often might cause some performance problems on
an average server, and leaving it for too long *could* cause memory and
disk space problems; so it's a balance really, and you should tweak the
settings to match your needs ( which you should have determined in dry
runs before going live...)

On Tue, 2003-03-11 at 09:47, Shaun van den Berg wrote:
> Hi,
> 
> What should the probability of your garbadge collector be ? is a 100% bad ,
> and how long must the max lifetime of your session variables be , the
> default is 1440 secs(24 min) , is 24 hours to much ? Thanks
> 
> Shaun
> 
> --
> Novtel Consulting
> Tel: +27 21 9822373
> Fax: +27 21 9815846
> Please visit our website:
> www.novtel.co.za
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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



Re: [PHP] PHP Books

2003-03-12 Thread Petre Agenbag
Hi Chris

The first book, Teach Yourself PHP and MySQL in 24 Hrs: I got that one
myself, but it tends to gather dust nowadays...
It was very useful in the beginning with learning the basix syntax etc,
but I quickly outgrew it, and rarely use it at all, not even for
reference.

I got the book called PHP and MySQL web development by Luke Welling and
Laura Thompson. This is a great book, I sleep with it under my pillow
and use it regularly as a reference to examples. I'd say it's basic
enough to start out with, yet advanced enough to keep you interested as
you grow more adept.

BUT, I must admit, at this point, the single resource I use the most wrt
PHP is the manual that comes with PHP, great reference to functions etc,
but of course, you need to know of these functions before you can just
refer to them... So, I would still suggest getting the Luke Welling et
al book. There's a new edition on Amazon for $35, plus shipping of about
$25. The last time I ordered, the Rand was much weaker, and the VAT was
about R55, bringing my total to about R800, but it's well worth it...

There is also a new book by Rasmus Lerdorf and it's cheaper than the
book I mention, unfortunately I don't have insight into that book, and
what would the guy that wrote PHP know about it anyway heh? ;p


On Wed, 2003-03-12 at 11:45, Chris Blake wrote:
> Greetings learned PHP(eople),
> 
> Can anyone offer comment on the following books on PHP.
> I`m in the early stages of PHP and am looking for a suitable guide to
> begin with.
> =
> Sams Teach Yourself PHP MYSQL and Apache in 24 Hours
> Publisher:  Sams Publishing
> ISBN:  067232489X
> Publishing Date:  2003
> Format:  Paperback
> =
> PHP BIBLE
> Author:  Tim Converse
> Publisher:  WILEY
> ISBN:  0764549553
> Pages:  875
> Format:  Paperback
> ==
> Beginner's Guides (Osborne): PHP 4: A Beginner's Guide
> Author:  Bill McCarty and William McCarty
> Publisher:  MCGRAW HILL
> ISBN:  0072133716
> Publishing Date:  2001
> Pages:  544
> Format:  Paperback
> 
> 
> If anyone has used these manuals I would appreciate your input as I
> don`t wanna spend a fortune on a manual and then find out it`s [EMAIL PROTECTED]
> -- 
> Chris Blake
> Office : (011) 782-0840
> Cell : 083 985 0379
> Your mouse has moved. Windows must be restarted for the change to take
> effect. Reboot now? [ OK ]
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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



[PHP] XML

2003-07-08 Thread Petre Agenbag
Hi List

Firstly, this question is arguable more about XML than PHP, but they are
interlinked, so I hope it is "topical" for this list.

Firstly, Where I come from:

I am VERY comfortable with PHP/MySQL on Linux and understand all those
concepts.

Now I'm trying to see the benefits of XML, and quite frankly, I just
cannot see why one would want to use it...

Anyway, I don't want to start a discussion on that from.

I have done extensive reading on XML/XSL(XSLT : XHTML), DTD and XML
parsing on browser and server side.

I arguable still don't have a 100% understanding of exactly how things
fit together, but the little bit I think I got so far is:

I would use an XML doc to package my data in a structure.
This XML file is "useless" on it's own, and good for transporting data
to another app or client.
Should I need to do something with the data, I would look at XSL and in
particular XSLT in order to convert the XML into XHTML so a browser can
display the data ( so we can safely assume that I am only interested in
the web applications of XML)

This is where I'm starting to get a headache, because now it seems that
there are browser issues wrt XSL, and one also have the added choice of
parsing the XML with the browser or on server level.

For me, parsing it on browser level must be a no-no, as I would assume
that it's would take alot of effort to find out what type of browser the
client has, then load the appropriate XSL file for that browser.

So, I'm here, with the server side XML parsing in mind.

Now on M$ systems, it seems that IIS has built in ActiveX XMLDOM parsing
built in, and you can "easily" parse the XML document by using ASP etc.

So can I assume that this is also true with PHP/Apache, ie, Apache has a
built in XML parser and I can use PHP fnuctions to parse my XML file on
the server side and thus "pump" out XHTML that is compatible with all
past and future browsers?

Also, what is the procedure that most of you (members of the PHP lists)
follow when dealing with XML. ie, do you go for the client side parsing
or do you do server side parsing. And how do you decide when to use XML
and when to stick to trusty old PHP/MySQL? ( Sorry,  know this is
probably the dumbest question I can ask, but I really battle to see when
to use it, or rather WHY I should use it seeing that the data is
arguably "static" in nature ( I would either get the XML file from
somewhere else, or I would generate it from some source and pass it on,
effectively creating a little data island/snapshot of the actual data at
a point in time?)

Thanks for any input.





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



RE: [PHP] XML

2003-07-09 Thread Petre Agenbag
Hi List

Firstly, thanks for the replies and mostly for the accommodating
attitude to this, arguable non-PHP subject.

I don't want this thread to become a flame war on why one should use
XML, or why not.
I do have personal issues wrt XML and the way it works, and although I
cannot *yet* see the need, it doesn't mean that there isn't one. 

My original post should have made this clear, but it seems it didn't.

I have laid to rest my reservations wrt XML, and am more interested in
understanding the entire process in the hope that 1) I will "see" the
need, and 2) understand how all those XML jargon fits together ( XML,
XSL, XSLT, DTD, DOMXML, phew...)

That was why I gave a brief summary of where I am atm wrt understanding
what it is.

What I still don't know much about, and at last, this is where the PHP
comes in, is once I have this XML file, whereto from here using PHP (
you see, it should be clear that I want to use PHP as my "one and only"
trusty tool.

As I stated, and correct me, the XML file contains the structured data,
and the XSL file contains the "look and feel" and the XSL file is
written in XSLT language.

My understanding is further that, again focused only on web applications
here, one would have an XML file in your web folder, along with it's XSL
file. These files would be "linked" by means of calls or references to
each other inside the files.

Having these two files (oh, and the dtd which can be used to verify the
XML, but doesn't seem necessary from what I can see), as I understand
it, gives the basis from where one would then parse the XML into XHTML
in order to actually "see" anything in a browser via one of two routes:
1) client side via the browser's built in XML parser -> arguably leaving
the old Netscape/IE gap wrt compatibility, or 2) server side parsing
with the built-in XML parser that comes with the webserver (IIS or
Apache in my case) -> with this approach being in my mind the "best" if
you want to make sure you don't run into browser issues.

This is where my PHP question really starts: 
On apache.org they talk about the XML support of apache etc, and in the
PHP documentation there are lots of XML functions and yet more jargon
like DOMXML etc, which is not clear for me what to do now (should I
elect to parse server side).

If someone can just give me a quick and easy "tour" on what to do and
what is needed from here to actually parse and display the contents
correctly, I should have enough to keep me busy for a while, and
hopefully help me to increase my knowledge and understanding so I won't
ask stupid questions on this list ;)


Thanks again for the input.
 


 
On Wed, 2003-07-09 at 00:36, Ray Hunter wrote:
> I see that not many sites require the use of xml/xsl(t). Many sites can
> just use html and database to accomplish 99.9% of the work.
> 
> I always suggest that when you have tons of data that you need to send
> to the user that it is a good idea. Especially now that xslt is growing
> up :)
> 
> I like to use xml and xsl for various reasons, mainly i can really
> separate the logic and presentation. All data is keep in the xml file
> and presentation in the xsl file. So when i need to make changes in the
> presentation then i only change the xsl file and never really have to
> touch the logic (php) code. This is really, really great for some sights
> that are extremely complex.
> 
> Also in php i can create standards that my xml files will follow (dtds,
> schema) and allowing me to create modules (functionality) very
> efficiently and timely.
> 
> Also as mentioned xml provides a format for transfering data. However, i
> would not use it with databases unless it is large amounts of data.
> However, i have used xml for creating sql queries and setting up
> configureation files which are extremely reliabe.
> 
> --
> BigDog
> 
> 
> 
> On Tue, 2003-07-08 at 15:51, Jeff Harris wrote:
> > |-Original Message-
> > |From: Petre Agenbag [mailto:[EMAIL PROTECTED]
> > |Sent: Tuesday, July 08, 2003 6:27 AM
> > |To: [EMAIL PROTECTED]
> > |Subject: [PHP] XML
> > |
> > |
> > |Hi List
> > |
> > |Firstly, this question is arguable more about XML than PHP, but they are
> > |interlinked, so I hope it is "topical" for this list.
> > |
> > |Firstly, Where I come from:
> > |
> > |I am VERY comfortable with PHP/MySQL on Linux and understand all those
> > |concepts.
> > |
> > |Now I'm trying to see the benefits of XML, and quite frankly, I just
> > |cannot see why one would want to use it...
> > |
> > [snip]
> > 
> > On Jul 8, 2003, "Joe Harman" claimed that:
> > 
> > |Okay Petre... You have asked the

[PHP] elegant way of doing something else the last time through a loop?

2003-07-14 Thread Petre Agenbag
HI list

Is there an elegant way to know when the last time through the loop is
going to be and to do something else?


I want to search through a table by "exploding" the search string and
then compounding my own sql string by working through the array.

>From my example below, you can see I use a foreach to loop through the
array. Arguably I could first determine the amount of elements in the
array and then use a for instead of a foreach, but I'm not sure if that
will help ( will probably need a switch instead if you want to work with
the sheer array elements), however, the if statement inside the loop is
meant to "strip" out "the" and "and", meaning that it won't much help to
use that approach anyway.

Anyway, as you can see my problem lies with the SQl when the last
element is reached, then it should NOT add another "and" or "or".

My attempts at "backtracking" the $sql string/array and start writing
the end part of the string obviously fails.

Any help with my "logic", ie, how do/would you guys do this?

Thanks
 

$table_name = "test";
if ($_POST[any_all] == "any") {
$logic = "or";
}
elseif ($_POST[any_all] == "all") {
$logic = "and";
}

$string = $_POST[text];
$phrases = explode(" ", $string);

$sql = "select * from $table_name where ";

foreach ($phrases as $key=>$val) {
if (($val != "the") && ($val != "and")) {
$sql.= "name like '%$val%'  $logic";
}   
}

$length = strlen($sql);
$newlen = $length - 4;
$sql[$newlen].= " order by name";
echo $sql; 



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



Re: [PHP] elegant way of doing something else the last timethrough a loop?

2003-07-14 Thread Petre Agenbag
Sheer genius my man!

Thanks!

On Mon, 2003-07-14 at 13:38, Tom Rogers wrote:
> Hi,
> 
> Monday, July 14, 2003, 9:11:11 PM, you wrote:
> PA> HI list
> 
> PA> Is there an elegant way to know when the last time through the loop is
> PA> going to be and to do something else?
> 
> 
> PA> I want to search through a table by "exploding" the search string and
> PA> then compounding my own sql string by working through the array.
> 
> >>From my example below, you can see I use a foreach to loop through the
> PA> array. Arguably I could first determine the amount of elements in the
> PA> array and then use a for instead of a foreach, but I'm not sure if that
> PA> will help ( will probably need a switch instead if you want to work with
> PA> the sheer array elements), however, the if statement inside the loop is
> PA> meant to "strip" out "the" and "and", meaning that it won't much help to
> PA> use that approach anyway.
> 
> PA> Anyway, as you can see my problem lies with the SQl when the last
> PA> element is reached, then it should NOT add another "and" or "or".
> 
> PA> My attempts at "backtracking" the $sql string/array and start writing
> PA> the end part of the string obviously fails.
> 
> PA> Any help with my "logic", ie, how do/would you guys do this?
> 
> PA> Thanks
>  
> 
> PA> $table_name = "test";
> PA> if ($_POST[any_all] == "any") {
> PA> $logic = "or";
> PA> }
> PA> elseif ($_POST[any_all] == "all") {
> PA> $logic = "and";
> PA> }
> 
> PA> $string = $_POST[text];
> PA> $phrases = explode(" ", $string);
> 
> PA> $sql = "select * from $table_name where ";
> 
> PA> foreach ($phrases as $key=>$val) {
> PA> if (($val != "the") && ($val != "and")) {
> PA> $sql.= "name like '%$val%'  $logic";
> PA> }   
> PA> }
> 
> PA> $length = strlen($sql);
> PA> $newlen = $length - 4;
> PA> $sql[$newlen].= " order by name";
> PA> echo $sql; 
> 
> I would do this
> 
> $like = '';
> foreach ($phrases as $key=>$val) {
> if (($val != "the") && ($val != "and")) {
> if(!empty($like)) $like .= ' '.$logic.' ';
> $like.= "name like '%$val%'";
> }   
> }
> $sql .= $like;
> -- 
> regards,
> Tom
> 


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



Re: [PHP] elegant way of doing something else the last timethrough a loop? SOLVED

2003-07-14 Thread Petre Agenbag
Following works nicely for me now, thanks all!


connect("localhost","user","password","table");
$table_name = "main";
if ($_POST[any_all] == "any") {
$logic = "or";
}
elseif ($_POST[any_all] == "all") {
$logic = "and";
}
elseif ($_POST[any_all] == "exact") {
$logic = "exact";
}
$string = $_POST[text];
$phrases = explode(" ", $string);

$sql = "select * from $table_name where ";

if (($logic == "or") || ($logic == "and")) {
$temp = '';
foreach ($phrases as $key=>$val) {
if (($val != "the") && ($val != "and") && ($val != " ") && ($val !=
"")) {
if (!empty($temp)) $temp .= ' '.$logic.' ';
$temp.= "name like '%$val%' ";  
}   
}
$sql.=$temp;
} elseif ($logic == "exact") {
$sql.="name like'%$string%'";
}
$sql.= " order by name";
//echo $sql;
$db->query($sql);
$db->draw_table();
 
?>


On Mon, 2003-07-14 at 14:00, Marek Kilimajer wrote:
> I always do it this way:
> 
> $condition='';
> foreach ($phrases as $key=>$val) {
>  if (($val != "the") && ($val != "and")) {
>  $condition.= "name like '%$val%'  $logic";
>  }
> }
> $condition=substr($condition, 0, strlen($condition) - strlen($logic));
> $sql .= $condition;
> > 
> > $length = strlen($sql);
> > $newlen = $length - 4;
> > $sql[$newlen].= " order by name";
> > echo $sql; 
> > 
> > 
> > 
> 


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



RE: [PHP] elegant way of doing something else the last time through a loop? SOLVED

2003-07-15 Thread Petre Agenbag
Well, it should never be, it comes from a drop down that only has 3 options,
any, all or exact
Any caveats there?


-Original Message-
From: David Otton [mailto:[EMAIL PROTECTED]
Sent: Monday, July 14, 2003 2:58 PM
To: Petre Agenbag
Subject: Re: [PHP] elegant way of doing something else the last time
through a loop? SOLVED


On 14 Jul 2003 14:35:28 +0200, you wrote:

>if ($_POST[any_all] == "any") {
>   $logic = "or";
>}
>elseif ($_POST[any_all] == "all") {
>   $logic = "and";
>}
>elseif ($_POST[any_all] == "exact") {
>   $logic = "exact";
>}

[...]

>   if (!empty($temp)) $temp .= ' '.$logic.' ';

Consider what would happen to $logic if $_POST['any_all'] was 'xyzzy'.




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



[PHP] Help with loop inside loop and mysql queries

2003-07-16 Thread Petre Agenbag
Hi List.

I cannot see my error:

I have relation tables setup.

main
id  entity_name main_type   etc etc date_in
1   testtype1   x   y   2003-06-02
2   test2   type2   xx  yy  2003-03-11
3   test3   type1   xxx yyy 2003-02-02


type1
id_type1id  field1  field2  field3  
1   1   1st rec (1) 2003-07-07  -00-00  
2   3   1st rec (3) 2003-07-10  2003-07-12
3   1   2nd rec (1) 2003-07-13  -00-00

type2
id_type2id  field1  field2
1   2   1st rec (2) 2003-01-23
2   2   2nd rec (2) 2003-07-07

etc...


So, what I'm trying to do is this:

On a search page, the user selects a date range to view the records in
the main table.

What I want to display now on the result page (code below), is something
like this:

Date Captured   NameLast Action Date of Action
2003-02-02  test3   field3  2003-07-12
2003-03-11  test2   field2  2003-07-07
2003-06-02  testfield2  2003-07-13


In the above examples, if there are dates as record entries, then the
field_type is "date". The field_name is the "action" name, like "info
sent", "contact made" etc, so if there is a non-zero date in the field,
it means that specific "action" happened that day.


So in the code below I tried to 
1) query the table for all the entries in the data range ( for my
example, the date range was wide enough to include ALL)
2) Make sure that I have the "last" row for the specific entity by
looking for the max id in the related table matching the main table's
id.
3) Once I know that id, I query the "sub" table for all the fields in
that row.

Then I tried to run through all the fields in the result set and get the
"highest" date from that row, else fall back to the original capture
date_in in the main table (meaning that no "actions" have yet been taken
(when I enter something in the main table, it automatically enters a new
row in the $main_type table with default "zero" dates)


My problem is somewhere in the code, but I cannot see where (maybe my
logic sucks with the whole thing?)

It returns the correct stuff for the first entry, but then takes the
same for the rest (as if it's not going back to the beginning of the
loop, or not resetting the values)

I use a class that does the connect and querying to the db. I'm 100%
sure the class is correct, I'm not 100% sure if I USE it correct
though...


Any help appreciated.






include ("main_class.php");
$db = new my_db_class;
$db ->connect("localhost","user","password","db");
if ($_GET[st] == "date") {
$sql = "select * from main where (date_in > '$_POST[date_1]' and date_in
< '$_POST[date_2]') order by entity_name";
}
//echo $sql.'';
$db ->query($sql); 
if ($sql) {
echo 'Date InNameLast
ActionDate of last action'; 
while ($myrow = mysql_fetch_assoc($db->result)) {
extract($myrow);
$sql_search = "select MAX(id_$main_type) as mid from $main_type where
id = '$id'";
//echo $sql_search.'';
$db1 = new my_db_class;
$db1->query($sql_search);
$myrow_search = mysql_fetch_assoc($db1->result);
$pointer = $myrow_search[mid];
$sql_search_2 = "select * from $main_type where id_$main_type =
'$pointer'";
//echo $sql_search_2.'';
$db2 = new my_db_class;
$db2->query($sql_search_2);
$myrow_search_2 = mysql_fetch_assoc($db2->result);
$fields = mysql_num_fields($db2->result);
$test_date = "-00-00";
for ($i=0; $i < $fields; $i++) {
$type = mysql_field_type($db2->result,$i);
if ($type == "date") {
$action_name = mysql_field_name($db2->result,$i);
$val = $myrow_search_2[$action_name];
if (($val >= $test_date) && ($val != "-00-00")) {
$test_date = $val;
$XXX = $action_name;
$YYY = $test_date;
}
}
}
if (!$XXX) {
$XXX = "Original Capture";
}
if (!$YYY) {
$YYY = $date_in;
}
echo ''.$date_in.''.$entity_name.''.$XXX.''.$YYY.'';
if ((mysql_num_rows($db->result)) == "" || (mysql_num_rows($db->result)
== "0")) {
echo 'No Results Found!';
}

}
echo '';
}


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



Re: [PHP] Help with loop inside loop and mysql queries - SOLVED

2003-07-16 Thread Petre Agenbag
Grr

Needed to reset the $XXX and $YYY vars BEFORE the for loop...


Anyway, should you have nothing better to do, plz look through and see
if there is a "better" way to do this with possibly less queries made on
the db...

Ta

On Wed, 2003-07-16 at 09:25, Petre Agenbag wrote:
> Hi List.
> 
> I cannot see my error:
> 
> I have relation tables setup.
> 
> main
> identity_name main_type   etc etc date_in
> 1 testtype1   x   y   2003-06-02
> 2 test2   type2   xx  yy  2003-03-11
> 3 test3   type1   xxx yyy 2003-02-02
> 
> 
> type1
> id_type1  id  field1  field2  field3  
> 1 1   1st rec (1) 2003-07-07  -00-00  
> 2 3   1st rec (3) 2003-07-10  2003-07-12
> 3 1   2nd rec (1) 2003-07-13  -00-00
> 
> type2
> id_type2  id  field1  field2
> 1 2   1st rec (2) 2003-01-23
> 2 2   2nd rec (2) 2003-07-07
> 
> etc...
> 
> 
> So, what I'm trying to do is this:
> 
> On a search page, the user selects a date range   to view the records in
> the main table.
> 
> What I want to display now on the result page (code below), is something
> like this:
> 
> Date Captured NameLast Action Date of Action
> 2003-02-02test3   field3  2003-07-12
> 2003-03-11test2   field2  2003-07-07
> 2003-06-02testfield2  2003-07-13
> 
> 
> In the above examples, if there are dates as record entries, then the
> field_type is "date". The field_name is the "action" name, like "info
> sent", "contact made" etc, so if there is a non-zero date in the field,
> it means that specific "action" happened that day.
> 
> 
> So in the code below I tried to 
> 1) query the table for all the entries in the data range ( for my
> example, the date range was wide enough to include ALL)
> 2) Make sure that I have the "last" row for the specific entity by
> looking for the max id in the related table matching the main table's
> id.
> 3) Once I know that id, I query the "sub" table for all the fields in
> that row.
> 
> Then I tried to run through all the fields in the result set and get the
> "highest" date from that row, else fall back to the original capture
> date_in in the main table (meaning that no "actions" have yet been taken
> (when I enter something in the main table, it automatically enters a new
> row in the $main_type table with default "zero" dates)
> 
> 
> My problem is somewhere in the code, but I cannot see where (maybe my
> logic sucks with the whole thing?)
> 
> It returns the correct stuff for the first entry, but then takes the
> same for the rest (as if it's not going back to the beginning of the
> loop, or not resetting the values)
> 
> I use a class that does the connect and querying to the db. I'm 100%
> sure the class is correct, I'm not 100% sure if I USE it correct
> though...
> 
> 
> Any help appreciated.
> 
> 
> 
> 
> 
> 
> include ("main_class.php");
> $db = new my_db_class;
> $db ->connect("localhost","user","password","db");
> if ($_GET[st] == "date") {
> $sql = "select * from main where (date_in > '$_POST[date_1]' and date_in
> < '$_POST[date_2]') order by entity_name";
> }
> //echo $sql.'';
> $db ->query($sql); 
> if ($sql) {
> echo 'Date InNameLast
> ActionDate of last action'; 
> while ($myrow = mysql_fetch_assoc($db->result)) {
>   extract($myrow);
>   $sql_search = "select MAX(id_$main_type) as mid from $main_type where
> id = '$id'";
>   //echo $sql_search.'';
>   $db1 = new my_db_class;
>   $db1->query($sql_search);
>   $myrow_search = mysql_fetch_assoc($db1->result);
>   $pointer = $myrow_search[mid];
>   $sql_search_2 = "select * from $main_type where id_$main_type =
> '$pointer'";
>   //echo $sql_search_2.'';
>   $db2 = new my_db_class;
>   $db2->query($sql_search_2);
>   $myrow_search_2 = mysql_fetch_assoc($db2->result);
>   $fields = mysql_num_fields($db2->result);
>   $test_date = "-00-00";
>   for ($i=0; $i < $fields; $i++) {
>   $type = mysql_field_type($db2->result,$i);
>

Re: [PHP] elegant way of doing something else the last timethrough a loop? SOLVED

2003-07-16 Thread Petre Agenbag
Hi

Yes, I see your point.
Guess I'm way too trusting a person, should think like a criminal...

So you're basically saying I should always place sensible "default
values" in my script and then compare the $_POST vars, else stick to the
default, ie, have the $_POST overwrite your default before the script
can use it?

Petre




On Tue, 2003-07-15 at 17:39, David Otton wrote:
> On Tue, 15 Jul 2003 16:47:22 +0200, you wrote:
> 
> >Well, it should never be, it comes from a drop down that only has 3 options,
> >any, all or exact
> >Any caveats there?
> 
> "You can't trust the client". I can submit any data I want to your script,
> most easily by knocking up my own form:
> 
> http://domain.com/yourform.php";>
> 
> 
> 
> 
> In this particular case, it's no big deal - your script exits gracelessly,
> but no real harm is done. However, the same class of attack (injecting
> unexpected data into a script) can cause far more serious problems.
> 
> What I'm trying to say is that it will pay off in the future if you learn a
> defensive coding style now. Assume that all input from the outside world is
> potentially malicious.
> 
> The code we're takling about can easily be made safe:
> 
> $logic = "exact";
> if ($_POST[any_all] == "any") {
>   $logic = "or";
> } elseif ($_POST[any_all] == "all") {
>   $logic = "and";
> }
> 
> BTW, try putting
> 
> error_reporting(E_ALL);
> 
> at the top of the script to flag the string literal problem I mentioned
> originally, and see what happens if any_all isn't in the $_POST array at
> all.
> 


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



[PHP] get size of variable n bytes

2003-07-16 Thread Petre Agenbag
Hi List

Sorry, tried to find it in manual...

I'd like to query a db and and see how big the result is in bytes. How
can I do that?

Thanks


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



RE: [PHP] get size of variable n bytes

2003-07-16 Thread Petre Agenbag
Yes, well, that complicates things.

You see, I'm trying to determine the size that the $_POST variable will be
in bytes, because there is a byte limit in the php.ini file for POST
variable size, so I was hoping for something easy like bytes_size($_POST)...
Would also be handy to calculate how much memory your script will use/need.

So, you say there is no such function or no way to determine it?


-Original Message-
From: David Nicholson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 16, 2003 4:36 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] get size of variable n bytes


Hello,

This is a reply to an e-mail that you wrote on Wed, 16 Jul 2003 at 15:31,
lines prefixed by '>' were originally written by you.
> One way would be to assume that 1 character takes 1 byte to store
> so...
>   $sizeinbytes = strlen($field);

Also, this will only work with text data as numbers types, bool types etc
will be stored differently.

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

  Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
 http://www.quizsender.com/
(developed entirely in PHP)

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




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



[PHP] really no way to get byte size of variable?

2003-07-16 Thread Petre Agenbag
Hi List
Just want to make sure:

Is there no way for me to easily determine the byte size occupied by a
variable (regardless of type)?

It might be trivial, or I'm missing the point (as per usual)...

I would like to find the actual byte size that is transmitted when say a
$_POST variable is sent, or how much memory a particular variable is taking
up.

Just want to make sure. Some of the post received so far suggest that "one
character = one byte" etc, but I would love to work with something more
precise if possible, also, is a variable contains a multi-dimensional array,
would that "one character = one byte" formula still return a fair
representation?

Thanks.



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



Re: [PHP] Protecting files with PHP

2003-07-17 Thread Petre Agenbag
If you place files inside a webfolder, then they are publicly
accessible, period.

They might not be obvious, ie. you would have to guess that there are
files in a specific folder AND know the exact name of the file, but if
you do happen to guess correct, then the files are downloadable.

There are ways to still have files in "public" folders and have a
measure of extra protection, but that is up to your webserver, and not
PHP. Use .htaccess to place a username/password on the folder, or better
yet, you can use ftp, but then you place the files outside the
webfolder. PHP has built in ftp functions that would allow you to create
a pretty secure system to give access to files.

On Thu, 2003-07-17 at 15:58, Maria Garcia Suarez wrote:
> Hi there!
> 
> I'm developing an application to which you can upload
> files. Right now the destination folder of those files
> is at /public_html/files which makes them visible from
> the internet.
> 
> I thought of putting that ./files/ folder outside the
> ./public_html/ folder and make those files be only
> accessible via PHP pages (if the pages doesn't display
> a link to that folder there's no way to download the
> file). But, there's any way to keep on having the
> ./files/ folder inside ./public_html/ and have those
> files protected? Right now to identify users
> (authenticate them) I use session variables... it
> should be a protection that could be used together
> with session variables
> 
> Thanks a lot.
> 
> Kisses,
> Maria
> 
> __
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com


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



RE: [PHP] Register Globals

2003-07-21 Thread Petre Agenbag
a simple extract($_POST) or extract($_GET) would also work

On Mon, 2003-07-21 at 14:22, stfmoreau wrote:
> Hi,
> 
> include this code in your header file :
>   // _GET
>   if (isset($_GET))
>   while (list($key, $val) = each($_GET))
>   {
>   eval ("$".$key." = '".$val."';");
>   }
>   // _POST
>   if (isset($_POST))
>   while (list($key, $val) = each($_POST))
>   {
>   eval ("$".$key." = '".$val."';");
>   }
>   // _SESSION
>   if (isset($_SESSION))
>   while (list($key, $val) = each($_SESSION))
>   {
>   eval ("$".$key." = '".$val."';");
>   }
> It may works (I have not expirimence it)
> 
> Stf
> 
> -Message d'origine-
> De : Daryl Meese [mailto:[EMAIL PROTECTED]
> Envoyé : lundi 21 juillet 2003 14:18
> À : [EMAIL PROTECTED]
> Objet : [PHP] Register Globals
> 
> 
> I would like to rewrite my scripts to work when register globals is off.
> The problem is that my scripts encompass several thousand files.  Does
> anyone have any suggestions for an effective tool to help in this process?
> 
> Daryl Meese
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



Re: [PHP] How to execute a bat file on the Apache server

2003-07-22 Thread Petre Agenbag
Well, firstly, you should not have to use the double \\ when using the
single quotes, try it without and see if it works...

ie, 

 exec('c:\WINNT\system32\cmd.exe /c START c:\test.bat > c:\xxx.txt');
> ?>

On Mon, 2003-07-21 at 16:34, Mikael wrote:
> Hello all, I am trying to execute a bat file, and its not working. I manage
> to get the CMD in the "win task list" however its not executing the bat
> file, and its not closing it self...?? What I need it for is to execute a
> modem to send a SMS. I got that working but the php stuff is not really my
> bussiness...so please, I need some help.
> 
> I have tried:
> 
>  exec('c:\\WINNT\\system32\\cmd.exe /c START c:\\test.bat > c:\\xxx.txt');
> ?>
> 
> Os:win 2000
> 
> Can anyone sheed some light on this...?
> 
> Thanks in advance
> 
> 


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



RE: [PHP] I'm really getting annoyed with PHP

2003-07-23 Thread Petre Agenbag
If you want to "use PHP", then you must use the headers() function. BUT,
with the header function, you MUST make sure that there will be absolutely
NO output to the page before the header() function is called, not even a
space...
Otherwise, you can simply use a meta refresh...


-Original Message-
From: Beauford.2005 [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 24, 2003 9:41 PM
To: PHP
Subject: [PHP] I'm really getting annoyed with PHP


Yes, I'm still screwing around with this stupid redirection thing, and
either I'm just a total idiot or there are some serious problems with
PHP. I have now tried to do it another way and - yes - you guessed it.
It does not work.

I mean really, it can not be this hard to redirect a user to another
page. If it is, then I must look into using something else as I just
can't be wasting days and days on one minor detail that should take 30
seconds to complete.

If anyone has some concrete suggestion on how to get this to work It
would be greatly appreciated. In the mean time I have given up on it as
I am just totally pissed off at it.

TIA



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




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



Re: [PHP] PHP should know my data!

2003-07-25 Thread Petre Agenbag
Quit horsing around fellas, what if the developers take interest in this
thread and decide it's a good idea to release PHP6 with cranial
electrodes that will detect "what I want to do", and instead of me
having to code the application, PHP will just spit out the
application... That way our bosses won't need us...


;P





On Fri, 2003-07-25 at 15:08, Comex wrote:
> <[EMAIL PROTECTED]>
> Step Schwarz:
> > I'm trying to open a pop-up window with PHP but I keep getting an
> > error. HELP!  Does anyone know if they plan to fix this
> > bug in PHP5? 
> LOL!


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



RE: [PHP] Bizarre SQl, if issue....

2003-07-29 Thread Petre Agenbag
Hi Mike, List

Where is the $place variable coming from that you use in your query's where
clause?
I hope it is not being POST'ed or GET'ed (sic), cause then you might have
the dreaded old register_globals issue.

Humour me,

echo your sql string in your code and see if it actually has something in
the $place.

-Original Message-
From: Mike At Spy [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 9:25 PM
To: Jay Blanchard; Mike At Spy; [EMAIL PROTECTED]
Subject: RE: [PHP] Bizarre SQl, if issue



> [snip]
> > $person = mysql_query("The Query");
> > $thecount = mysql_num_rows($person);
> > echo "$thecount \n";
> >
> > And tell us what $thecount is...
>
> Returns 0 (zero).
> [/snip]
>
> Then
> if($thecount == 0){
>$whatever = 1;
> } else {
>$whatever = 4;
> }
>
> $whatever should be 1

But that is my point - and I think we are going in circles now.  It just
doesn't do that.  It returns 4 (as per your example). :\

-Mike




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




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



[PHP] MySQL query/PHP logic?

2003-07-29 Thread Petre Agenbag
Hi List
 OK, I've posted this on the MySQL list as well, but it seems a bit quiet
there, and arguably it could definately be a PHP rather than mysql question
depending on whether it can be done with one query (then it was/is a mysql
query), or whether it should be done with some structures and multiple
queries ( then it's arguably PHP).

So, here goes.


I'm trying to return from multiple tables, the records that have field
"information_sent" between two dates.
The tables are all related by means of the id of the entry in the main
table, ie..

main
id  entity_name ...

fof
id_fof  id  information_sent ...

pub
id_pub  id  information_sent ...

etc.

So, I tried the following join

select * from main
left join fof on main.id = fof.id
left join pub on main.id = pub.id
left join gov on main.id = gov.id
left join med on main.id = med.id
left join ngo on main.id = ngo.id
left join own on main.id = own.id
left join sup on main.id = sup.id
left join tra on main.id = tra.id
where (
(fof.information_sent > '$date1' and fof.information_sent < '$date2')
OR
(pub.information_sent > '$date1' and pub.information_sent < '$date2')
OR
(gov.information_sent > '$date1' and gov.information_sent < '$date2')
OR
(med.information_sent > '$date1' and med.information_sent < '$date2')
OR
(ngo.information_sent > '$date1' and ngo.information_sent < '$date2')
OR
(own.information_sent > '$date1' and own.information_sent < '$date2')
OR
(sup.information_sent > '$date1' and sup.information_sent < '$date2')
OR
(tra.information_sent > '$date1' and tra.information_sent < '$date2')
)
order by entity_name


BUT, although it seems to be "joining" the tables correctly AND only
returning the ones with the correct date criteria, it does NOT return
the "id" or the "information_sent" fields correctly ( due to duplication
in the result )

Can this be done in one query without sub-selects, or should it be broken up
(in which case I would still need help with the logic and to minimize the
amount of queries inside loops)


Thanks



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



Re: [PHP] Why wouldn't a simple script work on my server thatworks on other servers?

2003-07-29 Thread Petre Agenbag
Look;s like he has short_open_tags = on in php.ini, BUT, as I understand
it, this is a supplemental setting, meaning that it does not disable the
use of the (proper)  I have a client who had me upload a relatively simple script to his
> server.  Oddly, it does not work there but works every where else I test
> it.  AND he has other PHP scripts running on his server.
> 
> So I checked out his server and all scripts are of the form:
> 
> 
> 
> // HTML HERE
> 
>  // some functionality
> 
> ?>
> 
> versus my scripts as
> 
>  
> ?>
> 
> Why would this affect things?
> 
> -Dan
> 


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



[PHP] Mysql query and PHP loops

2003-07-31 Thread Petre Agenbag
Hi List

I've been trying to do something with one MySQL query, but I don't think
it is possible, so, I would need to probably do multiple queries, and
possibly have queries inside loops, but I am rather weary of that so,
I'd like your views/possible solutions to doing the following:


Consider this:

id  val1val2val3
1   a   1   1
2   b   2   3
3   a   1   2
4   b   2   1
5   c   3   3
6   c   2   1

I need to query this table to return this:

id  val1val2val3
3   a   1   2
4   b   2   1
6   c   2   1

Thus, I need to firstly only return ONE row for each val1, and that row
MUST be that last row (ie, the row with the highest id, OR, should val3
for instance be a date, then with the highest date).


if I do a

select distinct val1, MAX(id) from table order by val1, then it returns 

id  val1
3   a   
4   b   
6   c   

which is correct, BUT
select distinct val1, MAX(id), val2 from table order by val1

it returns

id  val1val2
3   a   1   
4   b   2   
6   c   3   <--- incorrect

it then returns the FIRST "hit" for val2 in the db, and NOT the one in
the row with the max id...

Can I do this with one query? ( PS, I cannot use MAX on val2 or val3,
they are text)


Thanks



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



Re: [PHP] What does -> mean?

2003-08-14 Thread Petre Agenbag
You should read up on classes and objects in the manual.



On Thu, 2003-08-14 at 09:14, James Johnson wrote:
> Hello,
> 
> I've searched through Zend and php.net and can't find the answer.
> 
> In the following code:
> 
>  $this->vendor = $vendor; 
> 
> What does the -> mean or do?
> 
> Thanks,
> James
> 


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



RE: [PHP] Nestled 'while's or 'for's or 'foreach's -- I'm lost

2003-08-17 Thread Petre Agenbag
OK, Difficult to see from your pseudo code EXACTLY what it is that you
want to do, but I'll take a stab anyway...

Firstly, instead of using your elaborate ways of running through the
result set and extracting the variables, use something like this:

$sql = "whatever";
$result = mysql_query($sql);

echo 'ID...

while ($myrow = mysql_fetch_assoc($result)) {
extract($myrow);
//or $id = $myrow[id]; etc.
...
//construct your table here
echo ''.$id.'...';
...
}
echo '';


You must also remember that in cases where you do "limit" queries, and
want to "continue" on the next page, you must remember that your result
will NOT contain the "next" page's data. You will need to do another
query with the new "limit" data. It *looks* like this is what you are in
fact attempting in your code, just making sure...

In your case, I would say the easiest is to call the page onto itself.
Ie, your first query will be 
$sql = "whatever limit 0,6";

it will return the (maximum) 6 rows and then, on your "next" link you
should include the data for the next query. Ie, create a link like this:

Next

Meaning that you call up the same page that you used to display the
first query results, but you pass it different values for the start and
limit numbers in the query ( x,y ).

To recap, one of you biggest mistakes in the pseudo code below is that
you open a the  inside the while and close it as well (which is
fine if you want to create a table for each row you display , BUT, you
close the table again AFTER the while, that *could* cause the HTML to
freak out. So, the reason your app is not working is probably not PHP
related, but related to the fact that you are creating erroneous HTML
with your PHP. The pseudo code you are using *should* work, although, as
I stated above, there are easier and more efficient ways of doing the
same thing as per my example...





-Original Message-
From: Verdon vaillancourt [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 17, 2003 9:47 PM
To: 'PHP-General'
Subject: [PHP] Nestled 'while's or 'for's or 'foreach's -- I'm lost

Hi, somewhat newbie warning :)

I'm trying to take a paged result set and divide it into two chunks for
displaying on the page. Basically making something that looks like a
typical
thumbnail gallery. I'm limiting my result set to 6 records and want to
display it as 2 rows of 3 cells with a record in each cell. I've had no
trouble getting my result set, paging etc. I'm not having much luck
splitting my result into 2 chunks. I've tried nestling 'while'
statements
with a number of arguments and either end up with no results or a loop
that
seemingly never ends. That lead me to looking at some other apps which
seemed to use a variety of ways to achieve what I want. That lead me to
looking at 'for' and 'foreach' in the php manual. And that lead me to
being
more confused than I was before I started ;) Sometimes there's just too
many
ways to skin a cat, eh!

Below, I've include a rather lengthy bit of pseudo code that represents
basically where I'm at now. This particular version returns no results,
though I know it's just the nestled while's that are causing this. The
results are there. My research makes me think that I should replace the
nestled while's with 'foreach's. I was kind of hoping that before I
spend a
few hours trying to puzzle out how to use the 'foreach's correctly that
somebody would venture an opinion as to whether or not that would be the
way
to go.

Thanks in advance for any advice,
Verdon

-- pseudo code --

 0) {

$x = 0;

echo "Page of Pieces";

while ( $x < $numberall ) {
 
// Retreiving data and putting it in local variables for each
row
$id = mysql_result ($resultall ,$x ,"id");
$title = mysql_result ($resultall ,$x ,"title");
$description = mysql_result ($resultall ,$x ,"description");
$thumb = mysql_result ($resultall ,$x ,"thumb");
$company = mysql_result ($resultall ,$x ,"company");

echo "";
echo "";

while ($x >= 0 && $x < 4)
{

echo "";
if ($thumb) {
echo "thumbnail with a link";
} else {
echo "text with a link";
}
echo "$title";
echo "$company";
echo "$description";
echo "";
$x ++;
}

echo "";
echo "";

while ($x > 3 && $x < $numberall)
{

echo "";
if ($thumb) {
echo "thumbnail with a link";
} else {
echo "text with a link";
}
echo "$title";
echo "$company";
echo "$description";
echo "";

Re: [PHP] Strange Issues

2003-04-01 Thread Petre Agenbag
Hi Nicole
First of all you need to tell us where and for which service these users
are trying to log in, ie. are they logging in to receive mail, access
secure website section etc? And what is the authentication
method/dependencies? I think if you can answer these questions, we will
know better to tell you where to look for the cause. For example, if the
problem is with users loggin into the website, and the authentication
you use is a sql table , then the problem could lie with either Apache
being too busy, or with mysql being too busy, and the problem would
probably be evident in the logs of either service.

You can also scrutinize your /var/log/messages file to see if there are
any evidence of system lockups or other errors.

Regards

Petre

On Wed, 2003-04-02 at 09:04, Nicole wrote:
> ---
> My System:
> A dedicated server with:
> Red Hat 7.2
> P4 2 GHZ
> 1GB Ram
> 
> -Apache
> -PHP 4.2
> -MySQL
> 
> Ensim panel
> ---
> I am having strange occurrences of people telling me they cannot sign into
> their accounts. It happens every now and then, and it happens to anyone --
> but not everyone.
> 
> I am not sure what this could be a result of. I start to think it's a server
> issue. I see no common pattern, they are using either windows 98 or XP with
> IE 5 and 6. I personally run XP and have the same setup as some of these
> that report trouble signing in. If they try to sign in later, they get in
> fine.
> 
> I run several sites on this server, and this particular site is high
> traffic. My other site has just about 30 members and I have had not a single
> complain in 6 months. So I'm baffled.
> 
> The hour of the day varies,as well. There's no regular or common pattern
> that I can see. Could it be from an issue with Apache, MySQl and PHP? Maybe
> it is even an issue with PHP sessions.
> 
> I wondered if anyone else has heard of or experienced something similar. If
> so, have you figured out what is causing this? Have you found a workaround?
> 
> Thanks!
> 
> --
> Nicole
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



Re: [PHP] newbie help, pressing the submit button returns nothing

2003-04-04 Thread Petre Agenbag
Your problem is not with PHP but with basic HTML.
Your  tag needs an action="www.somepage.com" in order to "do"
something. With PHP, you can call the same page back onto itself.
 
On Fri, 2003-04-04 at 14:37, David McGlone wrote:
> Hi all, I have a real quick question. I'm trying to learn PHP and right now im 
> working with variables, anyway, I cannot get the code below to work 
> correctly, could anyone help me out here the problem is, when you submit the 
> name, the name will not appear at all.
> 
>  
> 
> 
> 
> Name:
> 
> 
> 
> 
> Your name is:
>  
> echo ($UserName);
> ?>
> 
> 
> -- 
> David M.
> Edification Web Solutions
> http://www.edificationweb.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



[PHP] How do I display new lines in a textearea?

2003-06-06 Thread Petre Agenbag
Hi

I want to have a textarea that contains details read from a mysql table,
but I want to echo each row so that it is on a new line. What is the
"new-line" character for a textarea? ( in effect the reverse of nl2br()
)

Thanks




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



Re: [PHP] How do I display new lines in a textearea?

2003-06-06 Thread Petre Agenbag
Hi 
Thanks, I DID use \n, BUT, I made a stupid mistake, I did:





And the literal ' did not "parse" the \n, replacing with " works fine...


 
On Thu, 2003-06-05 at 16:32, CPT John W. Holmes wrote:
> > I want to have a textarea that contains details read from a mysql table,
> > but I want to echo each row so that it is on a new line. What is the
> > "new-line" character for a textarea? ( in effect the reverse of nl2br()
> 
> A newline is \n
> 
> $text = "word\nword\nword\n";
> 
> echo "$word";
> 
> will have each "word" on a different line. 
> 
> ---John Holmes...


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



Re: [PHP] Variables don't pass... *sniff*

2003-05-28 Thread Petre Agenbag
RegisterGlobals = Off

You need to access these variables by

$_POST[aVariable] or in your case ( adding the variables to the end of a
URL means you are using the GET method: $_GET[aVAriable] etc.
 
On Wed, 2003-05-28 at 11:37, [EMAIL PROTECTED] wrote:
> Hi all!
> 
> I'm using Apache 2.0.45, PHP 4.3.2RC4, and MySQL 3.23.49 on Windows 2003
> Server Standard.
> 
> I have a problem passing variables between pages. They simply get lost.
> Neither GET nor POST pass values, and even "hardcoding" them into the URL,
> like
> 
> htpp://localhost/comeon.php?aVariable=ding&anotherVariable=dong
> 
> and putting this in comeon.php:
> 
> echo("Values: $aVariable, $anotherVariable");
> 
> only outputs
> 
> Values: ,
> 
> ...I've tried with RC3 of PHP, even 4.3.1, but it doesn't work. I've used
> PHP on my machine with Apache 2 before, and it worked fine. Actually I used
> the same scripts fine on my old config. This was on XP however, so I'm not
> sure if it's got something to do with the OS. I'm hoping it's a
> configuration issue.
> 
> Any ideas are VERY much appreciated =).
> 
> Thanks,
> Daniel
> 
> 
> » There are 10 kinds of people - those who know binary and those who don't.
> «
> 


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



Re: [PHP] Variables don't pass... *sniff*

2003-05-28 Thread Petre Agenbag
It's not backwards compatible. If your code simply mentioned the
variable name and not the method array, it will not work (as you
noticed) when registerglobals is turned off ( for security reasons).

However, there are many ways of making your old code work, the easiest
is probably to extract the $_POST or $_GET array.

Look in the manual at the array functions ( extract() ) and also read up
on working with registerglobals = off.


On Wed, 2003-05-28 at 11:49, [EMAIL PROTECTED] wrote:
> Thank you mate, this works! =)
> 
> Just curious, though... I'd like to keep my scripts as compatible as
> possible, so can you tell me if this method is backwards compatible? I've
> never used this method before, the variables have just "been there" on a
> subsequent page. I'm kinda fearing for my previous work, if the servers
> suddenly change their configurations, rendering scripts non-functional...
> 
> And, I'm guessing $_POST would be the array to hold POSTed variables, right?
> 
> Is there a function to "release" the contents of these arrays into global
> variables in a scripts, so you don't have to go...
> $var1 = $_GET[var1];
> $var2 = $_GET[var2];
> ...if that's what you wanted? (Not sure I want to, but just to know)
> 
> Again, thank you! =)
> 
> Daniel
> 
> 
> - Original Message - 
> From: Petre Agenbag
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Sent: Wednesday, May 28, 2003 11:40 AM
> Subject: Re: [PHP] Variables don't pass... *sniff*
> 
> 
> RegisterGlobals = Off
> 
> You need to access these variables by
> 
> $_POST[aVariable] or in your case ( adding the variables to the end of a
> URL means you are using the GET method: $_GET[aVAriable] etc.
> 
> On Wed, 2003-05-28 at 11:37, [EMAIL PROTECTED] wrote:
> > Hi all!
> >
> > I'm using Apache 2.0.45, PHP 4.3.2RC4, and MySQL 3.23.49 on Windows 2003
> > Server Standard.
> >
> > I have a problem passing variables between pages. They simply get lost.
> > Neither GET nor POST pass values, and even "hardcoding" them into the URL,
> > like
> >
> > htpp://localhost/comeon.php?aVariable=ding&anotherVariable=dong
> >
> > and putting this in comeon.php:
> >
> > echo("Values: $aVariable, $anotherVariable");
> >
> > only outputs
> >
> > Values: ,
> >
> > ...I've tried with RC3 of PHP, even 4.3.1, but it doesn't work. I've used
> > PHP on my machine with Apache 2 before, and it worked fine. Actually I
> used
> > the same scripts fine on my old config. This was on XP however, so I'm not
> > sure if it's got something to do with the OS. I'm hoping it's a
> > configuration issue.
> >
> > Any ideas are VERY much appreciated =).
> >
> > Thanks,
> > Daniel
> >
> >
> > » There are 10 kinds of people - those who know binary and those who
> don't.
> > «
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



Re: [PHP] Variables don't pass... *sniff*

2003-05-28 Thread Petre Agenbag
Sorry, I missunderstood your question about backwards compatible.

YES, accessing your variables this way ($_POST[] etc), IS backwards
compatibel, ie, they are placed in those arrays anyways, BUT, the method
is not backwards compatible to older versions of PHP, there the arrays
were called $HTTP_GET_VARS or something similarly unlike $_GET...

On Wed, 2003-05-28 at 11:49, [EMAIL PROTECTED] wrote:
> Thank you mate, this works! =)
> 
> Just curious, though... I'd like to keep my scripts as compatible as
> possible, so can you tell me if this method is backwards compatible? I've
> never used this method before, the variables have just "been there" on a
> subsequent page. I'm kinda fearing for my previous work, if the servers
> suddenly change their configurations, rendering scripts non-functional...
> 
> And, I'm guessing $_POST would be the array to hold POSTed variables, right?
> 
> Is there a function to "release" the contents of these arrays into global
> variables in a scripts, so you don't have to go...
> $var1 = $_GET[var1];
> $var2 = $_GET[var2];
> ...if that's what you wanted? (Not sure I want to, but just to know)
> 
> Again, thank you! =)
> 
> Daniel
> 
> 
> - Original Message - 
> From: Petre Agenbag
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Sent: Wednesday, May 28, 2003 11:40 AM
> Subject: Re: [PHP] Variables don't pass... *sniff*
> 
> 
> RegisterGlobals = Off
> 
> You need to access these variables by
> 
> $_POST[aVariable] or in your case ( adding the variables to the end of a
> URL means you are using the GET method: $_GET[aVAriable] etc.
> 
> On Wed, 2003-05-28 at 11:37, [EMAIL PROTECTED] wrote:
> > Hi all!
> >
> > I'm using Apache 2.0.45, PHP 4.3.2RC4, and MySQL 3.23.49 on Windows 2003
> > Server Standard.
> >
> > I have a problem passing variables between pages. They simply get lost.
> > Neither GET nor POST pass values, and even "hardcoding" them into the URL,
> > like
> >
> > htpp://localhost/comeon.php?aVariable=ding&anotherVariable=dong
> >
> > and putting this in comeon.php:
> >
> > echo("Values: $aVariable, $anotherVariable");
> >
> > only outputs
> >
> > Values: ,
> >
> > ...I've tried with RC3 of PHP, even 4.3.1, but it doesn't work. I've used
> > PHP on my machine with Apache 2 before, and it worked fine. Actually I
> used
> > the same scripts fine on my old config. This was on XP however, so I'm not
> > sure if it's got something to do with the OS. I'm hoping it's a
> > configuration issue.
> >
> > Any ideas are VERY much appreciated =).
> >
> > Thanks,
> > Daniel
> >
> >
> > » There are 10 kinds of people - those who know binary and those who
> don't.
> > «
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



Re: [PHP] Variables don't pass... *sniff*

2003-05-28 Thread Petre Agenbag
Maybe they could include a quick "overview" of the latest changes as
well as a link to the on-line manual in your "sign-up" message when
joining the list?

On Wed, 2003-05-28 at 11:46, Chris Hayes wrote:
> Could someone with power over php.net please try to make this change in 
> variable handling very extremely clear for downloaders? Make it something 
> you cannot miss? Not everybody reads release notes and readme.txt files.
> 
> 


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



[PHP] GEnerating PDF's

2003-06-02 Thread Petre Agenbag
Hi List

I'm investigating different possibilities to generate printable and
read-only documents, and the "best" method seems to be generating PDF's,
however, I have NO experience with working with PDF's, and the examples
in the manual only list a simple "one-liner" text pdf. 
Where can I find more material that will explain in layman's terms how
to generate pdf's from various sources. As example, I'd like to generate
PDF's of a webpage "on-the-fly" or even from data in MySQL tables. It
seems that you need to provide the pdf generation process with the
co-ordinates and size of each "element", but it is the location of the
"elements" that I have trouble with, ie. what is needed to define each
element?

Thanks for the help.




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



[PHP] dealiong with quote's in SQL strings

2003-06-13 Thread Petre Agenbag
Hi List

I recently installed 4.3.1 and enabled the magic_quotes_gpc to deal with
quotes in mysql inserts.

However, I think I have run into a problem that might be related, and
was wondering if there is an easy way to fix it:

I have a script that gets user input from a drop-down, on the action
page I search a mysql table for the row matching the selection made
previously. What I do then is to extract the result of that "select *
from table where data = form_selection" and then to re-insert the data
into the table ; note, re-insert, NOT UPDATE ( the app cals for a new
row to be added with the updated data, so the "old" row stays intact and
a new row is added that contains some of the old row's data plus some
new stuff I add).

So, the new insert sql looks as per usual 

insert into table (`var1`,`var2`,`var3`,`var4`,...) values
('$var1','$var2',);

where $var1, $var2 etc is either "inherited" from the extract of the
first querie's result set, or overwritten with my newly generated
values. The problem now comes in with this:

If one or more of the extracted variables containes something like 
" O'Healy " or something similar that causes trouble with the quotes in
the new INSERT sql, well, you see the problem...

And I don't want to have to go and addslashes to all my extracted
variables, because there really are a whole heap of them.

So, is there another php.ini setting that I'm missing to help me with
this, or maybe a function that will addslashes to all my extracted vars?

I'm lazy, shoot me!




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



Re: [PHP] dealiong with quote's in SQL strings

2003-06-13 Thread Petre Agenbag
Hi Awlad
Yes, I know addslashes(), but that's the point, I would rather NOT want
to go and have to use addslashes() to all my extracted vars as there are
almost a hundred vars, and I douldn't want to go and have to add
addslashes($var1), addlsashes($var2), ., addslashes($var100) UNLESS
it is the unanimous feeling of the list that there is no other way (
BTW, the app worked fine on PHP 4.0.4, hence my suspicion that there
might be a php.ini setting I missed when upgrading to 4.3.1)

On Fri, 2003-06-13 at 15:46, Awlad Hussain wrote:
> addslashes
> (PHP 3, PHP 4 )
> 
> addslashes -- Quote string with slashes
> Description
> string addslashes ( string str)
> 
> 
> Returns a string with backslashes before characters that need to be quoted
> in database queries etc. These characters are single quote ('), double quote
> ("), backslash (\) and NUL (the NULL byte).
> 
> - Original Message - 
> From: "Petre Agenbag" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, June 13, 2003 2:43 PM
> Subject: [PHP] dealiong with quote's in SQL strings
> 
> 
> > Hi List
> >
> > I recently installed 4.3.1 and enabled the magic_quotes_gpc to deal with
> > quotes in mysql inserts.
> >
> > However, I think I have run into a problem that might be related, and
> > was wondering if there is an easy way to fix it:
> >
> > I have a script that gets user input from a drop-down, on the action
> > page I search a mysql table for the row matching the selection made
> > previously. What I do then is to extract the result of that "select *
> > from table where data = form_selection" and then to re-insert the data
> > into the table ; note, re-insert, NOT UPDATE ( the app cals for a new
> > row to be added with the updated data, so the "old" row stays intact and
> > a new row is added that contains some of the old row's data plus some
> > new stuff I add).
> >
> > So, the new insert sql looks as per usual
> >
> > insert into table (`var1`,`var2`,`var3`,`var4`,...) values
> > ('$var1','$var2',);
> >
> > where $var1, $var2 etc is either "inherited" from the extract of the
> > first querie's result set, or overwritten with my newly generated
> > values. The problem now comes in with this:
> >
> > If one or more of the extracted variables containes something like
> > " O'Healy " or something similar that causes trouble with the quotes in
> > the new INSERT sql, well, you see the problem...
> >
> > And I don't want to have to go and addslashes to all my extracted
> > variables, because there really are a whole heap of them.
> >
> > So, is there another php.ini setting that I'm missing to help me with
> > this, or maybe a function that will addslashes to all my extracted vars?
> >
> > I'm lazy, shoot me!
> >
> >
> >
> >
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 


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



Re: [PHP] dealiong with quote's in SQL strings

2003-06-13 Thread Petre Agenbag
Thanks, it was there right infront of me...

Just as a matter of interest, are there security/performance issues with
this setting as well as the magic_quotes_gpc or other oddities that it
could cause?

On Fri, 2003-06-13 at 15:54, CPT John W. Holmes wrote:
> > I recently installed 4.3.1 and enabled the magic_quotes_gpc to deal with
> > quotes in mysql inserts.
> > 
> > However, I think I have run into a problem that might be related, and
> > was wondering if there is an easy way to fix it:
> > 
> > I have a script that gets user input from a drop-down, on the action
> > page I search a mysql table for the row matching the selection made
> > previously. What I do then is to extract the result of that "select *
> > from table where data = form_selection" and then to re-insert the data
> > into the table ; note, re-insert, NOT UPDATE ( the app cals for a new
> > row to be added with the updated data, so the "old" row stays intact and
> > a new row is added that contains some of the old row's data plus some
> > new stuff I add).
> > 
> > So, the new insert sql looks as per usual 
> > 
> > insert into table (`var1`,`var2`,`var3`,`var4`,...) values
> > ('$var1','$var2',);
> > 
> > where $var1, $var2 etc is either "inherited" from the extract of the
> > first querie's result set, or overwritten with my newly generated
> > values. The problem now comes in with this:
> > 
> > If one or more of the extracted variables containes something like 
> > " O'Healy " or something similar that causes trouble with the quotes in
> > the new INSERT sql, well, you see the problem...
> > 
> > And I don't want to have to go and addslashes to all my extracted
> > variables, because there really are a whole heap of them.
> > 
> > So, is there another php.ini setting that I'm missing to help me with
> > this, or maybe a function that will addslashes to all my extracted vars?
> 
> magic_quotes_runtime in php.ini
> 
> ---John Holmes...


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



[PHP] magic_quotes_gpc - > 4.0.1 to 4.3.1

2003-06-17 Thread Petre Agenbag
Hi List

Is there a difference in the way PHP handles the magic_quotes_gpc
between these versions?

I had 4.0.1 running on my server for a little over a year and all went
well, ie, data that contained quotes etc were discreetly handles by PHP
and inserted into MySQL with no problems ( when you vies the data in the
table with phpMyAdmin for instance, you would not see any slashes in the
content.

However, since I upgraded to 4.3.1 (and turned on magic_quotes_gpc), I
notice that the same process now produces slashes in the db, meaning
that I will now need to edit my code and add stripslashes() when I need
to display them. [STOP RIGHT HERE] -> I KNOW that it is "best" to use
addslashes() and stripslashes() BUT, I inherited the code, and it is
really going to be an enormous task to go through the code for the
entire app. So naturally I'm looking for a "quick fix" in the form of
another "magic" function, and in the absence of such a function, I'd
like to know what the differences are, maybe I can then look at a class
or a function to handle all for me???

Thanks for any help.
 


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



[PHP] Problems with quotes in URL

2003-06-18 Thread Petre Agenbag
Hi List

I don't know what I'm doing wrong:

Firstly, I upgraded from 4.0.1 to 4.3.1 and made sure that I have
similar settings in php.ini wrt register_globals and magic_quotes.

I now have problems with some of my apps:


For instance:

IN a mysql db, I would have a name like :[  whatever "whatever"  ]

I do a select on the table and then echo the name on a page, as well as
add it to a url:

page.php?myvar=$myvar

where $myvar contains the [ whatever "whatever" ]

Now, when I try to echo $myvar on the page.php, I don't get the entire
story.

I tried to addslashes() before the url line, I tried urlencode() and
htmlspecialchars, all causes an echo  of $myvar on the page.php page to
only display whatever , or, whatever \ but NEVER, whatever "whatever"


What am I doing wrong?

Thanks



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



Re: [PHP] Problems with quotes in URL

2003-06-18 Thread Petre Agenbag
OK, this is the URL that my code produces after it get's the my_var from
the mysql table.
my_var in the table is => whatever whatever  "whatever whatever"

So I do a select and I do a $my_var = $myrow['my_var'] (after all the
proper mumbo jumbo about the $myrow = mysql_fetc_assoc...etc.)

I then do a $my_var = addslashes($my_var)as well as $my_var =
urlencode($my_var).
 Then I simply create a link like so:

echo 'link';

Clicking on that link displays exactly the following in the browser's
URL location:

page.php?my_var=whatever+whatever++%5C%22whatever+whatever%5C%22&next_var=blabla

And now, on page.php

If I do an 

echo stripslashes($my_var);

I get exactly this:

whatever whatever \


What am I missing?





On Wed, 2003-06-18 at 11:18, Chris Hayes wrote:
> >IN a mysql db, I would have a name like :[  whatever "whatever"  ]
> >
> >I do a select on the table and then echo the name on a page, as well as
> >add it to a url:
> >
> >page.php?myvar=$myvar
> >
> >where $myvar contains the [ whatever "whatever" ]
> >
> >Now, when I try to echo $myvar on the page.php, I don't get the entire
> >story.
> >
> >I tried to addslashes() before the url line, I tried urlencode() and
> >htmlspecialchars, all causes an echo  of $myvar on the page.php page to
> >only display whatever , or, whatever \ but NEVER, whatever "whatever"
> 
> 
> What does your link in which 'whatever' is look like ?
> How do you test to see what is in the variable?
> 
> 
> This does the job for me:
> 
>  
> if ($_GET['x']=='')
> {$i='whatever "Whatever"';
> echo 'link';
> 
> }
> else
> 
> echo 'x is '.urldecode($_GET['x']);
> 
> ?>
> 
> and the url looks like:http://www.X.nl/get.php?x=whatever+%22Whatever%22
> 
> 
> 
> 
> 
> 


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



Re: [PHP] Problems with quotes in URL - SOLVED - plz FLAME me!!!

2003-06-18 Thread Petre Agenbag
Hi lists ( and all the guys trying to help me)

Firstly

SORRY, I oversimplified my examples that I posted in the hope that I
would get to the solution faster.

What i failed to mention in my stupidity, was that I echoed the variable
as the value of a form input text field, so I actually messed up the
HTML, and I just realized it, and a simple $var = htmlspecialchars($var)
does the trick beautifully.

Again
Sorry guys, I really should have known better than to post stripped down
code as the problem is usually a simple thing like this...

Just for the by-and-by, my previous claims to having a "perfectly
working" application before upgrading to 4.3.1 was also then a load of
bull, and I only realized now that my app had this bug in it all the
time!

Just goes to show.

Anyway, I deserve a good flaming for this one! 

I'm ready;)




On Wed, 2003-06-18 at 14:39, Chris Hayes wrote:
> (cutted the part about sending a var as get)
> 
> >page.php?my_var=whatever+whatever++%5C%22whatever+whatever%5C%22&next_var=blabla
> ok so here the variable is still complete, including slashes and quotes.
> 
> 
> >And now, on page.php
> >
> >If I do an
> >
> >echo stripslashes($my_var);
> >
> >I get exactly this:
> >
> >whatever whatever \
> 
> i get better results with
> 
> echo stripslashes(urldecode($_GET['my_var']));
> (or in your version
> echo stripslashes(urldecode($my_var));
> )
> 
> 
> this even though Marek  said "Incomming GET values are urldecoded 
> automaticaly, no need to do this." (this=urldecode)
> 
> 


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



[PHP] sending headers

2003-06-23 Thread Petre Agenbag
Hi List

I am having trouble using headers.

I try to include a redirect header in my script, but is fails with the
familiar ( headers already sent) error.

I KNOW you should put the headers call where it will cause the first
output, and I do that, the only thing happening infront of the headers
call is an include statement to my main db class; this class has
absolutely NO output unless a function is called (which it is not)...

What am I missing?





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



RE: [PHP] quotes

2003-06-25 Thread Petre Agenbag

What you also need is to htmlspecialchars() the vars that you echo as form
element values, else your HTML will be broken if one of the vars contains "
. This should work for both text fields and textareas




or





-Original Message-
From: Lso . [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 4:21 PM
To: [EMAIL PROTECTED]
Subject: [PHP] quotes


Ok I have been searching to no avail.   I have a form that lets you add new
sets of information to a database.  Once you add information i have a page
that displays this information in a series of text fields.  I have done this
so you can alter the information in the fields hit edit and the information
is updated, you are brought back to the same page and there you see your
updated information.  This all works fine.  The problem is if the usere
enters a quote.  I have used addslashes(), and the information is entered
fine, but when I display the information in the form fields its cut off
right after the  quote.  I tried stripslashes() didnt work.  If i url encode
the input i get the html entity displayed in the form field.  Does anyone
have any suggestions?  Im just trying to make a nice interface for editing
this data.  Thanks in advance.

Lucas Owens
www.lucasowens.com
www.technoiraudio.com

_
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail


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




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



Re: [PHP] Forms

2003-06-30 Thread Petre Agenbag
Have you checked register_globals = on/off in your php.ini?
If register_globals=off, then you must access your POST variables by:

$_POST['whatever'];

and your get (the stuff you put at the end of your URL's):

$_GET['whatever'];


On Mon, 2003-06-30 at 15:48, Simon Chappell wrote:
> Hi can anyone help me with this?
> 
> I have been failing to get any forms working with PHP now I have run out of 
> ideas? Having bought 3 books the latest one being php & mysql for 
> dummies(which might be appropriate for me) I am still failing at this hurdle.
> 
> the following script is a classic example taken straight out of the book, I 
> get round the $PHP_SELF problem ok but then all the script does is loop back 
> to itself? 
> 
> 
> 
> 
> SQL Query Sender
> 
> 
>   $user="root";
>  $host="localhost";
>  $password="";
> 
>  /* Section that executes query */
>  if (@$form == "yes")
>  {
>mysql_connect($host,$user,$password);
>mysql_select_db($database);
>$query = stripSlashes($query) ;
>$result = mysql_query($query);
>echo "Database Selected: $database
>   Query: $query
>   Results
>   ";
>if ($result == 0)
>   echo("Error " . mysql_errno() . ": " . mysql_error() . "");
> 
>elseif (@mysql_num_rows($result) == 0)
>   echo("Query completed. No results returned.");
>else
>{
>  echo "
>
> ";
>  for ($i = 0; $i < mysql_num_fields($result); $i++) 
>  {
>  echo("" . mysql_field_name($result,$i) . "");
>  }
>  echo " 
>
>";
>  for ($i = 0; $i < mysql_num_rows($result); $i++)
>  {
> echo "";
> $row = mysql_fetch_row($result);
> for ($j = 0; $j < mysql_num_fields($result); $j++)
> {
>   echo("" . $row[$j] . "");
> }
> echo "";
>  }
>  echo "
>   ";
>}
>echo "
>  
>   
>   
>   
>   
>  ";
>unset($form);
>exit();
>  }
> 
>  /* Section that requests user input of query */
>  @$query = stripSlashes($query);
>  if (@$queryButton != "Edit Query")
>  {
>$database = " ";
>$query = " ";
>  }
> ?>
> 
> ?form=yes method="post">
>  
>   
>Type in database name
>
>   >
>
>   
>   
>Type in SQL query
> ?>
>
>   
>   
>
>   
>  
> 
>  
> 
> 
> 
> Any ideas would be greatly appreciated as I am floundering badly!
> 
> Simon
> 


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



RE: [PHP] Forms

2003-06-30 Thread Petre Agenbag
Most books, specially the older ones will use this type of coding. It relies
completely on register_globals (and some other settings) to be enabled in
your php.ini.

However, many possible security risks has been identified with having
register_globals=on, so newer versions come with that feature disabled by
default.
This has been discussed to great depths in the archives, and arguably, if
you design your code with security in mind, turning register_globals on,
will and should not cause any problems. On the other hand, it is becoming a
"standard", so unless you have your own server, or you know your ISP will
turn it on for you, then you are probably better off accessing your
variables through the POST and GET arrays.

As I said in my first post, it is basically in the way that you call your
variables.

If you look at your example:
You have a form that has the same page as the action, using the POST method,
meaning that all the "names" of form elements and the correlating "values",
will be passed to the action page as POST variables. All these variables get
stored in the $_POST array.
So, as an example:
Your form has a 
With your code in mind, hitting the submit on the form, will place a new
element in the $_POST array, called "var1" ad associative value = "test"
And if you need to echo or use that variable/value, you should do so by
calling it like so:

echo $_POST[var1];

output -> "test"

If you look closely at your code, you will see an If

 /* Section that executes query */
> >  if (@$form == "yes")
> >  {


and you will also see that the form being shown on first load of the page,
has a get variable appended to it in the action:

?form=yes method="post">
> >  
> >   
> >Type in database name
> >

that "?form=yes" bit, creates a $_GET variable called $_GET[form] with a
value of "yes"

So, for your code to work, the IF statement should read:

 if ($_GET[form] == "yes")
> >  {

Basically, the reason why it looks like your page is not doing anything, is
because the if cannot be satisfied...

You should thus go through that sample code and change the nameing of your
POST and GET variables (ie, the variables that are "passed" to the next page
to the abovementioned method and all should be fine.



-Original Message-
From: Simon Chappell [mailto:[EMAIL PROTECTED]
Sent: Monday, June 30, 2003 6:22 PM
To: Petre Agenbag
Subject: Re: [PHP] Forms


thanks for the reply

yes I have tried both on and off, it is currently off?
Where would i put those in my script? or do I have to start from scratch?
The reason I am asking, is that all the books I have seem to be doing the
same
out of date coding, and if it is possible to make a quick change that I can
carry with me through my learning then I can get use out of all the books
that i have bought! but if all the scripts are pointless then i might as
well
light a match or give them to my 6 year old and ask him to look after them!!

Many thanks

Simon

On Monday 30 Jun 2003 3:14 pm, Petre Agenbag wrote:
> Have you checked register_globals = on/off in your php.ini?
> If register_globals=off, then you must access your POST variables by:
>
> $_POST['whatever'];
>
> and your get (the stuff you put at the end of your URL's):
>
> $_GET['whatever'];
>
> On Mon, 2003-06-30 at 15:48, Simon Chappell wrote:
> > Hi can anyone help me with this?
> >
> > I have been failing to get any forms working with PHP now I have run out
> > of ideas? Having bought 3 books the latest one being php & mysql for
> > dummies(which might be appropriate for me) I am still failing at this
> > hurdle.
> >
> > the following script is a classic example taken straight out of the
book,
> > I get round the $PHP_SELF problem ok but then all the script does is
loop
> > back to itself?
> >
> > 
> > 
> > 
> > SQL Query Sender
> > 
> > 
> >  >  $user="root";
> >  $host="localhost";
> >  $password="";
> >
> >  /* Section that executes query */
> >  if (@$form == "yes")
> >  {
> >mysql_connect($host,$user,$password);
> >mysql_select_db($database);
> >$query = stripSlashes($query) ;
> >$result = mysql_query($query);
> >echo "Database Selected: $database
> >   Query: $query
> >   Results
> >   ";
> >if ($result == 0)
> >   echo("Error " . mysql_errno() . ": " . mysql_error() . "");
> >
> >elseif (@mysql_num_rows($result) == 0)
> >   echo("Query completed. No results return

[PHP] Form 2 PDF 2 Form

2003-07-01 Thread Petre Agenbag
Hi List

OK, firstly, sorry if this has been on the list before...

What I'd like to do is something like this:

I currently have an app that takes user input via a normal html form,
and then pops the content into mysql.

The problem is that lots of user complain that the submit times out due
to slow/bad connections, and hence the data gets lost.

What I was hoping to do now, was to somehow create a PDF form from the
current html form ( should generate itself on the fly ) , the PDF form
will obviously need to be downloaded to the user's PC, and will be
unique for each time they use the system, ie, I don't want to just give
them a blank template PDF, some of the values need to be
"auto-completed" and inserted into the form as "read-only", as well as a
couple of "hidden" fields with identifying values so I can know where to
pop it into the db.

The idea is that the user will now come to the point where he would
usually have filled in the html form, but instead, the app must
autogenerate a PDF with some values auto-completed and/or hidden, and
the user then downloads the pdf to his/her PC, where they continue to
fill out the pdf form.

Then, on completetion, I'd like to investigate several delivery
mechanisms, arguably, the easiest way for the users ( who are mostly
techno-peasants), is to simply e-mail the pdf as an attachment to me),
but then I will either have to create an auto-parser for the email
(prolly difficult and prone to problems with making sure the attachment
is correct etc), or I will have to then manually process the
attachments.

Either way, I would need to "feed" the pdf to my app, where the
form/hidden variables would need to be harvested from the form, and noly
then (after validation), be entered into the db.

So, simple concept, but I'm sure many pitfalls, the least being probably
that I have never done this, and don't know where to start, or even if
it's possible/advisable to follow this route.

Hence my post here...



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



Re: [PHP] Re: Form 2 PDF 2 Form

2003-07-01 Thread Petre Agenbag
Hi Shiva
Appreciate your input. Wrt the spanning of the form, I think, in my
situation, it would actually make things worse... You see, my suspicion
is that most of the users who are experiencing problems, have very bad
connections, many complain that they lose connectivity while they are
busy with the form ( it takes them maybe 30 min or so to fill out the
entire form ( they basically transfer the data off paper forms they have
filled out earlier while "on-site", so it's not really alot of data, but
there are a lot of fields...)
So, my fear with this approach is that they will maybe get past the
first part of the form, submit that OK, then start getting trouble with
subsequent parts, leaving me with a whole lot of partial entries in the
DB., and how do I get them to "resume" at a a later stage?
You don't understand the mindset of these people, when something goes
wrong, they'll switch off their PC's and try to start from scratch, so
it's going to be difficult to try and get them to understand the concept
of multi-part forms... I shudder to even think what will happen, or
worse, how I will be able to allow them to make corrections on a certain
part of the form once they have submit it. And sometimes, to their
defense, it's not them that want to change the details on the form, but
the subject of the form who has decided to change their name etc...

I'm not ditching this idea, I will definitely give it some more thought,
it's just at this moment, my mind is running through my original idea of
PDF forms trying to evaluate it.

Each method will have it's pro's and cons, and I'll have to go and weigh
them. I must add, I don't see "effort" as a con for a particular
solution, as long as I know it will solve the problem without adding
other cons...

Thanks again, will take it up with you again ( need some more input on
this PDF thing to get some balanced views)

PS, if you have experience with using this method, I would appreciate it
if you could let me have your "field notes" and how successfull it's
working for you.
You see, the main thing here is that I need to KNOW when someone who
says they have submitted something actually have, and that they are not
trying their luck...

  
On Tue, 2003-07-01 at 13:43, Shivanischal A wrote:
> hi,
> 
> seems u have complicated task on hand mate. cant u simply consider span the
> user input over multiple pages? i mean using 2 or more form on different
> pages instead of a single form on one single page. if this cant be done,
> we'll think of other measures. but this is by far the most simple method
> 
> -shiva
> 
> 
> "Petre Agenbag" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi List
> >
> > OK, firstly, sorry if this has been on the list before...
> >
> > What I'd like to do is something like this:
> >
> > I currently have an app that takes user input via a normal html form,
> > and then pops the content into mysql.
> >
> > The problem is that lots of user complain that the submit times out due
> > to slow/bad connections, and hence the data gets lost.
> >
> > What I was hoping to do now, was to somehow create a PDF form from the
> > current html form ( should generate itself on the fly ) , the PDF form
> > will obviously need to be downloaded to the user's PC, and will be
> > unique for each time they use the system, ie, I don't want to just give
> > them a blank template PDF, some of the values need to be
> > "auto-completed" and inserted into the form as "read-only", as well as a
> > couple of "hidden" fields with identifying values so I can know where to
> > pop it into the db.
> >
> > The idea is that the user will now come to the point where he would
> > usually have filled in the html form, but instead, the app must
> > autogenerate a PDF with some values auto-completed and/or hidden, and
> > the user then downloads the pdf to his/her PC, where they continue to
> > fill out the pdf form.
> >
> > Then, on completetion, I'd like to investigate several delivery
> > mechanisms, arguably, the easiest way for the users ( who are mostly
> > techno-peasants), is to simply e-mail the pdf as an attachment to me),
> > but then I will either have to create an auto-parser for the email
> > (prolly difficult and prone to problems with making sure the attachment
> > is correct etc), or I will have to then manually process the
> > attachments.
> >
> > Either way, I would need to "feed" the pdf to my app, where the
> > form/hidden variables would need to be harvested from the form, and noly
> > then (after validation), be entered into the db.
> >
> > So, simple concept, but I'm sure many pitfalls, the least being probably
> > that I have never done this, and don't know where to start, or even if
> > it's possible/advisable to follow this route.
> >
> > Hence my post here...
> >
> >
> 
> 


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



Re: [PHP] Re: Form 2 PDF 2 Form

2003-07-01 Thread Petre Agenbag
Well, I'm still a bit concerned about what would happen if the
connection got broken while they are busy...
The session will time-out (by most defaults, after 1440s), so if they
cannot re-connect, and somehow get the same SESSID, then all would be
lost that they have done so far..., and that is the main problem;
The way I have it set-up atm, is that I place all the necessary details
as hidden elements into the form and I then allow them to actually
disconnect their connections ( if they want), and to then re-conncet
before they want to submit, and then try to submit. This works, but, wrt
saving what they have done so far; when the form has submitted
successfully, I re-construct it on the action page, and this gives them
the opportunity to save the page or print it out, all well and good if
the form actually submitted correctly. BUT, when something happens
DURING the submit, then it seems that the app behaves strangely;
sometimes, it will generate the "result" form, but will not actually
insert anything into the db, or it would only insert partial data...
Now on those, I don't think one would ever be able to do something, but
if I could at least find a way to let them save the form contents so
they don't have to start all over again...
The BACK button works sometimes, but some have reported (unconfirmed by
me) that it doesn't always return them to the filled out form before
they submit. One "solution" would be to have them save the form page
BEFORE they submit, BUT, I intentionally do not want them to do that,
because it would have the submit button on it, and I KNOW that some
"clever" bloke is gonna try to gippo the system by not going through the
whole process to generate the correct form (they all look the same , but
the hidden content differs, and are crucial,to the functionality of the
app)
So, it's a catch 22 I guess...
 

On Tue, 2003-07-01 at 15:18, Kristin Schesonka wrote:
> Hi :)
> 
> I'm actually working on an Multipart-Form and i'm saving all data during the
> "Fill-In" process in a Session - then, at the end, i save the whole
> sessiondata in my table.
> That will solve the connection-problems i hope . . .
> If I am wrong, please correct me :)
> 
> Greetings from Germany
> 
> Kristin Schesonka
> 
> 


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



Re: [PHP] Re: Form 2 PDF 2 Form

2003-07-01 Thread Petre Agenbag
Hi Kristin
Yes, of course that is a possibility, and it would surely address the
problem of "resuming" at a later stage. I'm just rather worried at
managing these "broken" submissions. They might start one, then for some
reason don't finish, and forget about it altogether...

But, I think my biggest problem is the way the app is currently working.
To have to change it to incorporate user-id's etc, would be almost as
big a task as trying to get the PDF thing to work, and unfortunately I
can't give you ALL the details of the app ( classified stuff and too
large anyway ;) ), I don't think it would be possible to do this.
But with PDF thing, I forsee that it *could* be possible, since one
would only change the process in one place, namely the form submit, iow,
I would "break" the process there, relay the process via another (PDF?)
route and re-connect at the submit phase. The coding would be difficult,
but the process to the user would seem to be identical, which it
probably wouldn't if I change the system to incorporate user-id's (and
possibly extra interfaces to view partial forms for a specific user)...
sound just too complicated atm (but don't get me wrong, I'm listening!
as I said in a previous comment, I'm not shooting down any ideas, I'm
just more biased towards ANYTHING that might help me out without
breaking the current process flow of the app...

Thanks again for the input, please continue!


On Tue, 2003-07-01 at 16:00, Kristin Schesonka wrote:
> Hmm, i don't know if you want it that way, but i got the idea of making the
> stuff personalized . . . I mean the user logges on and gets an Userid - then
> you always save your data with the Userid, so you can look which entries in
> your DB belong to this user and the user can start again at a different
> stage . . . .
> 
> Greetings
> 
> Kristin Schesonka
> 
> 


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



[PHP] Form variables not passed: register_globals = On

2002-08-12 Thread Petre Agenbag

Hi
I have posted here about session problems etc, but I think I found the
problem:
My Form variables are not passed at all!

Look at this:

index.php


  



page2.php

";
echo " POST_VARS: ".$_POST["test"]."";
echo " normal test :".$test."";
?>

I have installed a "everything" RedHat 7.3 installation, and changed
NOTHING to the default php.ini...


Can anyone help?





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




[PHP] Form variables not passing: globals IS on

2002-08-12 Thread Petre Agenbag

Sorry, posted with the wrong address, here it is again:

I have RH 7.3 with "everything" install, and I didn't make ANY changes
to the default php.ini, and have checked it and register_global = On

Now, when I make a simple form and action page combo, the variables are
not passed:
You can see from this example that I use to test that I use all methods
possible to check where the values are, but all return blank...




index.php

  


page2.php
";
echo " POST_VARS: ".$_POST["test"]."";
echo " normal test :".$test."";
?>

What could cause this?



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




[PHP] $HTTP_SESSION_VARS vs $_SESSION

2002-08-12 Thread Petre Agenbag

Hi
Me again

Still having problems with forms not sending variables, and session
variables dissapearing.

I have 2 systems, one older 4.0.3 PHP which is my main webserver, so all
scripts must comply with it...
And the other my development server with the latest 4.1.2

So, I'm trying to write scripts that will happily work on both, and I
understand that I must use HTTP_POST_VARS and HTTP_SESSION_VARS in order
to comply with 4.0.3.

register_globals and track_vars as well as trans_sid are enabled on
both.

Now, take a look at the example below:
index.php


  



page2.php

';
echo ' POST_VARS: '.$_POST["test"].'';
echo ' normal test :'.$test.'';
echo 'Session Value (only for
re-entry):'.$HTTP_SESSION_VARS["testing"].'';

if ($HTTP_POST_VARS["test"]) {
$HTTP_SESSION_VARS["testing"] = $HTTP_POST_VARS["test"];
}
echo 'Click';
?>

page3.php

';
echo 'Forward to test sess var further';
echo 'Back to test sess var';
?>

page4.php

';
echo 'Back to page 3 to test sess var
further';
echo 'Back to page 2 to test sess var';
?>

This small test works 100% on my newer system, and I was under the
impression that I coded it to be backwards compatible with my older
system, BUT, 

look here: http://www.linuxhelp.co.za/session_test to see what it does
on my working server. The scripts are identical.

Please can you point out my mistakes in reasoning?

Also, I want these scripts to work regardless of cookies, so if you see
something that might cause problems when ppl disable cookies, plz
advise.



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




Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION

2002-08-12 Thread Petre Agenbag

You lost me there...
Are you saying I don't need to access those variable in that way?
Can I simply use $variable in successive pages then?
Surely I MUST use that notation to assign values then right?, specially
to the session vars, right?

But, just out of curiosity, why does it work fine on my newer system?

Thanks

On Mon, 2002-08-12 at 21:17, Rasmus Lerdorf wrote:
> If register_globals is known to be on, why are you worrying about
> the $HTTP_* arrays?
> 
> On 12 Aug 2002, Petre Agenbag wrote:
> 
> > Hi
> > Me again
> >
> > Still having problems with forms not sending variables, and session
> > variables dissapearing.
> >
> > I have 2 systems, one older 4.0.3 PHP which is my main webserver, so all
> > scripts must comply with it...
> > And the other my development server with the latest 4.1.2
> >
> > So, I'm trying to write scripts that will happily work on both, and I
> > understand that I must use HTTP_POST_VARS and HTTP_SESSION_VARS in order
> > to comply with 4.0.3.
> >
> > register_globals and track_vars as well as trans_sid are enabled on
> > both.
> >
> > Now, take a look at the example below:
> > index.php
> >
> > 
> >   
> > 
> >
> >
> > page2.php
> >
> >  > session_start();
> > echo ' HTTP_POST_VARS :'.$HTTP_POST_VARS["test"].'';
> > echo ' POST_VARS: '.$_POST["test"].'';
> > echo ' normal test :'.$test.'';
> > echo 'Session Value (only for
> > re-entry):'.$HTTP_SESSION_VARS["testing"].'';
> >
> > if ($HTTP_POST_VARS["test"]) {
> > $HTTP_SESSION_VARS["testing"] = $HTTP_POST_VARS["test"];
> > }
> > echo 'Click';
> > ?>
> >
> > page3.php
> >
> >  > session_start();
> > echo 'Session Variable:'.$HTTP_SESSION_VARS["testing"].'';
> > echo 'Forward to test sess var further';
> > echo 'Back to test sess var';
> > ?>
> >
> > page4.php
> >
> >  > session_start();
> > echo 'Session Variable:'.$HTTP_SESSION_VARS["testing"].'';
> > echo 'Back to page 3 to test sess var
> > further';
> > echo 'Back to page 2 to test sess var';
> > ?>
> >
> > This small test works 100% on my newer system, and I was under the
> > impression that I coded it to be backwards compatible with my older
> > system, BUT,
> >
> > look here: http://www.linuxhelp.co.za/session_test to see what it does
> > on my working server. The scripts are identical.
> >
> > Please can you point out my mistakes in reasoning?
> >
> > Also, I want these scripts to work regardless of cookies, so if you see
> > something that might cause problems when ppl disable cookies, plz
> > advise.
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 


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




Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION

2002-08-12 Thread Petre Agenbag

Oh, almost forgot,
I *think* the reason why I'm still worrying about the $HTTP_* arrays are
because I *think* that it is the correct way to work with the vars once
register_globals is turned off ( which is where things are moving to
right?), and I don't want to re-code my scripts... 
Am I making sense?

On Mon, 2002-08-12 at 21:17, Rasmus Lerdorf wrote:
> If register_globals is known to be on, why are you worrying about
> the $HTTP_* arrays?
> 
> On 12 Aug 2002, Petre Agenbag wrote:
> 
> > Hi
> > Me again
> >
> > Still having problems with forms not sending variables, and session
> > variables dissapearing.
> >
> > I have 2 systems, one older 4.0.3 PHP which is my main webserver, so all
> > scripts must comply with it...
> > And the other my development server with the latest 4.1.2
> >
> > So, I'm trying to write scripts that will happily work on both, and I
> > understand that I must use HTTP_POST_VARS and HTTP_SESSION_VARS in order
> > to comply with 4.0.3.
> >
> > register_globals and track_vars as well as trans_sid are enabled on
> > both.
> >
> > Now, take a look at the example below:
> > index.php
> >
> > 
> >   
> > 
> >
> >
> > page2.php
> >
> >  > session_start();
> > echo ' HTTP_POST_VARS :'.$HTTP_POST_VARS["test"].'';
> > echo ' POST_VARS: '.$_POST["test"].'';
> > echo ' normal test :'.$test.'';
> > echo 'Session Value (only for
> > re-entry):'.$HTTP_SESSION_VARS["testing"].'';
> >
> > if ($HTTP_POST_VARS["test"]) {
> > $HTTP_SESSION_VARS["testing"] = $HTTP_POST_VARS["test"];
> > }
> > echo 'Click';
> > ?>
> >
> > page3.php
> >
> >  > session_start();
> > echo 'Session Variable:'.$HTTP_SESSION_VARS["testing"].'';
> > echo 'Forward to test sess var further';
> > echo 'Back to test sess var';
> > ?>
> >
> > page4.php
> >
> >  > session_start();
> > echo 'Session Variable:'.$HTTP_SESSION_VARS["testing"].'';
> > echo 'Back to page 3 to test sess var
> > further';
> > echo 'Back to page 2 to test sess var';
> > ?>
> >
> > This small test works 100% on my newer system, and I was under the
> > impression that I coded it to be backwards compatible with my older
> > system, BUT,
> >
> > look here: http://www.linuxhelp.co.za/session_test to see what it does
> > on my working server. The scripts are identical.
> >
> > Please can you point out my mistakes in reasoning?
> >
> > Also, I want these scripts to work regardless of cookies, so if you see
> > something that might cause problems when ppl disable cookies, plz
> > advise.
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 


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




Re: [PHP] $HTTP_SESSION_VARS vs $_SESSION - cont.

2002-08-13 Thread Petre Agenbag

Rasmus
OK, I think I understand the principle now, yet, when I implement id, my
app still fails.
I have register_golbals = on, BUT, I want to find a way to code that I
know will always work, regardless of register_globals or cookies, so
that I am only dependant on the trans-sid ( but If I could rule that out
too, it would be even better)

How do you write your apps so you know that they will work on most
configurations? I have a bunch of older apps that will definately break
if I upgrade the server and turn register_globals off, and I want to
prevent it from happening with new apps I write now.


With what you said below, can I assume that:
1) If I know all the variables that I will need to be session variables,
I can session_register() them all on the first page, and then simply
give them values during the normal flow of the app?

I have tried to implement what you said below in my app as follow,
basically the route is:
Login form --> action page:
action page links to another form page
form page --> action page

All these pages are supposed to be part of the session, but between the
last two pages, the session disappears, and the form doesn't pass
variables...

I'm so utterly fed-up with myself for not being able to get this right. 
Can you see ANYTHING that might cause this?


index.php



  

  Admin Login
  


  Username:
  
  
  


  Password:
  
  
  


  

  

  


Then: 
admin_select.php


 
  
  
Admin Interface
  
  
Please select Project to work with
  
  

";
while ($myrow = mysql_fetch_assoc($result)) {
$sess_project_name = $myrow["project_name"];
$sess_project_id = $myrow["id"];
echo ''.$sess_project_name;
}
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
} else {
echo 'There are currently no Projects on the system,';
echo 'please use the section below to add one';
echo '';
echo '';
echo '';
}


echo '

  
Add
a new Project
  

';

?>


This second page has two routes to go, either you select the document
from the drop_down, or you can "add a new project", It is with the
second route that I pick up further problems:

admin_add_project.php


  
  
Mafisa Admin Interface
  
  
New Project Name

  
  
Project Descriptions

  
  

  


';
?>

Now, on this last page that is supposed to insert the form data into the
db, there is simply no form data, or session variables!

admin_add_project_do.php
'.$project_name_db.' was added to the system. 
   Back';
?>

I really appreciate your time, and thanks in advance for your help.


On Mon, 2002-08-12 at 22:44, Rasmus Lerdorf wrote:
> No, you don't need to use HTTP_SESSION_VARS for anything if
> register_globals is on.  Sessions are very simple.  You start a session,
> and you register variables to be part of that session.  Like this:
> 
>  session_start();
>  session_register('a');
>  session_register('b');
> 
> If you have that at the top of the first page, then whatever values $a and
> $b have by the time the script finishes is what will be written to the
> session backend.
> 
> So, on a subsequent page you just do:
> 
>  session_start();
> 
> This will see the session ID that the browser passed to it either via a
> cookie or in the URL and it will go and restore the variables from the
> session backend.  That means that at this point you can just do:
> 
>  echo $a;
>  echo $b;
> 
> At no point is there any need for $HTTP_SESSION_VARS nor $_SESSION if you
> are sure that register_globals will always be on.
> 
> Now, if you want it to work with register_globals off, you still don't
> need to use $HTTP_SESSION_VARS when setting the variables, you only need
> to use it when retrieving them.  So, instead of echo $a and echo $b you
> would have:
> 
>  echo $HTTP_SESSION_VARS['a'];
>  echo $HTTP_SESSION_VARS['b'];
> 
> Or, of course in newer PHP's you can use $_SESSION['a'].
> 
> Your stuff probably didn't work because you were setting the session vars
> via the $HTTP_SESSION_VARS array.  That works now, but it probably didn't
> use to as it is a bit of a weird way to do it.
> 
> -Rasmus
> 
> On 12 Aug 2002, Petre Agenbag wrote:
> 
> > You lost me there...
> > Are you saying I don't need to access those variable in that way?
> > Can I simply use $variable

[PHP] Stumped: vars not passed!!!

2002-08-15 Thread Petre Agenbag

I'm going mad.

I've been trying to implement sessions so it will work backward on my
older 4.0.3 server ( I'm working on a 4.1.2), with no success as of yet,
but I think it's my 4.1.2 that's causing this, as the app in the
following example works perfectly on the older one.

Note, I have explicitly used the manual URl method to pass variables and
NOT the $HTTP_POST_VARS['x'] method as I am suspecting that my
register_globals is not working.

PS, register_globals, track vars etc IS on on both systems.

Look at this:

index.php




 

page1.php
Next


page2.php







page3.php
Username:  
Password:  
Test:  


This DOES NOT work on my 4.1.2 system.

Why?
I know page2 is not needed, but it is still supposed to work right? I
deliberatly put it there to "extend" the path the variable needs to
piggy back to see where I lose them, but on my system it loses the vars
right at the second page already


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




[PHP] 4.04 --> 4.1.2 incompatible

2002-08-20 Thread Petre Agenbag

Hi
Can someone please tell me what settings to check for on 4.1.2 in order
to ensure that scripts that runs on 4.0.4 will run on 4.1.2?

I HAVE checked registered_globals = on, but I still get variables that
are not passed on via URL and form submits.

The app has a "login" form that submits to an action page, on the action
page I generate a link that goes to another form, I append the username
and password to the end of the URL of the link on the action page, and
then create hidden fields that echo the username and password in the
subsequent form to be passed along with the extra form field to the last
page.

This whole process works 100% on 4.0.4, but breaks at the second page on
4.1.2 (ie, it DOESN't pass the username and password to the action page
from the form fields).

I need to resove this, as I have lots of applications that was written
in this way, and are currently working, but want to upgrade the server
to RedHat 7.3 that comes with 4.1.2 and don't want to end up with a
bunch of broken apps.

I know it's not the correct way to have coded, but it's done now, and
for now, I won't mind to have register_globals = On, although THAT
doesn't seem to be the solution...
Please advise.
Thanks

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




Re: [PHP] 4.04 --> 4.1.2 incompatible

2002-08-20 Thread Petre Agenbag

Yes, phpinfo() returns that register globals is ON...

On Tue, 2002-08-20 at 11:52, Thies C. Arntzen wrote:
> On Tue, Aug 20, 2002 at 11:28:55AM +0200, Petre Agenbag wrote:
> > Hi
> > Can someone please tell me what settings to check for on 4.1.2 in order
> > to ensure that scripts that runs on 4.0.4 will run on 4.1.2?
> > 
> > I HAVE checked registered_globals = on, but I still get variables that
> > are not passed on via URL and form submits.
> > 
> > The app has a "login" form that submits to an action page, on the action
> > page I generate a link that goes to another form, I append the username
> > and password to the end of the URL of the link on the action page, and
> > then create hidden fields that echo the username and password in the
> > subsequent form to be passed along with the extra form field to the last
> > page.
> > 
> > This whole process works 100% on 4.0.4, but breaks at the second page on
> > 4.1.2 (ie, it DOESN't pass the username and password to the action page
> > from the form fields).
> > 
> > I need to resove this, as I have lots of applications that was written
> > in this way, and are currently working, but want to upgrade the server
> > to RedHat 7.3 that comes with 4.1.2 and don't want to end up with a
> > bunch of broken apps.
> > 
> > I know it's not the correct way to have coded, but it's done now, and
> > for now, I won't mind to have register_globals = On, although THAT
> > doesn't seem to be the solution...
> > Please advise.
> > Thanks
> 
> have you checked that register_globals _is_ actually on? just
> look at the output of phpinfo();
> 
> re,
> tc
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




Re: [PHP] 4.04 --> 4.1.2 incompatible

2002-08-20 Thread Petre Agenbag

My oh my
OK, can someone help with this one???
My original Form conatined the following:

bla, bla


And then things broke, so, out of curiosity, I removed the enctype=""
part, and now it works/




On Tue, 2002-08-20 at 13:05, Thies C. Arntzen wrote:
> On Tue, Aug 20, 2002 at 12:01:24PM +0200, Petre Agenbag wrote:
> > Yes, phpinfo() returns that register globals is ON...
> 
> and does a simple testpage work?
> 
> 
> test.php
>  echo $hallo;
> ?>
> 
> http://localhost/test.php?hallo=test
> 
> should show a page containing the word test
> 
> re,
> tc
> > 
> > On Tue, 2002-08-20 at 11:52, Thies C. Arntzen wrote:
> > > On Tue, Aug 20, 2002 at 11:28:55AM +0200, Petre Agenbag wrote:
> > > > Hi
> > > > Can someone please tell me what settings to check for on 4.1.2 in order
> > > > to ensure that scripts that runs on 4.0.4 will run on 4.1.2?
> > > > 
> > > > I HAVE checked registered_globals = on, but I still get variables that
> > > > are not passed on via URL and form submits.
> > > > 
> > > > The app has a "login" form that submits to an action page, on the action
> > > > page I generate a link that goes to another form, I append the username
> > > > and password to the end of the URL of the link on the action page, and
> > > > then create hidden fields that echo the username and password in the
> > > > subsequent form to be passed along with the extra form field to the last
> > > > page.
> > > > 
> > > > This whole process works 100% on 4.0.4, but breaks at the second page on
> > > > 4.1.2 (ie, it DOESN't pass the username and password to the action page
> > > > from the form fields).
> > > > 
> > > > I need to resove this, as I have lots of applications that was written
> > > > in this way, and are currently working, but want to upgrade the server
> > > > to RedHat 7.3 that comes with 4.1.2 and don't want to end up with a
> > > > bunch of broken apps.
> > > > 
> > > > I know it's not the correct way to have coded, but it's done now, and
> > > > for now, I won't mind to have register_globals = On, although THAT
> > > > doesn't seem to be the solution...
> > > > Please advise.
> > > > Thanks
> > > 
> > > have you checked that register_globals _is_ actually on? just
> > > look at the output of phpinfo();
> > > 
> > > re,
> > > tc
> > > 
> > > -- 
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > 
> > 
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> Thies C. Arnzten   -   Looking for all sorts of freelance work  -   just ask..
> Whishlist:  http://www.amazon.de/exec/obidos/wishlist/AB9DY62QWDSZ
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




[PHP] Stepping through an array more than once

2002-08-28 Thread Petre Agenbag

Hi
I would like to do something like the following:

I have a table that contains a bunch of info at various "stages". To
optimize the load on the db, I was thinking it would be better to do a
"select * from table" , and then use PHP to sort through the results,
rather than have 3 SQL's with "where status="xxx" ".

There are essentially 3 "stages" or "states" at which the data in the
table can be sorted, so I would need to loop through the array 3 times
in order to display the entire contents of the table ordered by the 3
statges.

This is my first attempt:

$sql_it = 'select * from tickets ';
$result_it = mysql_query($sql_it);
echo 'New Tickets ';
$count = 0;
while ($myrow_it = mysql_fetch_assoc($result_it)) {
$status = $myrow_it["status"];
if ($status == "OPEN") {
$company = $myrow_it["company"];
$title = $myrow_it["title"];
$content = $myrow_it["content"];
echo $company.' :: '.$title.' :: '.$content.'';
$count++;
}
}
echo 'Total New:'.$count.'';


echo 'Current Tickets ';

while ($myrow_it = mysql_fetch_assoc($result_it)) {
$status = $myrow_it["status"];
if ($status == "CURRENT") {
$company = $myrow_it["company"];
$title = $myrow_it["title"];
$content = $myrow_it["content"];
echo $company.' :: '.$title.' :: '.$content.'';
}
}

echo 'Old Tickets ';

while ($myrow_it = mysql_fetch_assoc($result_it)) {
$status = $myrow_it["status"];
if ($status == "OLD") {
$company = $myrow_it["company"];
$title = $myrow_it["title"];
$content = $myrow_it["content"];
echo $company.' :: '.$title.' :: '.$content.'';
}
}





Now, obviously this only echoes the first part, as it seems the array is
at the end when it tries to loop through again.
I tried a reset($myrow_it) , but it drops an error about $myrow_it not
being an array.

I'm not sure if my logic here is correct. Is this the way to "re-loop"
the array?

Hope I explained what I am trying to do well enough.


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




Re: [PHP] Stepping through an array more than once

2002-08-28 Thread Petre Agenbag

Actually, it's not accurate for me to say "stepping through an array
more than once", as I want to step through the database ( $result) more
than once, without having to make connections to the db again.
Can this be done?

On Wed, 2002-08-28 at 13:58, Petre Agenbag wrote:
> Hi
> I would like to do something like the following:
> 
> I have a table that contains a bunch of info at various "stages". To
> optimize the load on the db, I was thinking it would be better to do a
> "select * from table" , and then use PHP to sort through the results,
> rather than have 3 SQL's with "where status="xxx" ".
> 
> There are essentially 3 "stages" or "states" at which the data in the
> table can be sorted, so I would need to loop through the array 3 times
> in order to display the entire contents of the table ordered by the 3
> statges.
> 
> This is my first attempt:
> 
> $sql_it = 'select * from tickets ';
> $result_it = mysql_query($sql_it);
> echo 'New Tickets ';
> $count = 0;
> while ($myrow_it = mysql_fetch_assoc($result_it)) {
> $status = $myrow_it["status"];
> if ($status == "OPEN") {
> $company = $myrow_it["company"];
> $title = $myrow_it["title"];
> $content = $myrow_it["content"];
> echo $company.' :: '.$title.' :: '.$content.'';
> $count++;
> }
> }
> echo 'Total New:'.$count.'';
> 
> 
> echo 'Current Tickets ';
> 
> while ($myrow_it = mysql_fetch_assoc($result_it)) {
> $status = $myrow_it["status"];
> if ($status == "CURRENT") {
> $company = $myrow_it["company"];
> $title = $myrow_it["title"];
> $content = $myrow_it["content"];
> echo $company.' :: '.$title.' :: '.$content.'';
> }
> }
> 
> echo 'Old Tickets ';
> 
> while ($myrow_it = mysql_fetch_assoc($result_it)) {
> $status = $myrow_it["status"];
> if ($status == "OLD") {
> $company = $myrow_it["company"];
> $title = $myrow_it["title"];
> $content = $myrow_it["content"];
> echo $company.' :: '.$title.' :: '.$content.'';
> }
> }
> 
> 
> 
> 
> 
> Now, obviously this only echoes the first part, as it seems the array is
> at the end when it tries to loop through again.
> I tried a reset($myrow_it) , but it drops an error about $myrow_it not
> being an array.
> 
> I'm not sure if my logic here is correct. Is this the way to "re-loop"
> the array?
> 
> Hope I explained what I am trying to do well enough.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




[PHP] Re: Stepping through an array more than once (offlist)

2002-08-28 Thread Petre Agenbag
e case, and not always
> worth worrying about, unless you've got a HUGE site with millions of hits a
> day... you just won't notice the benefit, in comparison to the advantage.
> 
> 
> Some pages on a site I'm working on right now, hinge.net.au, have 5-10
> queries on them, for sessions, users, content, data, counters, logging,
> message boards, etc etc.  And I've NEVER noticed a performance problem, or
> got any complaints.
> 
> 
> When you've got maybe 500 rows in there (or 5,000, or 50,000), it'd be nice
> to run an a/b test with a script timer, and get some averages to find out
> definitively.
> 
> 
> Enjoy,
> 
> Justin
> 
> 
> 
> on 28/08/02 11:16 PM, Petre Agenbag ([EMAIL PROTECTED]) wrote:
> 
> > Justin, 
> > Thanks for the reply.
> > I frequently see your comments on threads here, and don't worry, I
> > wouldn't take any as insults as I can see you want to help, and I
> > appreciate that!
> > 
> > So, you are more than welcome to show me alternatives, I am by no means
> > an ace programmer, and I eagerly lap up all comments and suggestions.
> > 
> > I will try the suggestion, and will report back.
> > 
> > Just to sort of explain my thinking process.
> > I would think that limiting queries to a db to the absolute minimum
> > would be the "best", BUT, I can now see that there are no easy way, as
> > the IF iterations clearly show...
> > 
> > I would me very interested in your suggestions as to "cleaning" up the
> > code, for I have seen plenty of examples where you can write the same
> > functionality in many many different ways, and the only difference is
> > normally in the way people think about the problem and the solution.
> > It can't be taught,and will only come with experience, which I can
> > hopefully get a head start on with this list...
> > 
> > Thanks alot.
> > 
> > On Wed, 2002-08-28 at 14:52, Justin French wrote:
> >> Try unset($myrow_it).
> >> 
> >> You don't want to reset the array, you want to clear it, then use a new
> >> array (with the same name, and the same $result) for another while loop.
> >> 
> >> FWIW, I'm pretty sure I'd just use three distinct queries.  Infact, it'd be
> >> worth you timing your scripts with both these versions to see what works out
> >> quicker -- three queries, or lots of if() statements [remember, you're in a
> >> while loop, so 5000 rows * 3 if statements = 15000!!]
> >> 
> >> Put this at the top:
> >> 
> >>  >> $show_timer = 1;
> >> function getmicrotime()
> >> { 
> >> list($usec, $sec) = explode(" ",microtime());
> >> return ((float)$usec + (float)$sec);
> >> } 
> >> $time_start = getmicrotime();
> >> ?>
> >> 
> >> And this at the end:
> >> 
> >>  >> if($show_timer)
> >> {
> >> $time_end = getmicrotime();
> >> $timer = $time_end - $time_start;
> >> echo "Timer: {$timer}";
> >> }
> >> ?>
> >> 
> >> Run the script with both versions about 10 times each, and take the average
> >> :)
> >> 
> >> 
> >> There are many many ways I can see that you could clean up and optimise the
> >> script you've shown (not intended as an insult AT ALL!) -- quite possibly
> >> some of these would make more of a difference to your performance than
> >> limiting yourself to just one query... at the very least, it would make
> >> updating the script easier, and reduce the lines of code.
> >> 
> >> 
> >> Good luck,
> >> 
> >> Justin French
> >> 
> >> 
> > 
> 


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




Re: [PHP] Re: Stepping through an array more than once (offlist)

2002-08-28 Thread Petre Agenbag

Jason
Sorry, I completely forgot to comment on your suggestion:

I did try mysql_data_seek(), but it didn't work for me ( guess I don't
know how exactly it works), BUT, it did look like it was meant for
stepping through a one dimensional array, and $result is not a one
dimensional array, right?
Maybe I'm just not thinking correctly, 
Justin has also just commented on your suggestion and he seems to give
some sort of an "implementation" of using mysql_data_seek(), maybe it
will explain it a better for me, I'll quickly see if I can get it to
work.

Thanks for the input!

On Thu, 2002-08-29 at 08:46, Jason Wong wrote:
> On Thursday 29 August 2002 14:16, Petre Agenbag wrote:
> > Hi Justin
> > OK, a quick feedback on your previous suggestion:
> >
> > I tried to unset the $myrow_it, but it still didn't produce any output.
> > The only way I could get it to work was with the same method you
> > suggested in this e-mail.
> > I had to create 2 new vars ( which basically boils down to 2 more
> > SQL's).
> 
> [snip]
> 
> I've said it once already:
> 
>   mysql_data_seek()
> 
> -- 
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> 
> /*
> Heller's Law:
>   The first myth of management is that it exists.
> 
> Johnson's Corollary:
>   Nobody really knows what is going on anywhere within the
>   organization.
> */
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




Re: [PHP] Re: Stepping through an array more than once (offlist)

2002-08-28 Thread Petre Agenbag

Jason
Thanks
the mysql_data_seek() works.
With Justin's help, I used the mysql_data_seek() to reset the $result
"matrix" to 0, and re-issued the same while statement.
It now produces the desired output.
Thanks.

On Thu, 2002-08-29 at 08:46, Jason Wong wrote:
> On Thursday 29 August 2002 14:16, Petre Agenbag wrote:
> > Hi Justin
> > OK, a quick feedback on your previous suggestion:
> >
> > I tried to unset the $myrow_it, but it still didn't produce any output.
> > The only way I could get it to work was with the same method you
> > suggested in this e-mail.
> > I had to create 2 new vars ( which basically boils down to 2 more
> > SQL's).
> 
> [snip]
> 
> I've said it once already:
> 
>   mysql_data_seek()
> 
> -- 
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> 
> /*
> Heller's Law:
>   The first myth of management is that it exists.
> 
> Johnson's Corollary:
>   Nobody really knows what is going on anywhere within the
>   organization.
> */
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




[PHP] "autocomplete" list box

2002-08-30 Thread Petre Agenbag

Hi
I am wondering if it is possible to write/create/implement an
"autocomplete" type list box, something that will basically work the
same as when you have a normal textbox in a form and have "autocomplete"
enabled in the browser, but not quite exactly, I want the textbox and
the listbox to be "combined" and browser independant.

Is this possible? Dependant/do-able with PHP or is it a Java/Browser
feature?

Thanks.



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




Re: [PHP] dumping mysql database with php script

2002-09-02 Thread Petre Agenbag

put the exec(...) line OUTSIDE the while loop.As your codeis now, it's
dumping with each new row , so i'ts overwriting itself.

On Mon, 2002-09-02 at 09:47, [EMAIL PROTECTED] wrote:
> 
> I am having a problem with a script to dump a mysql database to a text
> file. When I run the command below it creates the database.sql file but
> it only puts the first three lines in that file they look like this
> # MySQL dump 8.13
> #
> # Host: localhostDatabase: testdata1
> #
> # Server version3.23.37
> 
> 
> If I run the following at the command line it work perfect passing the whole
> database to the txt file
> /usr/bin/mysqldump -u testdata1 -ptestdata1 testdata1
> > /home/sites/www.directphp.net/sitebackup/databases/testdata1.sql
> 
> Why is it stopping on the third line when I run it with a PHP script
> 
> This is my script
> 
> while($row = mysql_fetch_array($result)){
> $databasename=$row["databasename"];
> $databaseusername=$row["$databaseusername"];
> $databasepassword=$row["$databasepassword"];
> 
> exec("/usr/bin/mysqldump -u $databaseusername -p$databasepassword $databasename >
> $Databasesdir/$databasename.sql");
> }
> 
> 
>   
> 
> -- 
> Best regards,
>  rdkurth  mailto:[EMAIL PROTECTED]
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




Re: [PHP] finding next and previous db entries

2002-09-05 Thread Petre Agenbag

I think it would probably be better to read all the id's into an array,
and then use the array stepping functions to move forward or back. This
way, you won't have to worry about "empty" rows, or id's that are not
numerically following on each other.

On Thu, 2002-09-05 at 23:20, tux wrote:
> 
> hey all,
> 
> if im displaying pages with data from a database eg 
> 
> www.domain.com/file.php?id=40
> 
> on that page i would like to have a previous and next link that would
> take it to id 41 and 39 respectively, the only problem being what if 39
> or 41 was empty? then i would want the link to be id=42 or id=38.. is
> the best way to do this just loop through the id's until it finds a
> entry that isnt empty? or is there any functions for this?
> 
> jo
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




[PHP] dropping mail into queue

2002-09-08 Thread Petre Agenbag

Hi list
Is is possible to change the default behaviour of the mail() function to
send the message to the queue instead of trying to send it immediately? 
I did do some research into this a while back, but it never really got
to a point where I was completely satisfied with the results. I can
recall from then that the behaviour of the mail() function was inherited
from the way sendmail was configured on the server, but I cannot go that
route ( ie, reconfigure sendmail to send all mail requests to the queue,
as the server is not only a webserver, but servers my clients normal
e-mail as well), so I'm basically asking if it is possible to "override"
the sendmail behaviour when you issue the mail() function, or to even
compose and write the message directly to the /var/spool/mqueue folder (
that would obviously NOT use the mail() function).
The reason for all this is that there are some clients that are
abusing/miss-using the mail() function to query a mysql db of 20K users
with a while() loop and then doing a mail() inside the while, this is
causing some serious problems on my server, and I'm trying to look for
ways to put a tab on this.So any other suggestions are also very
welcome.
Thanks




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




Re: [PHP] pretty simple problem in mailing a dynamic page

2002-09-25 Thread Petre Agenbag

You need to add another header telling it the content type = text/html

On Wed, 2002-09-25 at 17:04, usha wrote:
> I just want to email a dynamic page ( So I designed a page consisting  of datas 
>pulled from db and are formated with html tags: here in below code $d is such 
>variable to be mailed)
> 
> But the problem is that, instead the code contained in $d is sent.
> 
> The code is as such:
> $ebody="$d";
> mail("[EMAIL PROTECTED]", "The subject",$ebody,"From: [EMAIL PROTECTED]\r\n");
> 
> Cna anyone give me solution for this pretty simple problem.
> Regards
> Usha


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




[PHP] how to setup mysql logging from php scripts

2002-10-16 Thread Petre Agenbag

Hi
I need to be able to see logs of all mysql queries from php scripts on
my server.
I have a multitude of virtual hosts on my RedHat server, with many mysql
db's, and would like to be able to see what queries are done against the
db's from which scripts. The reason being is that I suspect that some of
the scripts on some domains are causing problems, for example infinite
loop db queries etc. Yesterday again I had mysql freeze up completely on
the server, and the only "interaction" with mysql are from php scripts
on the various domains, so looking at the mysql.log file gives no help.

Ideally I would like to see something like the following logged:

time || path/to/script.php || sql_query || mysql_error

or ANYthing that will help me to determine what went wrong.
At the moment I can merely blame the gremlins, and I don't know if it is
a poorly written script causing this or not, so I can't do anything
about the situation...
ANY suggestions or methods being used by ppl out there are also welcome.

Thanks alot.

 




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




[PHP] exploding values into new variables

2002-10-28 Thread Petre Agenbag
Hi
The manual states:

$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);

So, if I want to be able to echo piece1 to the screen at a later stage,
I would go:

echo $pieces[0];

or 
$first_piece = $pieces[0];
echo $first_piece;

Right?

Just want to make sure I understand it before I try to use it...


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




  1   2   >