From: | Helgi Örn Helgason <sacredeagle(at)gmail(dot)com> |
---|---|
To: | PostgreSQL - newbie <pgsql-novice(at)postgresql(dot)org> |
Subject: | MySQL --> PostgreSQL with PHP |
Date: | 2010-10-08 21:42:11 |
Message-ID: | AANLkTinPv2CroNaZndDdeaPG6T6nGnKz-3Psjih3d_da@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi!
I've been trying to convert this PHP-query thing that I used to run on
the project I am moving from MySQL to Postgres. I've done as good as I
can but it just doesn't work. I believe my MySQL --> Postgres
translation is to blame.
There is no error message in the browser.
Anyone who can spot what I'm doing wrong here?
-----------------------------------------------------------------------
<?php
// Producing simple table output with PostgreSQL
// Show from timmar in an HTML <table>
function displayTimmar($result)
{
print "<h3 align=center>Arbetstider - Ekolådans Packavdelning</h3><br />\n";
// Start a table, with column headers
print "\n<table>\n<tbody>\n<tr>\n" .
"\n\t<th style>ID</th>" .
"\n\t<th>Datum</th>" .
"\n\t<th>Vecka</th>" .
"\n\t<th>Dag</th>" .
"\n\t<th>P|T|S</th>" .
"\n\t<th>Namn</th>" .
"\n\t<th>Tid in</th>" .
"\n\t<th>Tid ut</th>" .
"\n\t<th>Lunch</th>" .
"\n</tr>";
// Until there are no rows in the result set, fetch a row into
// the $row array and ...
while ($row = @ pg_fetch_row($result))
{
// Start a TABLE row
print "\n<tr>";
// Print out each of the attributes in that row as a
// separate TD (Table Data).
foreach($row as $data)
print "\n\t<td> {$data} </td>";
// Finish the row
print "\n</tr>";
}
// Then, finish the table
print "\n</tbody>\n</table>\n";
}
$query = "SELECT * FROM timmar";
// Connect to the PostgreSQL server
if (!($connection = @ pg_connect($hostName, $username, $password)))
die("Cannot connect");
if (!(pg_select_db($databaseName, $connection)))
showerror( );
// Run the query on the connection
if (!($result = @ pg_query ($query, $connection)))
showerror( );
// Display the results
displayTimmar($result);
?>
-----------------------------------------------------------------------
--
PostgreSQL 8.4.4, Ubuntu Linux 10.04, Firefox 3.6.10
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Kelly | 2010-10-08 22:47:06 | Re: MySQL --> PostgreSQL with PHP |
Previous Message | Thangalin | 2010-10-08 18:30:08 | Re: PostgreSQL data types mapped Java classes for JDBC |