Re: [PHP-DB] Question about database design

2007-10-24 Thread Tony Grimes
A second address table is definitely the way to go (the '*' signifies the
primary key):

People Table

*user_id
first_name
last_name
etc

Address Table (compound primary key)
=
*user_id (fk to People Table)
*address_id
*obs_no (you can skip this if you don't want to keep an address history)
active_ind (is the row currently active or "deleted"?)
effective_date
expiry_date
address_line_1
address_line_2
city
etc

So say a user lives in the north from Mar to Sept and in the South from Oct
to Feb, your two rows would look like this:

Row 1
=
*john_doe (I prefer natural keys to surrogate)
*north
*1
Y
2007-03-01
2007-10-01
blah
blah

Row 2
=
*john_doe
*south
*1
Y
2007-10-01
2007-03-01
blah
blah

If you want to keep a history of past addresses, just add a new row with an
obs_no of 2 and set the active_ind to 'N' for the old row. All your queries
will have to contain a where clause (active_ind = 'Y') to keep the old rows
from showing up.

I hope this helps.

Tony


On 10/24/07 7:30 AM, "Bastien Koert" <[EMAIL PROTECTED]> wrote:

> 
> I would approach this by having a main people table (with a unique id of
> course) and then create a second addresses table which uses the people Id key
> as the foreign key to this table...then you can have multiple (more than two)
> addresses for those users, you could add a season in the addresses to be able
> to pull the correct one based on date

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



Re: [PHP-DB] PG: Table last updated?

2007-10-23 Thread Tony Grimes
I'm not sure. How can I tell? This database is running on a different server
than the one that created the data. I'm trying to restore a fried server
from a backup. Not sure if that matters.

Tony


On 10/23/07 6:20 PM, "Bastien Koert" <[EMAIL PROTECTED]> wrote:

> 
> Is logging turned on?
> 
> bastien
> 
> 
> > Date: Tue, 23 Oct 2007 16:12:14
> -0600> From: [EMAIL PROTECTED]> To: php-db@lists.php.net> Subject:
> [PHP-DB] PG: Table last updated?>> We've got a huge table in one of our
> Postgres databases and nobody seems to> know what it's for. Do any of the
> system tables keep track of the last time> the table was altered (i.e. Row
> INSERTs, UPDATEs, etc)?>> Tony>> --> PHP Database Mailing List
> (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>
> 
> _
> R U Ready for Windows Live Messenger Beta 8.5? Try it today!
> http://entertainment.sympatico.msn.ca/WindowsLiveMessenger
> --
> 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



[PHP-DB] PG: Table last updated?

2007-10-23 Thread Tony Grimes
We've got a huge table in one of our Postgres databases and nobody seems to
know what it's for. Do any of the system tables keep track of the last time
the table was altered (i.e. Row INSERTs, UPDATEs, etc)?

Tony

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



Re: [PHP-DB] Remote DB Connection: Pros and Cons?

2007-10-12 Thread Tony Grimes
Thank you all for the responses. I think we're going to try replicating the
databases with Slony. Wish me luck!

Tony


On 10/11/07 6:23 PM, "Chris" <[EMAIL PROTECTED]> wrote:

> Tony Grimes wrote:
>> Splitting the tables probably wouldn't work. Most of the tables are used by
>> both sites and the ones that aren't are tied to the rest by foreign keys.
>> 
>> Most of the updates are done from the admin site, so we're toying with the
>> idea of creating a read-only data warehouse for the website. The sync would
>> be one way from main office db to the warehouse (say, every 10 minutes).
> 
> No need to create something that has already been done.
> 
> Use slony or something to replicate the database.
> 
>> Any updates the website does (like an event registration or profile update)
>> would be done remotely to the office db. In this scheme the website db would
>> be 10 minutes behind. We can live with that.
> 
> When you do a registration, get it to use a remote database connection
> instead of the 'local' one.
> 
> $local_connection = pg_connect('localhost');
> 
> $remote_connection = pg_connect('remote_server_ip');
> 
> $remote_result = pg_query($remote_connection, $query);
> 
>> Doing everything by remote connection would be easier, but we're worried
>> about the performance.
> 
> The only way to find out would be to test it really. As long as you have
> a decent connection in to the office and a decent connection on the
> remote end and aren't pulling through a ridiculous amount of data in
> queries (eg pulling through 50,000 records when you only really need
> 10), you should be fine.

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



Re: [PHP-DB] Remote DB Connection: Pros and Cons?

2007-10-11 Thread Tony Grimes
Splitting the tables probably wouldn't work. Most of the tables are used by
both sites and the ones that aren't are tied to the rest by foreign keys.

Most of the updates are done from the admin site, so we're toying with the
idea of creating a read-only data warehouse for the website. The sync would
be one way from main office db to the warehouse (say, every 10 minutes).

Any updates the website does (like an event registration or profile update)
would be done remotely to the office db. In this scheme the website db would
be 10 minutes behind. We can live with that.

Doing everything by remote connection would be easier, but we're worried
about the performance.

Tony


On 10/11/07 6:01 PM, "Chris" <[EMAIL PROTECTED]> wrote:

> Tony Grimes wrote:
>> Have any of you tried running a PHP website using a remote database
>> connection?
>> 
>> We currently have an in-house PHP website driven by a PostgreSQL database
>> that is HEAVILY administered within the office with an administration sister
>> site (also PHP).
>> 
>> Problem: the office connection is having trouble keeping up with the website
>> traffic. Our IT guys want to outsource the whole server to a co-location
>> facility, but the administrators don't want the extra lag on the admin site.
>> 
>> Is it feasible to host the database and admin site in the office, but
>> outsource the website and connect to the office database remotely? Is there
>> any other way to do this?
> 
> Do the website and admin area reference the same database tables?
> 
> If they don't, split the database up and keep the website db on the
> website server and the other internally.
> 
> If they do, which one is the 'primary' set? ie which one gets updated?
> 
> You could use replication to keep them in sync (http://www.slony.info/
> for example).

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



[PHP-DB] Remote DB Connection: Pros and Cons?

2007-10-11 Thread Tony Grimes
Have any of you tried running a PHP website using a remote database
connection?

We currently have an in-house PHP website driven by a PostgreSQL database
that is HEAVILY administered within the office with an administration sister
site (also PHP). 

Problem: the office connection is having trouble keeping up with the website
traffic. Our IT guys want to outsource the whole server to a co-location
facility, but the administrators don't want the extra lag on the admin site.

Is it feasible to host the database and admin site in the office, but
outsource the website and connect to the office database remotely? Is there
any other way to do this?

Tony

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



Re: [PHP-DB] MySQL BETWEEN Problems

2007-05-18 Thread Tony Grimes
Nice! That did the trick. Thanks Brad. I live to fight another day.

Tony


On 5/18/07 3:00 PM, "Brad Bonkoski" <[EMAIL PROTECTED]> wrote:

> Try using the substr, since you are only comparing the first letters...
> (sorry I did not reply all on the other email, Dan)
> 
> i.e.
> 
> select name from users where substr(name, 1, 1) >= 'A' and substr(name,
> 1, 1) <= 'B';
> 
> -B
> Dan Shirah wrote:
>> So just change it to WHERE last_name BETWEEN 'A' AND 'G' .  That'll
>> get you
>> Aa-Fz :)
>> 
>> 
>> On 5/18/07, Tony Grimes <[EMAIL PROTECTED]> wrote:
>>> 
>>> We tried that and it didn't work. We've also tried every combination of
>>> upper and lower case too.
>>> 
>>> Tony
>>> 
>>> 
>>> On 5/18/07 2:18 PM, "Brad Bonkoski" <[EMAIL PROTECTED]> wrote:
>>> 
>>>> I think you need between 'A' and 'F%'
>>>> 
>>>> Aa is between A and F
>>>> but 'Fa' is not between 'A' and 'F'
>>>> (but 'Ez' would be between 'A' and 'F')
>>>> -B
>>>> 
>>>> 
>>>> Tony Grimes wrote:
>>>>> I'm using BETWEEN to return a list all people who's last names fall
>>> between
>>>>> A and F:
>>>>> 
>>>>>  WHERE last_name BETWEEN 'A' AND 'F' ...
>>>>> 
>>>>> but it's only returning names between A and E. The same thing happens
>>> when I
>>>>> use:
>>>>> 
>>>>>  WHERE last_name >= 'A' AND last_name <= 'F' ...
>>>>> 
>>>>> Shouldn't this work the way I expect it? What am I doing wrong?
>>>>> 
>>>>> Tony
>>>>> 
>>>>> 
>>>> 
>>> 
>>> -- 
>>> 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 BETWEEN Problems

2007-05-18 Thread Tony Grimes
Yeah, but what do I do for Q-Z? I guess I¹ll have to write a condition to
use last_name >= ŒQ¹ if it finds a Z. I¹ll have to write conditions to look
for other exceptions too. Aaarrgh!

*looks up at the Gods*

Damn you BETWEEN! Why must you torture me so!?!



Have a good weekend.


On 5/18/07 2:51 PM, "Dan Shirah" <[EMAIL PROTECTED]> wrote:

> So just change it to WHERE last_name BETWEEN 'A' AND 'G' .  That'll get you
> Aa-Fz :)
> 
>  
> On 5/18/07, Tony Grimes <[EMAIL PROTECTED]> wrote:
>> We tried that and it didn't work. We've also tried every combination of
>> upper and lower case too.
>> 
>> Tony
>> 
>> 
>> On 5/18/07 2:18 PM, "Brad Bonkoski" <[EMAIL PROTECTED]> wrote:
>> 
>>> > I think you need between 'A' and 'F%'
>>> >
>>> > Aa is between A and F
>>> > but 'Fa' is not between 'A' and 'F'
>>> > (but 'Ez' would be between 'A' and 'F')
>>> > -B
>>> >
>>> >
>>> > Tony Grimes wrote:
>>>> >> I'm using BETWEEN to return a list all people who's last names fall
>>>> between
>>>> >> A and F:
>>>> >>
>>>> >>  WHERE last_name BETWEEN 'A' AND 'F' ...
>>>> >>
>>>> >> but it's only returning names between A and E. The same thing happens
>>>> when I 
>>>> >> use:
>>>> >>
>>>> >>  WHERE last_name >= 'A' AND last_name <= 'F' ...
>>>> >>
>>>> >> Shouldn't this work the way I expect it? What am I doing wrong?
>>>> >>
>>>> >> Tony
>>>> >>
>>>> >>
>>> >
>> 
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> <http://www.php.net/unsub.php>
>> 
> 
> 




Re: [PHP-DB] MySQL BETWEEN Problems

2007-05-18 Thread Tony Grimes
We tried that and it didn't work. We've also tried every combination of
upper and lower case too.

Tony


On 5/18/07 2:18 PM, "Brad Bonkoski" <[EMAIL PROTECTED]> wrote:

> I think you need between 'A' and 'F%'
> 
> Aa is between A and F
> but 'Fa' is not between 'A' and 'F'
> (but 'Ez' would be between 'A' and 'F')
> -B
> 
> 
> Tony Grimes wrote:
>> I'm using BETWEEN to return a list all people who's last names fall between
>> A and F:
>> 
>>  WHERE last_name BETWEEN 'A' AND 'F' ...
>> 
>> but it's only returning names between A and E. The same thing happens when I
>> use:
>> 
>>  WHERE last_name >= 'A' AND last_name <= 'F' ...
>> 
>> Shouldn't this work the way I expect it? What am I doing wrong?
>> 
>> Tony
>> 
>>   
> 

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



[PHP-DB] MySQL BETWEEN Problems

2007-05-18 Thread Tony Grimes
I'm using BETWEEN to return a list all people who's last names fall between
A and F:

 WHERE last_name BETWEEN 'A' AND 'F' ...

but it's only returning names between A and E. The same thing happens when I
use:

 WHERE last_name >= 'A' AND last_name <= 'F' ...

Shouldn't this work the way I expect it? What am I doing wrong?

Tony

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



Re: [PHP-DB] MySQL sort stopped working

2007-03-13 Thread Tony Grimes
The sql is simple like:

SELECT artist_id 
FROM artists 
WHERE display_online = '1'
ORDER BY artist_id ACS

The statement works fine in phpMyAdmin and from the command line, but not
from my script, which uses PEAR::DB. It's as if PEAR just omitted the ORDER
BY statement.

Tony


On 3/13/07 5:24 PM, "Chris" <[EMAIL PROTECTED]> wrote:

> Tony Grimes wrote:
>> I have this page that lists artists alphabetically:
>> 
>> http://www.wallacegalleries.com/artists.php
>> 
>> At least it did until today. Nobody made any changes to the files, but the
>> database stopped sorting by artist_id. The list shown is just the default
>> order that mysql spits out if the SORT BY clause is omitted (as if I clicked
>> 'browse' in phpMyAdmin).
> 
> Right. All databases do exactly the same thing. There are no guarantees
> about sorting unless you tell it exactly how to sort.
> 
>> The SQL works in phpMyAdmin, and the site uses PEAR::DB. We patched the
>> server last week, but the problem showed up this morning.
> 
> What sql? With an order by?

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



[PHP-DB] MySQL sort stopped working

2007-03-13 Thread Tony Grimes
I have this page that lists artists alphabetically:

http://www.wallacegalleries.com/artists.php

At least it did until today. Nobody made any changes to the files, but the
database stopped sorting by artist_id. The list shown is just the default
order that mysql spits out if the SORT BY clause is omitted (as if I clicked
'browse' in phpMyAdmin).

The SQL works in phpMyAdmin, and the site uses PEAR::DB. We patched the
server last week, but the problem showed up this morning.

Anyone have any ideas on what could be causing this?

Thanks in advance,
Tony

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



[PHP-DB] SQL Performance Help

2006-12-27 Thread Tony Grimes
I'm developing a course calendar for a client and I'm running into
performance problems with the admin site. For example, when I try to include
registration counts in the course list, the page really slows down for large
course lists (50 or so):

COURSEATTENDEES  CAPACITYSEATS LEFT
===  ==
Course 1 5  10   5
Course 2 6  15   9
Course 3 4  10   6

I've been using one query to retrieve the course list and then one for each
attendee count. Is there a more efficient way of doing this all in one
query? I was thinking something like this (I'm not a SQL expert, so I don't
know if this is even possible):

SELECT
course_name,
capacity,
count(query here) as attendee_count
FROM events AS e
LEFT OUTER JOIN event_attendees AS a ON e.event_id = a.event_id
WHERE start_time BETWEEN point_a AND point_b

Or should I just pull everything as a separate row like this and sort it all
out programmatically:

SELECT
e.course_name,
e.capacity,
a.user_id
FROM events AS e
LEFT OUTER JOIN event_attendees AS a ON e.event_id = a.event_id
WHERE start_time BETWEEN point_a AND point_b

Or should I just try caching the data in PHP? Would an index help?

I realize any answers might be complicated, but if you could just point me
in the right direction, I can probably figure the rest out.

Thanks,
Tony

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



Re: [PHP-DB] Database abstract layer

2006-11-07 Thread Tony Grimes
Why not build the options into your data model? Instead of using integers
for gender, use a varchar field that stores 'Male' and 'Female'. You can
ensure data integrity by adding a check constraint to the column.

If the presentation might change depending on context, you can create gender
reference table with columns like short_name, long_name and abbreviation and
use a foreign key to reference it from the main table.

I try to use natural keys (i.e. Male,Female) instead of surrogate keys (1,2)
whenever possible. It makes the database information more readable and
you're not constantly picking through code to figure out what '3' means.

Hope that helps,
Tony


On 11/7/06 2:19 PM, "Vignesh M P N" <[EMAIL PROTECTED]> wrote:

> Hi
> 
> 
> 
> I am facing a common problem which any developer querying the database would
> face.
> 
> 
> 
> In our web applications wherever we have more than one standard options for
> a field, we usually denote them as integers. Say, for gender, we store it as
> 1 or 2, but we display that as male or female in the user interface. So far
> I had been handling this translation in the presentation layer ie., just
> before displaying the data in the table, I check if the retrieved is "1" and
> then translate it to "male" and so on. But this becomes clumsy when we have
> lots of such standard options and when we need this translation in multiple
> places in the application.
> 
> 
> 
> So now I am thinking of adding an abstract layer which does all the
> querying, retrieving and translation; and then return to my presentation
> layer, so that if my presentation layer just calls a function in the
> database abstract layer with the required query parameters, it gets back a
> resultset with the translations. I hope this is a very common problem every
> developer faces.
> 
> 
> 
> I would like to have your guidance on this. I understand that a resultset
> object is not easy to replicate. How do I make these translations and store
> them back in an object and return it to the presentation layer?
> 
> 
> 
> Or do we have existing PHP libraries which serve this purpose? Could you
> suggest me a better way of solving this problem?
> 
> 
> 
> Please help me on this.
> 
> 
> 
> Thanks
> 
> Vignesh.
> 
> 
> 
> 
> 
> 

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



Re: [PHP-DB]: small question php/postgreSQL

2006-11-07 Thread Tony Grimes
You should turn on display_errors in your php.ini file. That would make it a
lot easier to track down the error.

Tony


On 11/7/06 9:27 AM, "Desmond Coughlan" <[EMAIL PROTECTED]> wrote:

> X-No-Archive:
>   
> 
> Curious.  I put this in a file...
>   
>  
>   
>
> echo 'Hello World'
>   
> ?>
>   
> Bingo.  
>   
>  
>   
> I then take the *same* file, I don't rename it, I just open it in vi.  I copy
> a single occurrence of 'pg_connect' etc...
>   
>  
>   
> And the 'hello world' disappears.
>   
>  
>   
> D.
>   
> 
> 
> Tony Grimes <[EMAIL PROTECTED]> a écrit :
>   
>> Is your server configured to display errors? Try adding this at the top of
>> your script:
>> 
>> ini_set('display_errors',true);
>> 
>> It won't catch syntax errors, but it should help. Also, try adding this to
>> the top of your script:
>> 
>> echo 'test';
>> 
>> If you still get a blank page, then it's  probably not a problem with your
>> actual script. Maybe your configuration.
>> 
>> Tony
>> 
>> 
>> On 11/7/06 8:38 AM, "Desmond Coughlan" wrote:
>> 
>>> > X-No-Archive: true
>>> > 
>>> > That doesn't work, either. Still the blank page. Hmm ... the file is in
>>> the
>>> > right place../usr/local/www/data ... 'cos all of the other files (*.html
>>> one
>>> > an d all) are served from there, and they're available to the outside
>>> world.
>>> > 
>>> > D.
>>> > 
>>> > Bastien Koert a écrit :
>>> > The code does need to know what the fields are...I think a more likely
>>> issue
>>> > is the query for some reason, also change the $query to result in the
>>> query
>>> > statement
>>> > 
>>> > try
>>> > 
>>> > $result=pg_query($query) or die(pg_error()); //to see if there are any
>>> > errors with the query
>>> > 
>>> > while($row=pg_fetch_array($result,NULL,PGSQL_ASSOC)) {
>>> > echo "Title:  ".$row['isbn_no']."
>>> > ";
>>> > echo "blah ".$row['code_livre']."
>>> > ";
>>> > }else{
>>> > echo "No rows found";
>>> > }
>>> > 
>>> > 
>>> > bastien
>>> > 
>>> > 
>>>> >> From: JeRRy
>>>> >> To: php-db@lists.php.net
>>>> >> Subject: [PHP-DB] re: small question php/postgreSQL (basic question, not
>>>> >> small)
>>>> >> Date: Tue, 7 Nov 2006 23:18:58 +1100 (EST)
>>>> >> 
>>>> >> Date: Tue, 7 Nov 2006 10:38:18 +0100 (CET) From: "Desmond
>>>> >> Coughlan" To: "php"
>>> > 
>>>> >> Subject: small question php/postgreSQL
>>>> >> Hi,
>>>> >> 
>>>> >> I've been trying to get a small DB up and working with PhP. It's a
>>>> >> library, and so far, I can't get past the stage of displaying a page. I
>>>> >> try the 'hello world' example, and it displays. I then populate a DB
>>>> >> and can access it via psql ..
>>>> >> 
>>>> >> cdi=> SELECT * FROM stock ;
>>>> >> -[ RECORD 1  ]-+---
>>>> >> stock_ids | 1
>>>> >> isbn_no | 10101010
>>>> >> code_livre | 23455
>>>> >> titre | toto goes to Hollywood
>>>> >> editeur | editions toto
>>>> >> collection | collection toto
>>>> >> auteur_nom | smith
>>>> >> auteur_prenom | john
>>>> >> matiere | ang
>>>> >> media_type | li
>>>> >> -[ RECORD 2 ]-+---
>>>> >> stock_ids | 2
>>>> >> isbn_no | 10536278
>>>> >> code_livre | 24874
>>>> >> titre | toto comes back from Hollywood
>>>> >> editeur | editions baba
>>>> >> collection | collection toto
>>>> >> auteur_nom | martin
>>>> >> auteur_prenom | peter
>>>> >> matiere | fre
>>>> >> media_type | dvd
>>>> >> 
>>>> >> OK, I th

Re: [PHP-DB] RE : Re: [PHP-DB]: small question php/postgreSQL

2006-11-07 Thread Tony Grimes
Alright, now try commenting out all the script except for the ini_set and
echo 'test' at the top. There still might be a syntax error in the code.

Essentially, you want to do whatever you can to get the page to display a
simple message. Then, work backwards until you get the error/blank page.

If you can't get a message to display, try copying the script from hello.php
to right into your new script. That should give you enough to troubleshoot.

Tony


On 11/7/06 9:00 AM, "Desmond Coughlan" <[EMAIL PROTECTED]> wrote:

> X-No-Archive: true
>  
> OK, that gives a blank page, too... which is puzzling, 'cos I tried
> 'hello.php' before getting into the db 'thang', and I saw the text on the
> screen.
>  
> Well .. back to the drawing board...
>  
> D.
> 
> Tony Grimes <[EMAIL PROTECTED]> a écrit :
> Is your server configured to display errors? Try adding this at the top of
> your script:
> 
> ini_set('display_errors',true);
> 
> It won't catch syntax errors, but it should help. Also, try adding this to
> the top of your script:
> 
> echo 'test';
> 
> If you still get a blank page, then it's probably not a problem with your
> actual script. Maybe your configuration.
> 
> Tony
> 

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



Re: [PHP-DB]: small question php/postgreSQL

2006-11-07 Thread Tony Grimes
Is your server configured to display errors? Try adding this at the top of
your script:

ini_set('display_errors',true);

It won't catch syntax errors, but it should help. Also, try adding this to
the top of your script:

echo 'test';

If you still get a blank page, then it's probably not a problem with your
actual script. Maybe your configuration.

Tony


On 11/7/06 8:38 AM, "Desmond Coughlan" <[EMAIL PROTECTED]> wrote:

> X-No-Archive: true
>  
> That doesn't work, either.  Still the blank page.  Hmm ... the file is in the
> right place../usr/local/www/data ... 'cos all of the other files (*.html one
> an d all) are served from there, and they're available to the outside world.
>  
> D.
> 
> Bastien Koert <[EMAIL PROTECTED]> a écrit :
> The code does need to know what the fields are...I think a more likely issue
> is the query for some reason, also change the $query to result in the query
> statement
> 
> try
> 
> $result=pg_query($query) or die(pg_error()); //to see if there are any
> errors with the query
> 
> while($row=pg_fetch_array($result,NULL,PGSQL_ASSOC)) {
> echo "Title: ".$row['isbn_no']."
> ";
> echo "blah ".$row['code_livre']."
> ";
> }else{
> echo "No rows found";
> }
> 
> 
> bastien
> 
> 
>> From: JeRRy 
>> To: php-db@lists.php.net
>> Subject: [PHP-DB] re: small question php/postgreSQL (basic question, not
>> small)
>> Date: Tue, 7 Nov 2006 23:18:58 +1100 (EST)
>> 
>> Date: Tue, 7 Nov 2006 10:38:18 +0100 (CET) From: "Desmond
>> Coughlan" To: "php"
> 
>> Subject: small question php/postgreSQL
>> Hi,
>> 
>> I've been trying to get a small DB up and working with PhP. It's a
>> library, and so far, I can't get past the stage of displaying a page. I
>> try the 'hello world' example, and it displays. I then populate a DB
>> and can access it via psql ..
>> 
>> cdi=> SELECT * FROM stock ;
>> -[ RECORD 1 ]-+---
>> stock_ids | 1
>> isbn_no | 10101010
>> code_livre | 23455
>> titre | toto goes to Hollywood
>> editeur | editions toto
>> collection | collection toto
>> auteur_nom | smith
>> auteur_prenom | john
>> matiere | ang
>> media_type | li
>> -[ RECORD 2 ]-+---
>> stock_ids | 2
>> isbn_no | 10536278
>> code_livre | 24874
>> titre | toto comes back from Hollywood
>> editeur | editions baba
>> collection | collection toto
>> auteur_nom | martin
>> auteur_prenom | peter
>> matiere | fre
>> media_type | dvd
>> 
>> OK, I then write the following script 
>> 
>>> pg_connect ("dbname=cdi user=cdi password=toto") or die ("Couldn't
>> Connect: ".pg
>> _last_error());
>> $query="SELECT * FROM stock";
>> $query=pg_query($query);
>> // start the output
>> while($row=pg_fetch_array($query,NULL,PGSQL_ASSOC)) {
>> echo "Title: ".$row['isbn_no']."
> ";
>> echo "blah ".$row['code_livre']."
> ";
>> }
>> ?>
>> 
>> (sorry not to put that in italics or whatever...)
>> 
>> ... and put it in the document root of my webserver, under
>> php_experimental.
>> 
>> I get a blank page. The apache weblogs look like ...
>> 
>> 192.168.0.254 - - [07/Nov/2006:10:37:30 +0100] "GET
>> /php_experimental/base.php HTTP/1.1" 200 - "-" "Mozilla/4.0 (compatible;
>> MSIE 6.0;
>> Windows NT 5.0)"
>> 
>> There's something obvious that I'm missing. Any ideas ..?
>> 
>> Thanks.
>> 
>> D.
>> 
>> --
>> 
>> re:
>> 
>>> pg_connect ("dbname=cdi user=cdi password=toto") or die ("Couldn't
>> Connect: ".pg
>> _last_error());
>> $query="SELECT * FROM stock";
>> $query=pg_query($query);
>> // start the output
>> while($row=pg_fetch_array($query,NULL,PGSQL_ASSOC)) {
>> echo "Title: ".$row['isbn_no']."
> ";
>> echo "blah ".$row['code_livre']."
> ";
>> }
>> ?>
>> 
>> Simple, isbn_no and code_livre need to be "defined" in your code.
>> Otherwise PHP don't know what your looking for.
>> 
>> There is PLENTY of docs online to show you how to display items in a DB.
>> Hello World is basic, too basic to use as an example and is a poor one to
>> use. If your nerw you have to go a bit more into it than Hello World code.
>> (which in my opinion gets you know-where) been there done that.
>> 
>> Google how to display items in a DB in PHP and shoot you get some handy
>> things.
>> 
>> I just feel this question is not required here when google has all the
>> answers like this.
>> 
>> Jerry
> 
> _
> Ready for the world's first international mobile film festival celebrating
> the creative potential of today's youth? Check out Mobile Jam Fest for your
> a chance to WIN $10,000! www.mobilejamfest.com

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



Re: [PHP-DB] barcode

2006-10-21 Thread Tony Grimes
One of my programmers did something exactly like this. I can't remember
specifics, but the car code is alpha numeric and displayed in a special
'barcode' font on the page. If you don't store any information in the code,
why not just use the PHP session id?

Tony


On 10/21/06 3:54 AM, "Mad Unix" <[EMAIL PROTECTED]> wrote:

> I am in the process to create an online form using PHP with DB Oracle or
> MySQL, this form which consist of
> 2x parts personal data and finance data, and it will be filled by the users,
> once the form is filled and submitted ,
> it will be saved to the system as reference and printed as hardcopy it could
> be a pdf or not, but the print format
> will be on A4 format hardcopy with printed random generated (internal
> calculation) bar code printed on the paper.
> Then in the central office through bar code readers the date will be
> retrieved.
> 
> Any one implemented this kind of application, if yes  how did you generate
> the bar code on the web form
> through php, and which bar code readers did you use in order to access and
> retrieve the data from the form?
> 
> Thanks

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



[PHP-DB] Re: EXISTS syntax for SELECT INTO?

2006-10-11 Thread Tony Grimes
Thanks Mike. Luckily, I don¹t need the data if the table already exists so
that should work.

Tony


On 10/11/06 2:53 PM, "Mike Morris" <[EMAIL PROTECTED]> wrote:

> My advice:
> 
> Do a "drop table" first, ignoring any error that will result if it does not
> exist, then do the "select into". This is portable, too...
> 
>> > I have a script that creates a table copy using SELECT INTO, but I want it
>> > to check if the new table already exists first. Does SQL support the EXISTS
>> > keyword for SELECT INTO statements (I'm running PG7)?
>> > 
>> > If not, is there another way to do it in SQL? I'd rather not do it
>> > programmatically.
>> > 
>> > Thanks in advance,
>> > Tony
>> > 
> 
> 
> Mike Morris
> The Music Place
> 1617 Willowhurst Avenue
> San Jose, CA 95125
> (408) 445-ARTS (2787)
> 
>     Your Free Humorous Quote:
>     When asked the difference between a tax collector and a taxidermist:
>     'The taxidermist takes only your skin.'
>     - Mark Twain
> 
> 




[PHP-DB] EXISTS syntax for SELECT INTO?

2006-10-11 Thread Tony Grimes
I have a script that creates a table copy using SELECT INTO, but I want it
to check if the new table already exists first. Does SQL support the EXISTS
keyword for SELECT INTO statements (I'm running PG7)?

If not, is there another way to do it in SQL? I'd rather not do it
programmatically.

Thanks in advance,
Tony

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



Re: [PHP-DB] Unicode error with PostgreSQL

2006-09-26 Thread Tony Grimes
So does that mean I will always get that error? There's got to be a way
around that. Is there at least a way to detect invalid characters before I
try to insert?

Tony


On 9/26/06 1:17 PM, "Niel Archer" <[EMAIL PROTECTED]> wrote:

> PHP isn't multibyte aware by default.
> 
> Niel
> 

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



Re: [PHP-DB] Error when trying to connecting to an Oracle database

2006-09-26 Thread Tony Grimes
Hi Janet,

This is a PHP 5 only function. Are you running PHP 5? If not, try using
ocilogon() instead. If you are running 5, then maybe the Oracle library
wasn't included when PHP was compiled.

HTH,
Tony


On 9/26/06 2:13 PM, "Janet Smith" <[EMAIL PROTECTED]> wrote:

> I am trying to use a program written in PHP but connect to an Oracle
> database. 
> 
> We have a function as follows:
> 
> function dbconnect($db, $username, $password)
> {
>global $siteadmin;
>global $db;
> 
>// $bob = @mysql_connect($db, $username, $password);
>//$bob= oci_connect($username, $password, $db);
>// mysql_select_db($db, $bob);
>$bob = oci_connect("", "", "devl");
>   echo $bob;
> return $bob;
> }
> 
> where  is replaced with a username and  is replaced with a
> password. We get the following error:
> 
> Fatal error: Call to undefined function: oci_connect() in
> /www/WEBUSERS/ics2004/public_html/PHP/Project Manager/dba_copy(1).php on
> line 52
> 
> Line 52 is $bob = oci_connect("", "", "devl");
> 
> Can anyone tell me why I am getting this error?
> 
> Thanks
> 
> 
> Jan Smith
> Programmer Analyst
> Indiana State University
> Terre Haute, Indiana
> Phone: (812) 237-8593
> Email: [EMAIL PROTECTED]
> 
> **
> *
> This email, and any attachments, thereto, is intended only for use by
> the addressee(s) named herein and may contain privileged and/or
> confidential information.  If you are not the intended recipient of this
> email, you are hereby notified that any dissemination, distribution or
> copying of this email, and any attachments thereto, is strictly
> prohibited.
> **
> *

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



Re: [PHP-DB] Unicode error with PostgreSQL

2006-09-26 Thread Tony Grimes
So does that mean I will always get that error? There's got to be a way
around that. Is there at least a way to detect invalid characters before I
try to insert?

Tony


On 9/26/06 1:17 PM, "Niel Archer" <[EMAIL PROTECTED]> wrote:

> PHP isn't multibyte aware by default.
> 
> Niel
> 

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



Re: [PHP-DB] Error when trying to connecting to an Oracle database

2006-09-26 Thread Tony Grimes
Hi Janet,

This is a PHP 5 only function. Are you running PHP 5? If not, try using
ocilogon() instead. If you are running 5, then maybe the Oracle library
wasn't included when PHP was compiled.

HTH,
Tony


On 9/26/06 2:13 PM, "Janet Smith" <[EMAIL PROTECTED]> wrote:

> I am trying to use a program written in PHP but connect to an Oracle
> database. 
> 
> We have a function as follows:
> 
> function dbconnect($db, $username, $password)
> {
>global $siteadmin;
>global $db;
> 
>// $bob = @mysql_connect($db, $username, $password);
>//$bob= oci_connect($username, $password, $db);
>// mysql_select_db($db, $bob);
>$bob = oci_connect("", "", "devl");
>   echo $bob;
> return $bob;
> }
> 
> where  is replaced with a username and  is replaced with a
> password. We get the following error:
> 
> Fatal error: Call to undefined function: oci_connect() in
> /www/WEBUSERS/ics2004/public_html/PHP/Project Manager/dba_copy(1).php on
> line 52
> 
> Line 52 is $bob = oci_connect("", "", "devl");
> 
> Can anyone tell me why I am getting this error?
> 

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



[PHP-DB] Unicode error with PostgreSQL

2006-09-26 Thread Tony Grimes
I'm getting the following error when PHP tries to insert a Unicode character
(the problem word is resume with the accents) into a PostgreSQL database:

pg_exec(): Query failed: ERROR:  Invalid UNICODE character sequence found
(0xe97375)

I can't figure out why I'm getting the error. The HTML form is utf-8 and the
database is UNICODE, but I'm still getting the error. Is there some problem
with the PHP library? Is there a PHP setting that controls character
encoding within scripts? Any help would be appreciated.

Thanks in advance,
Tony


Re: [PHP-DB] PostgreSQL functions missing

2006-04-27 Thread Tony Grimes
Hi Chris,

I'm not sure if PG was updated at the same time. I do know that a separate
server has no problem connecting to the database and it's running PHP 4.3.
In any case, I think I've given the support guys enough info to go on.

I figure if they broke it, they can fix it :)

Thanks,
Tony


On 4/26/06 8:55 PM, "chris smith" <[EMAIL PROTECTED]> wrote:

> On 4/27/06, Tony Grimes <[EMAIL PROTECTED]> wrote:
>> Hi,
>> 
>> My sys admin installed an update to H-Sphere (control panel software) that
>> broke PEAR::DB and phpBB last week. After much trial and error, I finally
>> tracked it down to missing pg_affected_rows() and pg_cmdtuples() functions
>> (for PEAR and phpBB respectively) in PHP. I'm assuming that the H-Sphere
>> update also included an upgrade for PHP and they didn't compile it right.
>> 
>> Does anyone know how we can fix this? Does Psoft (the company that makes
>> H-Sphere) have to recompile libpq? The server is currently running PHP 4.4.2
>> and PosgreSQL 7.4.11. Any insight would be much appreciated.
> 
> Was postgres updated at the same time or possibly compiled against a
> different version to yours?
> 
> http://www.php.net/manual/en/ref.pgsql.php
> 
> Note:  Not all functions are supported by all builds. It depends on
> your libpq (The PostgreSQL C client library) version and how libpq is
> compiled. If PHP PostgreSQL extensions are missing, then it is because
> your libpq version does not support them.
> 
> I guess psoft needs to help you sort this one out..
> 
> --
> Postgresql & php tutorials
> http://www.designmagick.com/

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



[PHP-DB] PostgreSQL functions missing

2006-04-26 Thread Tony Grimes
Hi,

My sys admin installed an update to H-Sphere (control panel software) that
broke PEAR::DB and phpBB last week. After much trial and error, I finally
tracked it down to missing pg_affected_rows() and pg_cmdtuples() functions
(for PEAR and phpBB respectively) in PHP. I'm assuming that the H-Sphere
update also included an upgrade for PHP and they didn't compile it right.

Does anyone know how we can fix this? Does Psoft (the company that makes
H-Sphere) have to recompile libpq? The server is currently running PHP 4.4.2
and PosgreSQL 7.4.11. Any insight would be much appreciated.

Thanks in advance,
Tony

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