Re: [PHP-DB] PHP4 to PHP3 problem

2001-04-11 Thread fabrizio . ermini

On 10 Apr 2001, at 13:49, Rob Griffiths wrote:

 **50**   print "tr bgcolor=#66td{$A["fname"]}/td" .
"td{$A["lname"]}/td" . "
td{$A["dept"]}/td" . " td{$A["manager"]}/td" .
"td{$A["extension"]}/td/tr\n";

Notation with "{" parenthesis is not used in PHP3. Use the string 
concatenation operator "." instead:

print "some string".$array["element"]."some other string\n";

you could also use printf(), but AFAIK, this is the most safe way 
from the "sintactical" point of view.

HTH, bye

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Fabrizio Ermini   Alternate E-mail:
C.so Umberto, 7   [EMAIL PROTECTED]
loc. Meleto Valdarno  Mail on GSM: (keep it short!)
52020 Cavriglia (AR)  [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] OBDC date problems

2001-04-11 Thread Walter Franssen


Hello, i have some problems with date's in a query like

SELECT * FROM news WHERE fdate = $date AND tdate = #date

Can someone help me



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] images

2001-04-11 Thread Steve Brett

i'm pretty sure i read somewhere that is you use sessions php will not allow
an url that contains a path to a file typed in the address bar ...

may be wrong though ...

and apologies once again for the shopping cart debacle yesterday. some
poeple were complaining and rightly so. i received a dozen e-mails from the
two guys arguing at my works address, which was nice.



 -Original Message-
 From: Ron Brogden [mailto:[EMAIL PROTECTED]]
 Sent: 10 April 2001 19:57
 To: bryan; [EMAIL PROTECTED]; db
 Subject: Re: [PHP-DB] images
 
 
 At 11:48 AM 4/10/2001 -0800, bryan wrote:
 Maybe there is a way to use .htaccess more appropriately,
 but, this site allows guest / non-members, to buy something.
 Once they buy something, they are given a username of
 email, and password (they choose).  If they log back in, they
 should have access to ONLY the files they purchased.
 
 Easy enough.  Create a table that includes allowed download 
 file names 
 attached to a given user.  When the user logs in they are 
 given a list of 
 files they have permission to access.  The form does not send 
 the path but 
 the row *ID* of the entry from the SQL table.  When they choose the 
 appropriate link, the script looks it up in the database, 
 checks that the 
 user ID matches their authenticated one and if so uses 
 fread() to send out 
 the appropriate file.  Just include the appropriate MIME type 
 header and 
 that's that.
 
 The .htaccess file should just be used to enforce access 
 solely via the PHP 
 script (i.e. deny from all).
 
 Cheers,
 
 Ron
 
 --
 ---
 Island Net AMT Solutions Group Inc.  Telephone:   
250 383-0096
 1412 Quadra  Toll Free:   
  1 800 331-3055
 Victoria, B.C.   Fax: 
250 383-6698
 V8W 2L1  E-Mail:
 [EMAIL PROTECTED]
 Canada   WWW:   
http://www.islandnet.com/

-


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] OBDC date problems

2001-04-11 Thread Steve Brett

i think you need

SELECT * FROM news WHERE fdate = '$date' AND tdate = '$date'

the dates have to be single-quoted in your query string

i generally use

$query = "SELECT * FROM news WHERE fdate = '".$date."' AND tdate =
'".date."'";

this may not be the best way and i would really appreciate it if someone
could give me the 'correct' way. it's the way i used when i first started
using php and have kinda kept it 

Steve

 -Original Message-
 From: Walter Franssen [mailto:[EMAIL PROTECTED]]
 Sent: 11 April 2001 10:47
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] OBDC date problems
 
 
 
 Hello, i have some problems with date's in a query like
 
 SELECT * FROM news WHERE fdate = $date AND tdate = #date
 
 Can someone help me
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: 
 [EMAIL PROTECTED]
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] mssql - unable to read large text fields

2001-04-11 Thread Manuel Prieur

Hello,


I'd like to use PHP4 on IIS to access a MSSQL7 server, but i have problems
reading large text fields :

- "nvarchar" fields are truncated to 255 chars.

- "ntext" fields generated the following error message :


Warning: MS SQL message: Impossible d'envoyer les donnes ntext aux clients
utilisant DB-Library (par exemple ISQL) ou ODBC version 3.7 ou antrieure.
(severity 16)

(English : Unable to send ntext data to clients using DB-Library (for
instance ISQL) or ODBC version 3.7 or previous.)



I also tried to use built-in ODBC driver :

- "nvarchar" fields have correct size.

- "ntext" fields generate the following error message :


FATAL: emalloc(): Unable to allocate 1073741824 bytes



Thanks for help.


Manuel Prieur.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] MSSQL and @@identity

2001-04-11 Thread Daniel Fairs

Hi,

I'm trying to insert a row into an MSSQL7 table using the SQL string:

INSERT INTO person (birthdate,deathdate,sname,othername,motherid,fatherid)
VALUES ('1978-10-06',NULL,'Fairs','Daniel',NULL,NULL) SELECT @@identity AS
last_identity

The actual PHP code is
$oRes = mssql_query("SET NOCOUNT ON " . $sSQL, $this-iConnIndex) ;
if ($oRes) echo "yea" ; else echo "nay" ; die() ;

... and 'nay' gets printed

I've tried both SET NOCOUNT ON and SET NOCOUNT OFF, and also omitting the
SET NOCOUNT completely. Any ideas why I'm not getting the last id back?

Cheers,
Dan







-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Re: PostgreSQL versus MySQL

2001-04-11 Thread Bob Hall

On Mon, 9 Apr 2001, Bob Hall wrote:

 MySQL is providing an SQL frontend to a
   bunch of tables and indices, that is it ... it is up to the programmer to
   handle the "managing of data" part where it revolves around being
   relational ...
  
   I've developed database apps in which the data was inserted in
   batches, which meant that transactions were unnecessary. On the other
   hand, the apps needed an RDBMS to handle normalized tables.

Okay, so you start the insert, and one of the records in the batch failed
to insert ... then what?  You manually rollback the other ones?

Well, with MySQL, you start the batch over again, but use IGNORE in 
the INSERT statement, and MySQL passes over the records that are 
already inserted.

   A
"transaction" is effectively a batch ... if one of the batch fails, either
the programmer has to manually remember and roll everything back, or you
let the database itself handle it ..

No, a batch isn't very much like a transaction. In OLTP, the DBA 
doesn't initiate a transaction, has no control over it, and can't 
recover lost data. In batch processing, the DBA initiates and 
controls the batch, and any missing data is in the file.

   Futhermore, some datawarehousing and web projects involve relational
   databases that are inserted and updated in batches at night, making
   transactions unnecessary.

See above ... I have an application that loads ACT! data into a database
every night ... each contact in the system has something like 20-30 fields
associated with them ... if, for some reason, *one* of those fields fail
to insert properly, that contact is invalid, and the transaction that its
wrap'd in automatically rolls back everything I've done since the start of
the transaction, so that there is no record of that failed contact except
in my error log file ... no "incomplete" data, no stray data ...

If your DBMS doesn't give you the capability to restart the batch at 
the point where it failed, then that's necessary. I have a hard time 
believing, though, that you can't do that in whatever DBMS you're 
using. I'll concede that transactions are preferable in that 
circumstance, but I also have experience with databases where 
transactions have nothing to offer.

batch or interactive doesn't matter ... its the data integrity that is
maintained by using transactions that is key ...

   I'm not trying to claim that MySQL can handle all types of db
   applications. MySQL is a niche product that was never designed to
   handle certain types of applications. My point is that whether a DBMS
   is relational depends on the structure of the data it deals with.
   Whether it needs to support transaction depends on the environment it
   operates in. I think that your point is that in an OLTP environment,
   lack of transaction support screws up the data to the point that the
   database becomes useless. I agree, but not all RDBMSs operate in an
   OLTP environment.

No, my point is that in any environment that needs the features of being
"relational" (data spread across multiple tables, link'd together), IMHO,
transactions are required in order to maintain data integrity *unless* the
programmer himself wants to take it upon himself to maintain this data
integrity in the application layer ...

... if data in table C requires that the data saved to table B was stored,
then if table B fails, the transaction should fail and the changes to
table A should be reversed automatically ... *shrug*  By extension, if the
data to table C fails for whatever reason, the data put to Tables A and
B should be automatically reversed ...

... or the missing data inserted. How did DBAs handle batch 
processing before there were transactions?

Bob Hall

Know thyself? Absurd direction!
Bubbles bear no introspection. -Khushhal Khan Khatak
MySQL list magic words: sql query database

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] create type

2001-04-11 Thread Olivier Thauvin


Is somebody an example of create type under Postgres (v. 7) I have a probleme with the 
input function of the new type:


parcmicro=#  CREATE TYPE "macad" ( internallength = variable, externallength = 
variable, input = macadi, output = macado, PASSEDBYVALUE);
CREATE
parcmicro=# create table toto (mac macad);
CREATE
parcmicro=#  insert into toto (mac) values ('AA:AA:AA:AA:AA:AA');
NOTICE:  plpgsql: ERROR during compile of macadi near line 0
ERROR:  cache lookup for return type 0 failed


What i'm doing wrong ? Thanks a lot.

-- 
Olivier Thauvin-CNRS Service Aeronomie
[EMAIL PROTECTED] 
Tlphone:
01 64 47 43 60  Verrires (lundi,mercredi et vendredi)
01 44 27 47 59  Jussieu (Mardi et Jeudi)



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] MSSQL and @@identity

2001-04-11 Thread fabrizio . ermini

On 11 Apr 2001, at 11:40, Daniel Fairs wrote:

 Hi,
 
 I'm trying to insert a row into an MSSQL7 table using the SQL string:
 
 INSERT INTO person (birthdate,deathdate,sname,othername,motherid,fatherid)
 VALUES ('1978-10-06',NULL,'Fairs','Daniel',NULL,NULL) SELECT @@identity AS
 last_identity
 
 The actual PHP code is
 $oRes = mssql_query("SET NOCOUNT ON " . $sSQL, $this-iConnIndex) ;
 if ($oRes) echo "yea" ; else echo "nay" ; die() ;
 
 ... and 'nay' gets printed
 
 I've tried both SET NOCOUNT ON and SET NOCOUNT OFF, and also omitting the
 SET NOCOUNT completely. Any ideas why I'm not getting the last id back?
 
Maybe the problem is simpler: on some version of mssql API 
(maybe all?), I've verified that mssql_returns non-zero only for 
SELECT statements (returns the number of rows selected, to be 
more precise). All other statements return zero, so you could see 
that darn "nay" even if the query worked perfectly :-(...

HTH, bye!
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Fabrizio Ermini   Alternate E-mail:
C.so Umberto, 7   [EMAIL PROTECTED]
loc. Meleto Valdarno  Mail on GSM: (keep it short!)
52020 Cavriglia (AR)  [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] MSSQL and @@identity

2001-04-11 Thread fabrizio . ermini

On 11 Apr 2001, at 13:00, [EMAIL PROTECTED] wrote:

  
 (returns the number of rows selected, to be 
 more precise). 

Ehm... forget this part. I momentaneally disconnected the brain, I'm 
afraid :-)


/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Fabrizio Ermini   Alternate E-mail:
C.so Umberto, 7   [EMAIL PROTECTED]
loc. Meleto Valdarno  Mail on GSM: (keep it short!)
52020 Cavriglia (AR)  [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Uploading file into database

2001-04-11 Thread Lucio Stoco

Have you done the file upload into the database?
I´m having some problem to put the file (like .doc or .xls) in a database...
I´m using 'text' field type, is it right?

Do you have any example about it?

Tks.

""Zeus"" [EMAIL PROTECTED] escreveu na mensagem
01e601c0c26e$6ccded80$735518d2@zeus">news:01e601c0c26e$6ccded80$735518d2@zeus...
I'm trying to do a filexchange script.

Does anyone know how to upload a file into the database such that when I do
a 'select *' query, I can click on a link the download that file.





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Cookies Stuff

2001-04-11 Thread Lisa Elita

Hi everybody,

I am trying to use cookies in my website and want to ask you these
questions:
1. Header("Set-Cookie") or SetCookie() is better? as the setcookie manual
comments said that Header("Set-Cookie") is better.
2. Domain=myserver.com OR domain=.myserver.com OR skip the domain argument
is better? (to make the cookie available whether visitors are coming to my
site with http://www.myserver.com or http://myserver.com )
3. What SetCookie statement must I use to make the cookie available in the
entire website? Is it Header(SetCookie: cookiename=cookievalue;
expires=Friday, 16-Jan-2037 00:00:00 GMT; path=/; domain=.myserver.com); ?

Thank you!
Lisa Elita


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Blob or Link?

2001-04-11 Thread Anderson Sone

Blob or link?
Insert just the link is the better way?
Does the security is the same?

Thanks,
Anderson Sone

 No things of all

 Only upload the file, move to the right location and insert the file link
 (location path) into the database.

 READY!

 Bey,
 Daniel Kieviet
 Xsarus Internetservices
 Holland

 - Original Message -
 From: "Lucio Stoco" [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, April 11, 2001 4:11 AM
 Subject: Re: [PHP-DB] Uploading file into database


  Have you done the file upload into the database?
  I´m having some problem to put the file (like .doc or .xls) in a
 database...
  I´m using 'text' field type, is it right?
 
  Do you have any example about it?
 
  Tks.
 
  ""Zeus"" [EMAIL PROTECTED] escreveu na mensagem
  01e601c0c26e$6ccded80$735518d2@zeus">news:01e601c0c26e$6ccded80$735518d2@zeus...
  I'm trying to do a filexchange script.
 
  Does anyone know how to upload a file into the database such that when I
 do
  a 'select *' query, I can click on a link the download that file.
 
 
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] mysql and LIKE

2001-04-11 Thread Larry Hotchkiss

I am in the process of setting up some searches in php for a database.
Currently my test data consist of about 10k records. I am unsure what
the operational total will be but I would bet less than 1 million
records. The table in question has 13 fields and of these 13 fields I
would like to allow the user to be able to search on 7 of them. To
complicate things I would like to allow the user to use multiple colums
to do the search. I accomplish this by displaying a form where the user
can enter search criteria into all or none of the 7 fields. Obviously
the more accurate the returned data the faster and more correct the
search will be. 

In order to allow for the user to enter partial data I use a lot of
"like" in the search. I realize that in mysql LIKE uses indexes if it is
not prepended with a wildcard so performance should not be too big of an
issue there, but what if wildcards are used at the beginning of search
criteria? My searches are very acceptable with 10k records, but what can
I expect when I hit the 500,000 or even million mark? Please note, I
also use offset and limit to limit the returned records and supply
prev/next links at bottom of returned data.

Anyways, I am just looking for some ideas on a good compromise between
allowing users flexability without sacrificing performance. All input
welcome

-- 
Larry Hotchkiss

http://www.unicap.com/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Help with results output needed

2001-04-11 Thread COMMONS, PHILIP

Hi Liz, thanks for the reply! I have tried this, as well as
added to this approach, but I am still not sure what to do
with the results of the query (count, sum(*)) to produce
the needed final output ("5 chose A for answer1", or "20%
chose A for answer1").

Using the code below with my additions quickly added up.
Something like 16 lines just for answer1 :(

$result1A=mysql_query("SELECT answer1 FROM $table_name WHERE answer1 LIKE
'A'");
$row1A=mysql_num_rows($result1A);
print $row1A;

$result1B=mysql_query("SELECT answer1 FROM $table_name WHERE answer1 LIKE
'B'");
$row1B=mysql_num_rows($result1B);
print $row1B;

etc. etc. 

I am getting '0' or '1' back from the db as my output, I think I need to
somehow get this into an array, or ? then perhaps add a while {} loop
but I am still quite lost :(

Thanks again,
Phil


-Original Message-
From: Liz Bander [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 11, 2001 9:42 AM
To: COMMONS, PHILIP
Subject: Re: [PHP-DB] Help with results output needed


I'm not sure if this will work (I'm pretty much new to this myself) but try 
something along the lines of the following (I have a similar query going in 
one of my scripts).

$query = 'select answer1 from acct2301 where answer1 like 'A'';
$results=mysql_num_rows($query);
print $results;

Liz

(let me know if it works!)

At 10:30 AM 4/11/2001, COMMONS, PHILIP wrote:
Hi, first post :)

I have an interesting project. I have a basic form passing answers
into mysql. I have a db with multiple tables, each table contains
several fields, but I am only concerned with 16 of these fields
which contain the answers "A" "B" "C" "D" etc., not all fields
contain the same number of answers (ie; some answers have A-G,
some only have A-D to choose from). My problem is extracting the
number of people that chose "A" for answer1, "B" for answer1, etc.

Here is the layout:

acct2301 (table)
answer1-answer16 are my fields

usernameanswer1 answer2 answer3 answer4 answer16

joeblow A F A   E C
someguy A E B B   C
joeuser B A E A   D
someone D C D A   A

I have everything completed as far as getting the answers into the
tables,I just can't figure out the best way to extract the answers
and determine how many chose a given answer for each question.

I have seen some examples using count(*), and (sum) I am thinking
I need to first determine how many A's, B's etc. then perform a
count on the result of that, but that is as far as I have been able
to get.

Ideally a percentage function would be nice (20% chose A for Answer1,
etc.)

Thanks for any help, I sure need it!

-Phil


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] DOH! Is it so obvious that i cannot figure it out?

2001-04-11 Thread Michel Laine

I have PHP4 and MySQL running on a W98 PWS webserver.
My database is ported from Access and looks fine in MySQL.

I can query the database from a webbrowser window, but the result
("capital o with dots" for example) come out as "TM" (as in the
trademark symbol).

I know that this is because of the difference in the DOS and Windows
charset, but how / where do i solve it?

Should i do something with MySQL?
Should i write a routine in PHP that scan every text returned for the
characters and if found - change them before printing them to the
browser? This seems like a slow process.

Any suggestions?

--

Michel Laine

Please remove the NOSPAM in the email address if you reply directly to
me.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] DOH! Is it so obvious that i cannot figure it out?

2001-04-11 Thread fabrizio . ermini

 
 Should i do something with MySQL?
 Should i write a routine in PHP that scan every text returned for the
 characters and if found - change them before printing them to the
 browser? This seems like a slow process.
 
There's already a function called HTMLentities() that could give you 
an help, try that...


/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Fabrizio Ermini   Alternate E-mail:
C.so Umberto, 7   [EMAIL PROTECTED]
loc. Meleto Valdarno  Mail on GSM: (keep it short!)
52020 Cavriglia (AR)  [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Really Dumb Question...

2001-04-11 Thread Brian Grayless

How do I create a table within my PHP? Heres what I currently have, but I
keep getting parse error on the "create" line...

$result = mysql_query($sql);

create table $propTable (
ID int not null auto_increment primary key,
TourName tinytext,
TourTitle tinytext,
ViewTitle tinytext,
TourNum tinyint not null,
Applet tinyint not null,
Desc text,
TourPath text,
SmFile text,
LgFile text
);


Any thoughts??? I know this shouldn't be so complicated, but I'm lacking
sleep.

Thanks,

B R I A N   G R A Y L E S S


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Really Dumb Question...

2001-04-11 Thread Darryl Friesen



 How do I create a table within my PHP? Heres what I currently have, but I
 keep getting parse error on the "create" line...

Because create is not a valid PHP command.  You have to assign the create
statement to a string, _then_ pass the string to mysql_query:

$sql = "create table $propTable (
  ID int not null auto_increment primary key,
  TourName tinytext,
  TourTitle tinytext,
  ViewTitle tinytext,
  TourNum tinyint not null,
  Applet tinyint not null,
  Desc text,
  TourPath text,
  SmFile text,
  LgFile text );
";

$result = mysql_query($sql);


- Darryl

 --
  Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED]
  Education  Research Technology Services, http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 --
  "Go not to the Elves for counsel, for they will say both no and yes"



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Connect to MySQL from different computer

2001-04-11 Thread Paulson, Joseph V. \Jay\

Hello-
I was wondering how do I connect to a MySQL database, using php, when php
and MySQL are on two separate computers?
Thanks,
Jay

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] connection to database

2001-04-11 Thread Sharmad Naik

Hi,
While writing dynamic pages I use pg_connect to connect to the database.
I wanted to know whether i alway need to close database connection or while 
closing the FORM or going to another page does the connect close automatically.
Is pg_close necessary to be given ? 

-- 
The secret of the universe is @*!'^#+ NO CARRIER
___  _  _  _
|_|_||_||_||\/||_|| \
_|| || || \|  || ||_/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Really Dumb Question...

2001-04-11 Thread CC Zona

In article 00c701c0c2af$be478f40$[EMAIL PROTECTED],
 [EMAIL PROTECTED] ("Darryl Friesen") wrote:

  How do I create a table within my PHP? Heres what I currently have, but I
  keep getting parse error on the "create" line...
 
 Because create is not a valid PHP command.  You have to assign the create
 statement to a string, _then_ pass the string to mysql_query:
 
 $sql = "create table $propTable (
   ID int not null auto_increment primary key,
   TourName tinytext,
   TourTitle tinytext,
   ViewTitle tinytext,
   TourNum tinyint not null,
   Applet tinyint not null,
   Desc text,
   TourPath text,
   SmFile text,
   LgFile text );
 ";
 
 $result = mysql_query($sql);

And take out the semicolon immediately after the closing parenthesis in 
"LgFile text )".   :-)

-- 
CC

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] element in the SELECT query

2001-04-11 Thread phobo

you should look at php.net. Having never used postgres, my imagination
thinks that perhaps http://www.php.net/manual/en/function.pg-numfields.php
is what you're after.

and btw, if you're fetching a whole row, don't retreive a field at a time -
its very slow. use a fetch_array or something.

siggy


- Original Message -
From: "Sharmad Naik" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, April 12, 2001 7:59 AM
Subject: [PHP-DB] element in the SELECT query


 say u say a query like
 SELECT * from user where user='sharmad';
 Is there any variable like pg_Result that will count the number of
differnet
 values in * ?
 like i wanted to give something like
 for($i=0;$ipg_NumRows;$i++){
 for ($j=0;$j***Tell me what to put here *** ;$j++){
 echo pg_Result($result,$i,$j);
 }
 }
 -Regards

 --
 The secret of the universe is @*!'^#+ NO CARRIER
 ___  _  _  _
 |_|_||_||_||\/||_|| \
 _|| || || \|  || ||_/

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Only part of a field SQL

2001-04-11 Thread Randall Barber

Our Xerox production printers export a log in ':' delimited format.  
No big deal, except that each field has a tag like so:

Job ID = 99
Job ID = 98
Job ID = 97

See what I mean?

I have simply imported the whole CSV file into Access and was now wondering if I could 
do the following?
Pull everything out of the field AFTER the '=' sign.

SELECT FIELD1, FIELD3, FIELD10 FROM ImportTable WHERE FIELD1=' everything after the = 
sign ' AND FIELD3=' same idea ' AND FIELD10=' same idea '

So when I execute the query all I get for Job IDs is:

99
98
97


Is there a way to do this in the query?  I am totally inexperienced.  

Thanks in advance,
RDB



Re: [PHP-DB] Only part of a field SQL

2001-04-11 Thread B. van Ouwerkerk


Is there a way to do this in the query?  I am totally inexperienced.

Why not remove the part you don't want to import.. very easy in Access.

Bye,



B.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] date_format for Oracle

2001-04-11 Thread Richard Crawford

This isn't strictly a PHP question, I suppose... but is anyone aware of a 
date_format function for Oracle comparable to MySQL's date_format() function?

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] date_format for Oracle

2001-04-11 Thread Steve Farmer

Hi Richard,

try TO_DATE or TO_CHAR , depending upon what you are trying to do, 
there are about 2 pages of formatting options for these functions.

HTH
Steve
At 10:12 PM + 11/4/01, Richard Crawford wrote:
This isn't strictly a PHP question, I suppose... but is anyone aware of a
date_format function for Oracle comparable to MySQL's date_format() function?

-- 
---
"Minds are like parachutes, they work best when open"
Support free speech; visit http://www.efa.org.au/

Heads Together Systems Pty Ltd http://www.hts.com.au
Email: [EMAIL PROTECTED] Tel: 612 9982 6767 Fax: 612 9981 3081 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] I know this has been asked before, but....

2001-04-11 Thread SHAWN

I can't find the answer to this, I know it's easy.
 
What's the SELECT statment I want to use to find duplicate entries in a
specific field?
 
Thanks in Advance!
Shawn Sellars



Re: [PHP-DB] I know this has been asked before, but....

2001-04-11 Thread Ron Brogden

At 03:38 PM 4/11/2001 -0700, SHAWN wrote:
What's the SELECT statment I want to use to find duplicate entries in a
specific field?

SELECT column_name, count(*) AS doubles FROM some_table HAVING doubles  1 
GROUP BY colname

This should grab all instances where there are multiple instances of 
"column_name" with the same value.

Cheers,

Ron

-
Island Net AMT Solutions Group Inc.  Telephone:  250 383-0096
1412 Quadra  Toll Free:1 800 331-3055
Victoria, B.C.   Fax:250 383-6698
V8W 2L1  E-Mail:[EMAIL PROTECTED]
Canada   WWW:   http://www.islandnet.com/
-


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] date_format for Oracle

2001-04-11 Thread Joe Brown

Also consider the oracle sql

ALTER SESSION SET NLS_DATE_FORMAT='-MM-DD HH24:MI:SS'

or whichever format you prefer.

This sets the default format returned when selecting a date column.

-Joe

"Steve Farmer" [EMAIL PROTECTED] wrote in message
news:p04320402b6fa8a7ffc70@[203.28.219.179]...
 Hi Richard,

 try TO_DATE or TO_CHAR , depending upon what you are trying to do,
 there are about 2 pages of formatting options for these functions.

 HTH
 Steve
 At 10:12 PM + 11/4/01, Richard Crawford wrote:
 This isn't strictly a PHP question, I suppose... but is anyone aware of a
 date_format function for Oracle comparable to MySQL's date_format()
function?
 
 --
 ---
 "Minds are like parachutes, they work best when open"
 Support free speech; visit http://www.efa.org.au/

 Heads Together Systems Pty Ltd http://www.hts.com.au
 Email: [EMAIL PROTECTED] Tel: 612 9982 6767 Fax: 612 9981 3081

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] select substring_index

2001-04-11 Thread Mike Baerwolf

I have a simple news manager and I would like to display the first two sentences of a 
news story. I got this select statement from the mysql mailing list:

SELECT substring_index( body, ".  ", 2) FROM news;
 
This works great from the mysql client but when I try it using php with this:

$result = mysql_query("SELECT substring_index(body, "." ,2) FROM news",$db) or die 
("Invalid Query");  
  if ($myrow = mysql_fetch_array($result)) {

  do {
  
   printf("%s\nbr", $myrow["headline"]);
   printf("%s\n", $myrow["body"]);

  } while ($myrow = mysql_fetch_array($result));

} else {

 
  echo "Sorry, no records were found!"; 

 }

It dies a cold death.  I looked at the mysqld.log and the above is not putting the . 
in the quotes. I'm stuck in the mud, don't really know if this is even possible.  I 
would appreciate any pointers.

Thanks in advance,
Mike



Re: [PHP-DB] select substring_index

2001-04-11 Thread Paul Burney

on 4/11/01 7:48 PM, Mike Baerwolf at [EMAIL PROTECTED] wrote:

 SELECT substring_index( body, ".  ", 2) FROM news;
 
 This works great from the mysql client but when I try it using php with
 this:
 
 $result = mysql_query("SELECT substring_index(body, "." ,2) FROM news"

The way you have this written, PHP is using the . for concatenation.  To fix
the problem you need to alternate or escape the quotes, i.e. :

$result = mysql_query("SELECT substring_index(body, \".\" ,2) FROM news"

or

$result = mysql_query('SELECT substring_index(body, "." ,2) FROM news'

or

$result = mysql_query("SELECT substring_index(body, '.' ,2) FROM news"

Hope that helps,

Paul Burney
http://paulburney.com/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] date_format for Oracle

2001-04-11 Thread Steve Farmer

Hi Joe,

Yes, I put this in as a standard statement immediately after i 
connect to the orcale database, it is also possible to put it in your 
init.ora file i believe

rgds
Steve
At 8:28 PM -0400 11/4/01, Joe Brown wrote:
Also consider the oracle sql

ALTER SESSION SET NLS_DATE_FORMAT='-MM-DD HH24:MI:SS'

or whichever format you prefer.

This sets the default format returned when selecting a date column.

-Joe

"Steve Farmer" [EMAIL PROTECTED] wrote in message
news:p04320402b6fa8a7ffc70@[203.28.219.179]...
  Hi Richard,

  try TO_DATE or TO_CHAR , depending upon what you are trying to do,
  there are about 2 pages of formatting options for these functions.

  HTH
  Steve
  At 10:12 PM + 11/4/01, Richard Crawford wrote:
  This isn't strictly a PHP question, I suppose... but is anyone aware of a
  date_format function for Oracle comparable to MySQL's date_format()
function?
  
  --
  ---
  "Minds are like parachutes, they work best when open"
  Support free speech; visit http://www.efa.org.au/

  Heads Together Systems Pty Ltd http://www.hts.com.au
  Email: [EMAIL PROTECTED] Tel: 612 9982 6767 Fax: 612 9981 3081

  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
---
"Minds are like parachutes, they work best when open"
Support free speech; visit http://www.efa.org.au/

Heads Together Systems Pty Ltd http://www.hts.com.au
Email: [EMAIL PROTECTED] Tel: 612 9982 6767 Fax: 612 9981 3081 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] create type

2001-04-11 Thread Yasuo Ohgaki

Why you want to create MAC address type? It's already there in V7.

macaddr| XX:XX:XX:XX:XX, MAC address

Besides, do you have functions defined for INPUT and OUTPUT?
You must define them. Refer to PostgreSQL User Manual for details.

Regards,
--
Yasuo Ohgaki


"Olivier Thauvin" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 Is somebody an example of create type under Postgres (v. 7) I have a probleme
with the input function of the new type:


 parcmicro=#  CREATE TYPE "macad" ( internallength = variable, externallength =
variable, input = macadi, output = macado, PASSEDBYVALUE);
 CREATE
 parcmicro=# create table toto (mac macad);
 CREATE
 parcmicro=#  insert into toto (mac) values ('AA:AA:AA:AA:AA:AA');
 NOTICE:  plpgsql: ERROR during compile of macadi near line 0
 ERROR:  cache lookup for return type 0 failed


 What i'm doing wrong ? Thanks a lot.

 --
 Olivier Thauvin-CNRS Service Aeronomie
 [EMAIL PROTECTED]
 Tlphone:
 01 64 47 43 60  Verrires (lundi,mercredi et vendredi)
 01 44 27 47 59  Jussieu (Mardi et Jeudi)



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] connection to database

2001-04-11 Thread Yasuo Ohgaki

PHP takes care of closing it, just like other resources. However, it seems there
is bug in closing none persistent PgSQL link in current version. 4.0.5 hopefully
fix this.

Regards,
--
Yasuo Ohgaki


"Sharmad Naik" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi,
 While writing dynamic pages I use pg_connect to connect to the database.
 I wanted to know whether i alway need to close database connection or while
 closing the FORM or going to another page does the connect close
automatically.
 Is pg_close necessary to be given ?

 --
 The secret of the universe is @*!'^#+ NO CARRIER
 ___  _  _  _
 |_|_||_||_||\/||_|| \
 _|| || || \|  || ||_/

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] create type

2001-04-11 Thread Olivier Thauvin


Yesterday, I saw in Postgres User Manual that plpgsql cannot define function for 
create type. The function must be define in C language.
But i don't understand this language.

Thanks a lot.

Le Jeudi 12 Avril 2001 06:25, vous avez crit :
 Why you want to create MAC address type? It's already there in V7.

 macaddr| XX:XX:XX:XX:XX, MAC address

 Besides, do you have functions defined for INPUT and OUTPUT?
 You must define them. Refer to PostgreSQL User Manual for details.

 Regards,
 --
 Yasuo Ohgaki


 "Olivier Thauvin" [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

  Is somebody an example of create type under Postgres (v. 7) I have a
  probleme

 with the input function of the new type:
  parcmicro=#  CREATE TYPE "macad" ( internallength = variable,
  externallength =

 variable, input = macadi, output = macado, PASSEDBYVALUE);

  CREATE
  parcmicro=# create table toto (mac macad);
  CREATE
  parcmicro=#  insert into toto (mac) values ('AA:AA:AA:AA:AA:AA');
  NOTICE:  plpgsql: ERROR during compile of macadi near line 0
  ERROR:  cache lookup for return type 0 failed
 
 
  What i'm doing wrong ? Thanks a lot.
 
  --
  Olivier Thauvin-CNRS Service Aeronomie
  [EMAIL PROTECTED]
  Tlphone:
  01 64 47 43 60  Verrires (lundi,mercredi et vendredi)
  01 44 27 47 59  Jussieu (Mardi et Jeudi)
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
Olivier Thauvin-CNRS Service Aeronomie
[EMAIL PROTECTED] 
Tlphone:
01 64 47 43 60  Verrires (lundi,mercredi et vendredi)
01 44 27 47 59  Jussieu (Mardi et Jeudi)



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]