Re: [PHP-DB] mysql to postgres migration blues...

2004-09-23 Thread Antoine
On Thu, 23 Sep 2004 12:23:32 -0700, Andrew Kreps <[EMAIL PROTECTED]> wrote:
> On Thu, 23 Sep 2004 20:51:52 +0200, Antoine <[EMAIL PROTECTED]> wrote:
> > declaring it as global didn't seem to work -
> >
> > global $link;
> > /* Connect to database */
> > $link = pg_connect("dbname=movies host=localhost user=anton
> > password=password")
> 
> The global keyword works a little bit differently in PHP.  You need to
> inform your function that your variable is global, as opposed to
> declaring it as global outside the function.  Like:
> 
> $link = "database connection"
> 
> function processData () {
> global $link;
> ...

Like i said, I'll get there ;-). Cheers! I hope you folks don't mind
answering some rather basic questions... I am going to be starting
some serious development soon and promise to search the docs first
:-).
I have just followed up on the suggestion of pear and it looks like a
winner. That may mean a change of mailing list but all good for the
moment.
Cheers
Antoine

-- 
G System, The Evolving GUniverse - http://www.g-system.at

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



Re: [PHP-DB] mysql to postgres migration blues...

2004-09-23 Thread Andrew Kreps
On Thu, 23 Sep 2004 20:51:52 +0200, Antoine <[EMAIL PROTECTED]> wrote:
> declaring it as global didn't seem to work -
> 
> global $link;
> /* Connect to database */
> $link = pg_connect("dbname=movies host=localhost user=anton
> password=password")

The global keyword works a little bit differently in PHP.  You need to
inform your function that your variable is global, as opposed to
declaring it as global outside the function.  Like:

$link = "database connection"

function processData () {
global $link;
...
}

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



Re: [PHP-DB] mysql to postgres migration blues...

2004-09-23 Thread Antoine
On Thu, 23 Sep 2004 22:27:38 +0400, M Saleh EG <[EMAIL PROTECTED]> wrote:
> define the connection object as a global var in ur function
> 
> function ( params)
> {
>  global $ur_connection_obj;
>  ...
> ...
> 
Damn you guys are quick! I like this list...
declaring it as global didn't seem to work - 

global $link;
/* Connect to database */
$link = pg_connect("dbname=movies host=localhost user=anton
password=password")
or die("Could not connect : " . pg_result_error($link));

still didn't get it but passing it to the function did. I'll get
there, but I pretty much copied and pasted all the php up until now so
I have a little way to go...
Cheers
Antoine


-- 
G System, The Evolving GUniverse - http://www.g-system.at

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



Re: [PHP-DB] mysql to postgres migration blues...

2004-09-23 Thread M Saleh EG
define the connection object as a global var in ur function

function ( params)
{
 global $ur_connection_obj;
 ...
...
}


On Thu, 23 Sep 2004 14:56:10 -0300, Eduardo Sampaio <[EMAIL PROTECTED]> wrote:
> Its because the function cannot access your connection object...
> Try passing it to the function..
> 
> function makelistboxentries($link, $title, $mytable, $mycolumn, $othertable,
> $wherestring)
> 
> 
> 
> 
> On Thu, 23 Sep 2004 19:44:51 +0200, Antoine <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I am trying to get skilled up on postgres and decided to port a little
> > movie database I wrote for mysql with php to access it.
> > I used an auto converter for the bulk and then tried to tweak. The
> > following code does not work but the error message it gives me is
> > strange. It tells me that the connection string used on line 82 (where
> > it calls pg_query in makelistboxentries) is invalid... but the same
> > string/connection works just great in another script... any pointers
> > appreciated.
> > Cheers
> > Antoine
> >
> >  >
> >/* Connect to database */
> >$link = pg_connect("dbname=movies host=localhost user=anton
> > password=password")
> >or die("Could not connect : " . pg_result_error($link));
> >
> > print << > 
> > Search by:
> > 
> > 
> > 
> > ID:
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Name:
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > TII;
> > makelistboxentries("Audio Language", "lang", "lang", " audio ", "
> > t2.movie = t1.ID and t2.lang = ");
> > makelistboxentries("Subtitle Language", "lang", "lang", " subtitles ",
> > " t2.movie = t1.ID and t2.lang = ");
> > makelistboxentries("Genre", "Genre", "Genre", " moviegenre ", "
> > t2.movie = t1.ID and t2.genre = ");
> >
> > print << > 
> > 
> > 
> > Show All:
> >  > method="post">
> > 
> > 
> > 
> > 
> >Back to main page
> >Add a movie
> >Add a movie's audio languages
> >Add a movie's subtitle languages
> >Search the movies
> > 
> > TINI;
> >/* Close connection */
> >pg_close($link);
> >
> > function makelistboxentries($title, $mytable, $mycolumn, $othertable,
> > $wherestring)
> > {
> >
> > print "";
> >
> > print "$title:";
> >/* Perform SQL query */
> >$query = "SELECT $mycolumn FROM $mytable";
> >$result = pg_query($link,$query)
> >or die("Query failed : " . pg_result_error($link));
> >print "";
> >print "";
> >print "Select $title";
> >while ($line = pg_fetch_array($result,$result_countt++,PGSQL_ASSOC)) {
> >foreach ($line as $col_value) {
> >print ("");
> >print $col_value;
> >print ("");
> >}
> >
> >}
> > print "";
> > print "";
> > print "";
> > print "";
> > print "";
> >
> >pg_free_result($result);
> > }
> >
> > ?>
> >
> > --
> > G System, The Evolving GUniverse - http://www.g-system.at
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



-- 
M.Saleh.E.G
97150-4779817

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



Re: [PHP-DB] mysql to postgres migration blues...

2004-09-23 Thread Eduardo Sampaio
Its because the function cannot access your connection object...
Try passing it to the function..

function makelistboxentries($link, $title, $mytable, $mycolumn, $othertable,
$wherestring)


On Thu, 23 Sep 2004 19:44:51 +0200, Antoine <[EMAIL PROTECTED]> wrote:
> Hi,
> I am trying to get skilled up on postgres and decided to port a little
> movie database I wrote for mysql with php to access it.
> I used an auto converter for the bulk and then tried to tweak. The
> following code does not work but the error message it gives me is
> strange. It tells me that the connection string used on line 82 (where
> it calls pg_query in makelistboxentries) is invalid... but the same
> string/connection works just great in another script... any pointers
> appreciated.
> Cheers
> Antoine
> 
>  
>/* Connect to database */
>$link = pg_connect("dbname=movies host=localhost user=anton
> password=password")
>or die("Could not connect : " . pg_result_error($link));
> 
> print << 
> Search by:
> 
> 
> 
> ID:
> 
> 
> 
> 
> 
> 
> 
> 
> Name:
> 
> 
> 
> 
> 
> 
> 
> TII;
> makelistboxentries("Audio Language", "lang", "lang", " audio ", "
> t2.movie = t1.ID and t2.lang = ");
> makelistboxentries("Subtitle Language", "lang", "lang", " subtitles ",
> " t2.movie = t1.ID and t2.lang = ");
> makelistboxentries("Genre", "Genre", "Genre", " moviegenre ", "
> t2.movie = t1.ID and t2.genre = ");
> 
> print << 
> 
> 
> Show All:
>  method="post">
> 
> 
> 
> 
>Back to main page
>Add a movie
>Add a movie's audio languages
>Add a movie's subtitle languages
>Search the movies
> 
> TINI;
>/* Close connection */
>pg_close($link);
> 
> function makelistboxentries($title, $mytable, $mycolumn, $othertable,
> $wherestring)
> {
> 
> print "";
> 
> print "$title:";
>/* Perform SQL query */
>$query = "SELECT $mycolumn FROM $mytable";
>$result = pg_query($link,$query)
>or die("Query failed : " . pg_result_error($link));
>print "";
>print "";
>print "Select $title";
>while ($line = pg_fetch_array($result,$result_countt++,PGSQL_ASSOC)) {
>foreach ($line as $col_value) {
>print ("");
>print $col_value;
>print ("");
>}
> 
>}
> print "";
> print "";
> print "";
> print "";
> print "";
> 
>pg_free_result($result);
> }
> 
> ?>
> 
> --
> G System, The Evolving GUniverse - http://www.g-system.at
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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



RE: [PHP-DB] mysql to postgres migration blues...

2004-09-23 Thread Bastien Koert
Could be a scope problem. The connection is declared outside the function 
and the attempt to run a query is inside the function...Maybe add the global 
command to the connection. Or declare the connection inside the function...

Bastien
From: Antoine <[EMAIL PROTECTED]>
Reply-To: Antoine <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [PHP-DB] mysql to postgres migration blues...
Date: Thu, 23 Sep 2004 19:44:51 +0200
Hi,
I am trying to get skilled up on postgres and decided to port a little
movie database I wrote for mysql with php to access it.
I used an auto converter for the bulk and then tried to tweak. The
following code does not work but the error message it gives me is
strange. It tells me that the connection string used on line 82 (where
it calls pg_query in makelistboxentries) is invalid... but the same
string/connection works just great in another script... any pointers
appreciated.
Cheers
Antoine

/* Connect to database */
$link = pg_connect("dbname=movies host=localhost user=anton
password=password")
or die("Could not connect : " . pg_result_error($link));
print <<
Search by:



ID:








Name:







TII;
makelistboxentries("Audio Language", "lang", "lang", " audio ", "
t2.movie = t1.ID and t2.lang = ");
makelistboxentries("Subtitle Language", "lang", "lang", " subtitles ",
" t2.movie = t1.ID and t2.lang = ");
makelistboxentries("Genre", "Genre", "Genre", " moviegenre ", "
t2.movie = t1.ID and t2.genre = ");
print <<


Show All:





Back to main page
Add a movie
Add a movie's audio languages
Add a movie's subtitle languages
Search the movies

TINI;
/* Close connection */
pg_close($link);
function makelistboxentries($title, $mytable, $mycolumn, $othertable,
$wherestring)
{
print "";
print "$title:";
/* Perform SQL query */
$query = "SELECT $mycolumn FROM $mytable";
$result = pg_query($link,$query)
or die("Query failed : " . pg_result_error($link));
print "";
print "";
print "Select $title";
while ($line = pg_fetch_array($result,$result_countt++,PGSQL_ASSOC)) {
foreach ($line as $col_value) {
print ("");
print $col_value;
print ("");
}
}
print "";
print "";
print "";
print "";
print "";
pg_free_result($result);
}
?>

--
G System, The Evolving GUniverse - http://www.g-system.at
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
Take advantage of powerful junk e-mail filters built on patented Microsoft® 
SmartScreen Technology. 
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines 
 Start enjoying all the benefits of MSN® Premium right now and get the 
first two months FREE*.

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