Re: [PHP] Non-functioning db 'include'

2002-09-23 Thread Geoff

Once you go to https://www.yoursite.com
you are at a completely new url as far as the browser is concerned so
you need to include using the full
http://www.yoursite.com/yourinclude.inc syntax or throw another copy of
your include db file in your directory for secure serving

Not sure if this is what you are referring to but hope it helps   

On Mon, 2002-09-23 at 09:15, Andre Dubuc wrote:
 I've streamlined all files by using an include for db access. 
 Everything works except the main registration file which is set to 
 https.
 
 When I 'include' a file, the db access doesn't work: all other input that 
 accesses the db does, except for one that first calls a 'randomizer' 
 function, then an include to the db.
 
 Any ideas why this doesn't work? I figure it must have something to do with 
 switching from https (the reg'n file) http (the randomizer file  dbc file) 
  https (back to the reg'n file).
 
 Any suggestions on how to fix this? Any help, advice, or suggestions 
 gratefully accepted.
 
 Code follows:
 
 /* This is the 'randomizer' script called by require */
 ?php 
 
 # return a randomly-generated string with input length
 # Blake Caldwell [EMAIL PROTECTED]
 function randomString($length=15){
   static $srand;
   if($srand != true){
   $srand = true;
   srand((double)microtime()*100); # only seed once!
   }
   $chars =
  1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ;
   for($i=0; $i$length; $i++){
   $result .= substr($chars,rand(0,strlen($chars)-1),1);
   }
   return $result;
 }
 
 ?
 
 /* This script works (with '$db = .' )  */
 ?php
 . . .
 require(randomizer.php);
 
 $_SESSION['unique_id'] = randomString(15);
 
   $db = pg_connect(dbname=purgatory user=postgres);
 . . .
 ?
 
 /* This script DOESN'T work (with 'include(dbc.php);  and where dbc.php' = 
 ?php $db = pg_connect(dbname=purgatory user=postgres); ? in a separate 
 file */
 ?php
 . . .
 require(randomizer.php);
 
 $_SESSION['unique_id'] = randomString(15);
   include(dbc.php);
 . . .
 ?
 
 Tia,
 Andre
 
 -- 
 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] Non-functioning db 'include'

2002-09-23 Thread Andre Dubuc

Thanks Geoff,

I tried what you suggested, but now the db burps the stuff back. Perhaps, for 
two lousy lines of code, I'll leave it as it is. Too much trouble to figure 
why it doesn't like it without actually having the site live. Right now 
everything passes through 'localhost' which has been extraordinarly 'fussy' 
lately.

Thanks for the suggestion.
Regards,
Andre

On Monday 23 September 2002 10:33 am, Geoff wrote:
 Once you go to https://www.yoursite.com
 you are at a completely new url as far as the browser is concerned so
 you need to include using the full
 http://www.yoursite.com/yourinclude.inc syntax or throw another copy of
 your include db file in your directory for secure serving

 Not sure if this is what you are referring to but hope it helps

 On Mon, 2002-09-23 at 09:15, Andre Dubuc wrote:
  I've streamlined all files by using an include for db access.
  Everything works except the main registration file which is set to
  https.
 
  When I 'include' a file, the db access doesn't work: all other input that
  accesses the db does, except for one that first calls a 'randomizer'
  function, then an include to the db.
 
  Any ideas why this doesn't work? I figure it must have something to do
  with switching from https (the reg'n file) http (the randomizer file 
  dbc file)
 
   https (back to the reg'n file).
 
  Any suggestions on how to fix this? Any help, advice, or suggestions
  gratefully accepted.
 
  Code follows:
 
  /* This is the 'randomizer' script called by require */
  ?php
 
  # return a randomly-generated string with input length
  # Blake Caldwell [EMAIL PROTECTED]
  function randomString($length=15){
  static $srand;
  if($srand != true){
  $srand = true;
  srand((double)microtime()*100); # only seed once!
  }
  $chars =
   1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ;
  for($i=0; $i$length; $i++){
  $result .= substr($chars,rand(0,strlen($chars)-1),1);
  }
  return $result;
  }
 
  ?
 
  /* This script works (with '$db = .' )  */
  ?php
  . . .
  require(randomizer.php);
 
  $_SESSION['unique_id'] = randomString(15);
 
  $db = pg_connect(dbname=purgatory user=postgres);
  . . .
  ?
 
  /* This script DOESN'T work (with 'include(dbc.php);  and where
  dbc.php' = ?php $db = pg_connect(dbname=purgatory user=postgres); ?
  in a separate file */
  ?php
  . . .
  require(randomizer.php);
 
  $_SESSION['unique_id'] = randomString(15);
  include(dbc.php);
  . . .
  ?
 
  Tia,
  Andre
 
  --
  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