global variable problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



hi everybody,

i'm making a little testscript that uses adodb to connect via PHP4 to a 
postgresql 7.2 db. something like this:

=== file index.php ===
<?php
include_once('adodb/adodb.inc.php');
$conn=ADONewConnection('postgres7');
if (@$conn->PConnect('localhost','username', 'password', 'dbname')) {
  include("show.php");
}
?>
=== eof ==============

=== file show.php ===
<?php
switch ($action) {
  case start:
    start();
    break;
  case listing:
    listing($bereik);
    break;
  default:
    start();
    break;
}

function start() {
  global $conn;
  echo "<h2>Choose a letter</h2>\n";
  $lett=array(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z);
  foreach ($lett as $i) {
    echo "\n\t<a href='show.php?action=listing&range=$i'>$i</a> ";
  }
}

function listing($range) {
  global $conn;
  echo "<h2>Range: ", $range, "</h2>\n";
  $rs=$conn->Execute("select * from rolo where name like '$range%'");
}
?>
=== eof ==============

that's all. the idea is that the users clicks a letter, the function 
listing() is called, and a selection is made. the problem is the 
visibility of $conn. it's visible in index.php and in start(), but in 
listing() it's gone!?! the line $rs=$conn->exectute in listing() 
produces an error "call to a member of a non-object".

what am i doing wrong? how do i make $conn visible in listing()? TIA 
for any pointers / help!

-- 
Jules Alberts


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux