Re: [PHP-DB] Closing curly brackets?

2002-04-15 Thread Marius Ursache

a good tutorial for code formating is "c and c++ style guides"
( http://www.cs.umd.edu/users/cml/cstyle/ )

a good code editor is vim (http://www.vim.org).

Jennifer Downey a écrit :

> Thank you Paul,
>
> I have asked about atutorial on proper code formatting and got back a
> tutorial that was extremely hard to understand. While lots of people have
> screamed at me for my  coding format no one has supplied an understandable
> answer. That is until this morning.
>
> > The first thing you should do is properly indent your code.  If you do so,
> > you'll be sure to find the missing bracket.  Basically, for each new
> block,
> > tab out again.
>
> Thought that was the best tutorial I could ever get. Short and sweet and oh
> so easy to understand.
> I am using HTML_Kit as it has the same features as all the othere editors
> (color coding and such) but it also has a lot more. I can get plugins for
> anything I would ever need. Except a formatting tutorial ;)
>
> Thank for your help
> Jennifer
>
> "Paul Burney" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > on 4/12/02 11:15 PM, Jennifer Downey at [EMAIL PROTECTED] appended the
> > following bits to my mbox:
> >
> > > I believe it has something to do with the first while statement's
> closing
> > > curly bracket placement
> > > but I can't seem to get it in the right place.
> >
> > Hi Jennifer,
> >
> > The first thing you should do is properly indent your code.  If you do so,
> > you'll be sure to find the missing bracket.  Basically, for each new
> block,
> > tab out again.  It really helps to use a programmer's editor with syntax
> > highlighting like vim or BBEdit.  Here's an example using your code:
> >
> > ===
> >
> > $id = $HTTP_GET_VARS["id"];
> >
> > $query = "SELECT id, name, image, quantity, type FROM
> > {$config["prefix"]}_my_items WHERE uid={$session["uid"]} ORDER BY id";
> > $ret = mysql_query($query);
> >
> > while($row = mysql_fetch_array($ret)) {
> >
> > $iid = $row['id'];
> > $image = $row['image'];
> > $name = $row['name'];
> > $quantity = $row['quantity'];
> > $type = $row['type'];
> >
> > if ($iid == $id) {
> >
> > $display_block =" > size=2>$name$quantity$type";
> > echo "$display_block";
> >
> > if ($type == "food") {
> >
> > //if book or weapon is present then set an option and include
> in
> > the form later
> > $thisoption="Feed my pet\n";
> >
> > } else {
> >
> > //if any other type is present then set a blank
> > $thisoption="";}
> >
> > } // end option "if" statement
> >
> > } // end id "if" statement
> >
> > /* More code after this point */
> >
> > } // end "while" if statement.
> >
> >
> > ===
> >
> > Hope that helps.
> >
> > Sincerely,
> >
> > Paul Burney
> > 
> >
> >  > while ($self != "asleep") {
> > $sheep_count++;
> > }
> > ?>
> >
> >
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--
  Marius Ursache (3563 || 3494)

   \|/  \|/
   "@'/ ,. \`@"
   /_| \__/ |_\
  \__U_/



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




Re: [PHP-DB] Delete from mysql table is there a way to....

2002-04-15 Thread Marius Ursache

your posts are here.

i don't think you could do this in other way.
if is possible i'm curios about it too.

Jennifer Downey a écrit :

> Hi all,
> I'm not sure if my first post showed up so I am going to post it again and I
> apologize if it shows up twice.
>
> Is there a way to delete a record from a mysql table without fragmenting the
> db?
>
> Here is the query I am using and it does a horrible job. Fragment city.
>
> if ($quantity == 0)
>  {
> $gone = mysql_query("DELETE FROM {$config["prefix"]}_my_items WHERE
> uid={$session["uid"]} AND id = '$item'");
>   }
>
> Thanks
> Jennifer
>
> --
> The sleeper has awaken
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--
  Marius Ursache (3563 || 3494)

   \|/  \|/
   "@'/ ,. \`@"
   /_| \__/ |_\
  \__U_/



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




Re: [PHP-DB] Extracting the essence!

2002-04-15 Thread Lisi

How about:

$test= preg_replace ($search, $replace, $dokument);

while (list ($key, $val) = each($test)) {
  if ($key == "0" || $key == "3") {
   //do nothing
  } else {
 echo $key = $val;
  }
  }

Let me know if this works.

-Lisi

At 11:24 PM 4/14/02 +0200, #Linux wrote:
>Tanks so far, but if  I want don't want to display the 1st and 4th line.
>
>
>- Original Message -
>From: "Lisi" <[EMAIL PROTECTED]>
>To: "#Linux" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
>Sent: Sunday, April 14, 2002 10:55 PM
>Subject: Re: [PHP-DB] Extracting the essence!
>
>
> >
> > >Try something like the following to extract the contents of the array by
> > >looping through it:
> >
> > >$test= preg_replace ($search, $replace, $dokument);
> >
> > while (list ($key, $val) = each($test)) {
> >  echo $key = $val;
> > }
> >
> > HTH
> >
> > -Lisi
> >


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




[PHP-DB] Re: LOBS with CURSOR_SHARING=FORCE gives core dump

2002-04-15 Thread John Lim

According to Thies, this is an Oracle bug. A quick workaround which I just
tested is to execute an alter session before updating the LOB, and restore
cursor_sharing=force after the update.

ALTER SESSION SET cursor_sharing=exact

Bye, John

"Prince" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> John!
>
> Thanks for the update. Did you find any work-around for this issue?
>
> Thanks,
> Prince.
>
> "John Lim" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Hmm, I have also been having similar problems with LOBs. However it
might
> > not
> > be cursor_sharing=force, because on my Win 2000 oracle, LOBs work fine
> with
> > PHP
> > with this parameter set.
> >
> > However on our Sun server, PHP crashes as you mention (yes
> > cursor_sharing=force is
> > set here too).
> >
> > PS: this is set in init.ora.
> >
> >
> >
> >
> > "Prince" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > I have the following php code. If I add the parameter
> CURSOR_SHARING=FORCE
> > >
> > > in my init.ora and while executing the program I get the "Segmentation
> > > fault".
> > >
> > > $ /usr/local/php4/bin/php -q curshare.php
> > >
> > > Segmentation fault (core dumped)
> > >
> > > Is there any work-around for this? Is this a bug? This seems to be
> > happening
> > > only when LOB with returning clause is present.
> > >
> > > I tested a similar program from "C" program and is fine.
> > >
> > > Note: currently I have set the parameter  (CURSOR_SHARING=FORCE ) only
> in
> > > the program/session level.
> > >
> > > Thanks,
> > >
> > > Prince.
> > >
> > >
> > >
> > >
> > >
> > > $ cat curshare.php
> > >
> > > #!/usr/local/php4/bin/php -q
> > >
> > >  > >
> > > //program name curshare.php
> > >
> > > $conn = OCILogon($dbuser, $dbpass, $dbname);
> > >
> > > //This is added to affect only the current session.
> > >
> > > $sql = "alter session set cursor_sharing=force";
> > >
> > > $stmt = ociparse($conn,$sql);
> > >
> > > OCIExecute($stmt,OCI_DEFAULT);
> > >
> > > $lob = OCINewDescriptor($conn, OCI_D_LOB);
> > >
> > > $sqlstmt = "insert into blob_test ( packageid, packagebody )
> > > values('12344321123efd', EMPTY_BLOB()) returning packagebody into
> > > :packagebody";
> > >
> > > $stmt = OCIParse($conn, $sqlstmt) ;
> > >
> > > OCIBindByName($stmt, ':packagebody', &$lob, -1, OCI_B_BLOB);
> > >
> > > OCIExecute($stmt, OCI_DEFAULT);
> > >
> > > OCICommit($conn);
> > >
> > > OCIFreeDesc($lob);
> > >
> > > OCIFreeStatement($stmt);
> > >
> > > OCILogoff($conn);
> > >
> > > ?>
> > >
> > >
> > >
> >
> >
>
>



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




[PHP-DB] Re: Delete from mysql table is there a way to....

2002-04-15 Thread phplists

I'm not sure how to change DELETE statements in this fashion, but is there a
way maybe to run an OPTIMIZE TABLE query every so often in your PHP script..
I don't imagine you'd want it running too often since it locks the table you
run it on, but maybe on the reload of $PHP_SELF or something.. It can take a
while to run on tables with lots of data, so it may not be the best option
anyway.. Just a thought though.. Ooh, maybe a PHP script run from a cron job
every couple hours or something even??

Later,

Bob Weaver

"Jennifer Downey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi all,
> I'm not sure if my first post showed up so I am going to post it again and
I
> apologize if it shows up twice.
>
> Is there a way to delete a record from a mysql table without fragmenting
the
> db?
>
> Here is the query I am using and it does a horrible job. Fragment city.
>
>
>
> if ($quantity == 0)
>  {
> $gone = mysql_query("DELETE FROM {$config["prefix"]}_my_items WHERE
> uid={$session["uid"]} AND id = '$item'");
>   }
>
>
>
>
> Thanks
> Jennifer
>
>
> --
> The sleeper has awaken
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002
>
>



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




Re: [PHP-DB] Delete from mysql table is there a way to....

2002-04-15 Thread Jason Wong

On Monday 15 April 2002 08:46, Jennifer Downey wrote:
> Hi all,
> I'm not sure if my first post showed up so I am going to post it again and
> I apologize if it shows up twice.

The first post did show up. This is purely a MySQL issue.

> Is there a way to delete a record from a mysql table without fragmenting
> the db?

No. If you do a lot of deletes then you can optimize the table now and again 
to ensure maximum performance. See MySQL for details.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
There is only one way to kill capitalism -- by taxes, taxes, and more taxes.
-- Karl Marx
*/

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




[PHP-DB] Re: Delete from mysql table is there a way to....

2002-04-15 Thread phplists

Maybe if you ran the delete query, then the optimize table query immed
after, it wouldn't take such a long time.. I would imagine if you had quite
large tables though, it could still take some time.. And if users are
connecting over the internet, you don't want too may delays..

If the user doesn't need any specific feedback about the delete command, you
could do a low priority delete.. That's sketchy at best though from what I
could gather in the manual and around. It just queues the query until the
database is done with everything but it sounds like it might release the
user/client to go on with what they're doing..

You might also check into truncate.. The mysql manual talks about it
briefly.. I guess it's an Oracle thing that mysql supports.. It sounds like
it would keep things clean but sounds slow possibly..

Later,

Bob

"Jennifer Downey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi all,
> I'm not sure if my first post showed up so I am going to post it again and
I
> apologize if it shows up twice.
>
> Is there a way to delete a record from a mysql table without fragmenting
the
> db?
>
> Here is the query I am using and it does a horrible job. Fragment city.
>
>
>
> if ($quantity == 0)
>  {
> $gone = mysql_query("DELETE FROM {$config["prefix"]}_my_items WHERE
> uid={$session["uid"]} AND id = '$item'");
>   }
>
>
>
>
> Thanks
> Jennifer
>
>
> --
> The sleeper has awaken
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002
>
>



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




Re: [PHP-DB] Insert select does not insert all rows.

2002-04-15 Thread andy

the statement is executed directly on the server without php just mysql

any other ideas?

thanx, Andy

insert into geodata_backup.provinces_test
(country_code,province,province_id)
select country_code, name, province_id
from import.provinces_update_imported





"Olinux" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> The script is probably timimg out. Default timeout is
> 30 seconds.
>
> Stick this in your script
> set_time_limit(0);
>
> set_time_limit() has no effect when PHP is running in
> safe mode
> http://www.php.net/manual/en/function.set-time-limit.php
>
> olinux
>
>
> --- andy <[EMAIL PROTECTED]> wrote:
> > Hi there,
> >
> > I am trying to update a table with new rows. The new
> > rows are in another
> > table so thought a insert select would be the right
> > choice.
> >
> > Unfortunatelly it is only inserting about 400 rows,
> > but the table contains
> > more than 700.
> >
> > So I do really not know whats going on. Maybe
> > someone could help on this.
> > Thanx in advance.
> >
> > Andy
> >
> > Statement:
> > insert into geodata_backup.provinces_test
> > (country_code,province,province_id)
> > select country_code, name, province_id
> > from import.provinces_update_imported
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> __
> Do You Yahoo!?
> Yahoo! Tax Center - online filing with TurboTax
> http://taxes.yahoo.com/



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




[PHP-DB] Cross DB application

2002-04-15 Thread Arcadius A.


Hello !
I'm planning to write a database application for  MySQL, and then port it to
PostrgeSQL.
Is there any library or class that could help me to write/maintain just one
source code for both MySQL and PostgreSQL ?

Thanks.

ARcadius



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




[PHP-DB] newsletter

2002-04-15 Thread its me

hi guys,
i wanna make a news letter as follows:
i sell items within certain categories,so whenever a buyer is registered he choose 
some categories to contribute to my newsletter with:
whenever a new item is added within this category i send him an email with that.

i'm storing the mails in database.

does anyone have something like this that can help me??

i tried in my script that whenever an item is added i send  aletter to all who is 
subscribed under this category,but i need to know the ID of this item that is added 
first,so i faild to do that


Rehab M.Shouman





-
Express yourself with a super cool email address from BigMailBox.com.
Hundreds of choices. It's free!
http://www.bigmailbox.com
-

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




Re: [PHP-DB] Cross DB application

2002-04-15 Thread Andrew Hill

ARcadius,

You may use an abstraction library such as PEARDB or ADODB, or
simply the unified ODBC functions.

Best regards,
Andrew Hill
Director of Technology Evangelism
OpenLink Software

>
> Hello !
> I'm planning to write a database application for  MySQL, and then
port
> it to PostrgeSQL.
> Is there any library or class that could help me to write/maintain just
> one source code for both MySQL and PostgreSQL ?
>
> Thanks.
>
> ARcadius
>
>
>
> --
> 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] Insert select does not insert all rows.

2002-04-15 Thread Maureen

I'm curious, if this is not using php, why are you posting to the php-db 
mailing list?  Why not post to the mysql mailing list?

Just a thought.




andy <[EMAIL PROTECTED]> said:

> the statement is executed directly on the server without php just mysql
> 
> any other ideas?
> 
> thanx, Andy
> 
> insert into geodata_backup.provinces_test
> (country_code,province,province_id)
> select country_code, name, province_id
> from import.provinces_update_imported
> 
> 
> 
> 
> 
> "Olinux" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > The script is probably timimg out. Default timeout is
> > 30 seconds.
> >
> > Stick this in your script
> > set_time_limit(0);
> >
> > set_time_limit() has no effect when PHP is running in
> > safe mode
> > http://www.php.net/manual/en/function.set-time-limit.php
> >
> > olinux
> >
> >
> > --- andy <[EMAIL PROTECTED]> wrote:
> > > Hi there,
> > >
> > > I am trying to update a table with new rows. The new
> > > rows are in another
> > > table so thought a insert select would be the right
> > > choice.
> > >
> > > Unfortunatelly it is only inserting about 400 rows,
> > > but the table contains
> > > more than 700.
> > >
> > > So I do really not know whats going on. Maybe
> > > someone could help on this.
> > > Thanx in advance.
> > >
> > > Andy
> > >
> > > Statement:
> > > insert into geodata_backup.provinces_test
> > > (country_code,province,province_id)
> > > select country_code, name, province_id
> > > from import.provinces_update_imported
> > >
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> > __
> > Do You Yahoo!?
> > Yahoo! Tax Center - online filing with TurboTax
> > http://taxes.yahoo.com/
> 
> 
> 
> -- 
> 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] Cross DB application

2002-04-15 Thread Gurhan Ozen

Hi Arcadius,
If you know Object-oriented programming , you can write a class that
includes both MySQL and PostGreSQL functions and you can inherit from that
class.
Or, you can just stick all mysql, postgresql functions in a functions.php
file and include that file to be able to use the functions. I guess it would
work best if you have a configuration file where the user chooses either DB
and your code uses the corresponding function for that database.
I am sure there are database wrapper classes for php to address your issue
somewhere on the net , I just don't know where, since i have never searched
for it. I will personally email you if i come across any ...

Gurhan


-Original Message-
From: Arcadius A. [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 15, 2002 7:56 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Cross DB application



Hello !
I'm planning to write a database application for  MySQL, and then port it to
PostrgeSQL.
Is there any library or class that could help me to write/maintain just one
source code for both MySQL and PostgreSQL ?

Thanks.

ARcadius



--
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] Pdf display from Blob

2002-04-15 Thread [EMAIL PROTECTED]

We are using Interbase 6.01 as SQL-Server and PHP4.
The Interbase table was created an populated with a Delphi - Programm.
Everything is working.

Our problem is now to display the PDF Content out of Blobs.
Text - Blobs are working with ibase_blob_echo()
Outputting PDF-Blobs without MIME-Header is a garbled Text
With MIME - Header  the Acrobat-Reader 5.0 starts
but shows the errormessage
that this is not a PDF-File.

As this is not an Interbase-Problem,  I would appreciate any working
solution for any database.

Best regards

Helmut



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




[PHP-DB] Re: Saving DB Resuts to a file

2002-04-15 Thread Ray Hunter

Chris,

You will want to use the file i/o functions to write to a file and save the
db info to a file.

http://www.php.net/manual/en/function.fwrite.php

Ray "BigDog" Hunter


"Chris Payne" <[EMAIL PROTECTED]> wrote in message
000c01c1e258$f33f5ce0$f7fea8c0@chris">news:000c01c1e258$f33f5ce0$f7fea8c0@chris...
Hi there everyone,

I have a newsletter which works wonderfully, sends to everyone in the DB
fine with error checking etc ..  My problem is my client now wants to be
able to easily save the email addresses from the DB into a text file - so my
question is, how can this be done?

Connecting to the DB and executing a search based on criteria is not a
problem, the problem is how do I write a text file which has the field email
(From the table name newsletter) in it?  I just need to copy the contents of
email to a text file, but missing our other columns such as id and name.

Thanks for any help, it's very appreicated.

Chris




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




[PHP-DB] Arrays

2002-04-15 Thread Alex Francis

I am trying to insert event dats into a database and to make sure the user
puts the date in the correct format. I am now trying to collect the
information from the three fields and insert it into one field.

code as follows: $eventdate = array ("eventyear", "eventmonth", "eventday");

when I insert it into the database like: $query = "INSERT INTO $tablename4
VALUES ('0', '$entername', '$date', '$eventdate', '$eventheading',
'$eventbody' )";

for the $eventdate variable the word "array" is inserted.

Could someone please tell me where I am going wrong.

--
Alex Francis
Cameron Design
35, Drumillan Hill
Greenock PA16 0XD

Tel 01475 798106
[EMAIL PROTECTED]
http://www.camerondesign.co.uk

This message is sent in confidence for the addressee only. It may contain
legally privileged information.
Unauthorised recipients are requested to preserve this confidentiality and
to advise the sender
immediately of any error in transmission.



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




Re: [PHP-DB] Arrays

2002-04-15 Thread Jason Wong

On Tuesday 16 April 2002 04:13, Alex Francis wrote:
> I am trying to insert event dats into a database and to make sure the user
> puts the date in the correct format. I am now trying to collect the
> information from the three fields and insert it into one field.
>
> code as follows: $eventdate = array ("eventyear", "eventmonth",
> "eventday");
>
> when I insert it into the database like: $query = "INSERT INTO $tablename4
> VALUES ('0', '$entername', '$date', '$eventdate', '$eventheading',
> '$eventbody' )";
>
> for the $eventdate variable the word "array" is inserted.
>
> Could someone please tell me where I am going wrong.

You're trying to insert an array into something which is expecting a string. 
You should probably be concatenating your three fields into one string, 
something like:

$eventdate = $eventyear . $eventmonth . $eventday;

The exact format would depend on what field type your "eventdate" is.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
I'm going to give my psychoanalyst one more year, then I'm going to Lourdes.
-- Woody Allen
*/

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




Re: [PHP-DB] Arrays

2002-04-15 Thread Steve Cayford

Your $eventdate variable is an array, not a string so you can't just 
drop it into an sql query string like that.
If you have separate fields in the db for year, month and day then you 
probably want something like:

$query = "insert into ... values ( ... , '$eventdate[0]', 
'$eventdate[1]', '$eventdate[2]', ...)";

Otherwise, if they're all supposed to go into the same field then do 
something like:

$eventdatestring = join("-", $eventdate);
$query = "insert into ... values ( ..., '$eventdatestring', ...)";

This should insert the date in the form "eventyear-eventmonth-eventday";

-Steve


On Monday, April 15, 2002, at 03:13  PM, Alex Francis wrote:

> I am trying to insert event dats into a database and to make sure the 
> user
> puts the date in the correct format. I am now trying to collect the
> information from the three fields and insert it into one field.
>
> code as follows: $eventdate = array ("eventyear", "eventmonth", 
> "eventday");
>
> when I insert it into the database like: $query = "INSERT INTO 
> $tablename4
> VALUES ('0', '$entername', '$date', '$eventdate', '$eventheading',
> '$eventbody' )";
>
> for the $eventdate variable the word "array" is inserted.
>
> Could someone please tell me where I am going wrong.
>
> --
> Alex Francis
> Cameron Design
> 35, Drumillan Hill
> Greenock PA16 0XD
>
> Tel 01475 798106
> [EMAIL PROTECTED]
> http://www.camerondesign.co.uk
>
> This message is sent in confidence for the addressee only. It may 
> contain
> legally privileged information.
> Unauthorised recipients are requested to preserve this confidentiality 
> and
> to advise the sender
> immediately of any error in transmission.
>
>
>
> --
> 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] database table layout help

2002-04-15 Thread Barry Rumsey

I am setting up a music info site and have decided on the follow tables 
( not to sure weather to add the mp3 part). The one main question I have 
before starting to make the tables is weather mysql_insert_id() would be 
able to handle this with the way I have it ?
:Artist
id
artist_name

:Album
id - auto-inc
artist_id   
album_name
rec_id
image_id

:Songs
id  -  auto-inc
album_id
genre_id
mp3_id
lyrics

:Genre
id  -  auto-inc
genre

:Recording
id  -  auto-inc
recording_studio
date

:Album Image
id  -  auto-inc
image

:Artist Info
id  -  auto-inc
info

:Mp3
id  -  auto-inc
mp3_location

Any other suggestions are welcome.

B.J.Rumsey



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




Re: [PHP-DB] Arrays

2002-04-15 Thread Alex Francis

Got it now, Thank you

--
Alex Francis
Cameron Design
35, Drumillan Hill
Greenock PA16 0XD

Tel 01475 798106
[EMAIL PROTECTED]
http://www.camerondesign.co.uk

This message is sent in confidence for the addressee only. It may contain
legally privileged information.
Unauthorised recipients are requested to preserve this confidentiality and
to advise the sender
immediately of any error in transmission.
Steve Cayford <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Your $eventdate variable is an array, not a string so you can't just
> drop it into an sql query string like that.
> If you have separate fields in the db for year, month and day then you
> probably want something like:
>
> $query = "insert into ... values ( ... , '$eventdate[0]',
> '$eventdate[1]', '$eventdate[2]', ...)";
>
> Otherwise, if they're all supposed to go into the same field then do
> something like:
>
> $eventdatestring = join("-", $eventdate);
> $query = "insert into ... values ( ..., '$eventdatestring', ...)";
>
> This should insert the date in the form "eventyear-eventmonth-eventday";
>
> -Steve
>
>
> On Monday, April 15, 2002, at 03:13  PM, Alex Francis wrote:
>
> > I am trying to insert event dats into a database and to make sure the
> > user
> > puts the date in the correct format. I am now trying to collect the
> > information from the three fields and insert it into one field.
> >
> > code as follows: $eventdate = array ("eventyear", "eventmonth",
> > "eventday");
> >
> > when I insert it into the database like: $query = "INSERT INTO
> > $tablename4
> > VALUES ('0', '$entername', '$date', '$eventdate', '$eventheading',
> > '$eventbody' )";
> >
> > for the $eventdate variable the word "array" is inserted.
> >
> > Could someone please tell me where I am going wrong.
> >
> > --
> > Alex Francis
> > Cameron Design
> > 35, Drumillan Hill
> > Greenock PA16 0XD
> >
> > Tel 01475 798106
> > [EMAIL PROTECTED]
> > http://www.camerondesign.co.uk
> >
> > This message is sent in confidence for the addressee only. It may
> > contain
> > legally privileged information.
> > Unauthorised recipients are requested to preserve this confidentiality
> > and
> > to advise the sender
> > immediately of any error in transmission.
> >
> >
> >
> > --
> > 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] Re: Cross DB application

2002-04-15 Thread Manuel Lemos

Hello,

"Arcadius A." wrote:
> 
> Hello !
> I'm planning to write a database application for  MySQL, and then port it to
> PostrgeSQL.
> Is there any library or class that could help me to write/maintain just one
> source code for both MySQL and PostgreSQL ?

I think your best (if not the only) option in PHP is Metabase.

http://www.phpclasses.org/metabase

This is a PHP databases abstraction focused on application portability.
AFAIK, it is the only one that provide complete and true data type
abstraction. This means that for instance if you have to deal with dates
in your application, Metabase assures that you only have to deal with a
single date format (ISO 9601 - -MM-DD HH:MM:SS) even if the
underlying databases use other formats. So, when you switch to a
different database, you do not have to touch a single thing in your
application other that the choice of database type option.

Metabase goes farther, it also abstracts database schema installation
and maintenance. This means that it provides a way to describe a schema
of database tables, fields, indexes and sequences using a simple XML
syntax. Then the Metabase manager class will install it for you in the
target database that you use. If you move to another database, Metabase
can export the database contents in the same XML format and then you may
reinstall the schema in the new database type without loosing
information.

Here it is an example of a Metabase schema:

http://www.phpclasses.org/browse.html/file/59.html

Regards,
Manuel Lemos

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




[PHP-DB] Re: LOBS with CURSOR_SHARING=FORCE gives core dump

2002-04-15 Thread Prince

I don't think this is the bug with oracle as I was able to do the same with
C program having OCI calls.

John, I am aware of this work-around. But this requires some changes in the
application. What I would like to have is, set the parameter in the system
level (init.ora or alter system) and no changes in the application.

Thanks,

"John Lim" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> According to Thies, this is an Oracle bug. A quick workaround which I just
> tested is to execute an alter session before updating the LOB, and restore
> cursor_sharing=force after the update.
>
> ALTER SESSION SET cursor_sharing=exact
>
> Bye, John
>
> "Prince" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > John!
> >
> > Thanks for the update. Did you find any work-around for this issue?
> >
> > Thanks,
> > Prince.
> >
> > "John Lim" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Hmm, I have also been having similar problems with LOBs. However it
> might
> > > not
> > > be cursor_sharing=force, because on my Win 2000 oracle, LOBs work fine
> > with
> > > PHP
> > > with this parameter set.
> > >
> > > However on our Sun server, PHP crashes as you mention (yes
> > > cursor_sharing=force is
> > > set here too).
> > >
> > > PS: this is set in init.ora.
> > >
> > >
> > >
> > >
> > > "Prince" <[EMAIL PROTECTED]> wrote in message
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > I have the following php code. If I add the parameter
> > CURSOR_SHARING=FORCE
> > > >
> > > > in my init.ora and while executing the program I get the
"Segmentation
> > > > fault".
> > > >
> > > > $ /usr/local/php4/bin/php -q curshare.php
> > > >
> > > > Segmentation fault (core dumped)
> > > >
> > > > Is there any work-around for this? Is this a bug? This seems to be
> > > happening
> > > > only when LOB with returning clause is present.
> > > >
> > > > I tested a similar program from "C" program and is fine.
> > > >
> > > > Note: currently I have set the parameter  (CURSOR_SHARING=FORCE )
only
> > in
> > > > the program/session level.
> > > >
> > > > Thanks,
> > > >
> > > > Prince.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > $ cat curshare.php
> > > >
> > > > #!/usr/local/php4/bin/php -q
> > > >
> > > >  > > >
> > > > //program name curshare.php
> > > >
> > > > $conn = OCILogon($dbuser, $dbpass, $dbname);
> > > >
> > > > //This is added to affect only the current session.
> > > >
> > > > $sql = "alter session set cursor_sharing=force";
> > > >
> > > > $stmt = ociparse($conn,$sql);
> > > >
> > > > OCIExecute($stmt,OCI_DEFAULT);
> > > >
> > > > $lob = OCINewDescriptor($conn, OCI_D_LOB);
> > > >
> > > > $sqlstmt = "insert into blob_test ( packageid, packagebody )
> > > > values('12344321123efd', EMPTY_BLOB()) returning packagebody into
> > > > :packagebody";
> > > >
> > > > $stmt = OCIParse($conn, $sqlstmt) ;
> > > >
> > > > OCIBindByName($stmt, ':packagebody', &$lob, -1, OCI_B_BLOB);
> > > >
> > > > OCIExecute($stmt, OCI_DEFAULT);
> > > >
> > > > OCICommit($conn);
> > > >
> > > > OCIFreeDesc($lob);
> > > >
> > > > OCIFreeStatement($stmt);
> > > >
> > > > OCILogoff($conn);
> > > >
> > > > ?>
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



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




Re: [PHP-DB] Cross DB application

2002-04-15 Thread Manuel Lemos

Hello,

Andrew Hill wrote:
> 
> ARcadius,
> 
> You may use an abstraction library such as PEARDB or ADODB, or
> simply the unified ODBC functions.

Andrew, you always suggest ODBC as a good solution for portable database
application development, but AFAIK it is not a good solution at all
because for crucial things you still have to resort to database specific
code to handle database differences.

I already asked you this before but I don't recall ever getting a
satisfactory answer. I don't know if the problem is in PHP ODBC API or
is really an ODBC limitation, but for instance, when you want to
implement auto-incremented sequences of integer values that are
fundamental for database aplications to use in primary key fields, with
ODBC you there seems to be no database independent way to create and
retrieve the next sequence value.

The other important issue, especially for Web development, is query
results paging. In most current databases there some clause like for
instance MySQL LIMIT. Others use different syntaxes or clause for
restricting the range of rows that are returned by the server to the
client. This is importa, especially when you want to show a small number
of rows of a very large result set.

Once you suggested to use ODBC cursors, but that is not the same as
limiting the result rows in the actual queries. For instance, if you
need to get the first from row 10 to 19 of a result set of 1.000.000
rows, using the LIMIT clause will make the server stop the query after
20 rows. Using cursors, AFAIK will not stop the query making the
database server hog the machine needlessly to traverse 1.000.000 rows of
data that an application is not interested in.

I don't know if there are better and portable solutions using PHP ODBC
API functions, but with your ODBC knowledge is there a way to solve
these issues with a complete ODBC API (besides what PHP ODBC API can
offer)?

I would like to make a better ODBC driver class for Metabase so users
can develop portable database applications using Metabase via ODBC, but
it seems that I will have to develop subclasses for each type of ODBC
data source (MS Access, IBM DB2, SAP-DB, etc...) to handle database
specific issues that the ODBC API does not handle by itself.

Regards,
Manuel Lemos

Regards,
Manuel Lemos

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




[PHP-DB] Re: [PHP] Re: Cross DB application

2002-04-15 Thread Manuel Lemos

Hello,

James Cox wrote:
> > I'm planning to write a database application for  MySQL, and then port it
> to
> > PostrgeSQL.
> > Is there any library or class that could help me to write/maintain just
> one
> > source code for both MySQL and PostgreSQL ?
> 
> I think your best (if not the only) option in PHP is Metabase.
> 
> http://www.phpclasses.org/metabase
> 
> 
> 
> you could also use PEAR (http://pear.php.net/) which has a more than
> adequate abstraction layer for various databases.


PEAR does not offer a good means of writing portable database
applications because it does not have data type abstraction support.

This is important because different databases represent data types
differently. For instance, Oracle, unlike other databases, does not have
individual time and date field types, only a single type that represents
both a full timestamp with time and date. This means that if you just
want to store a date on the field you have to use the whole timestamp
field and discard the time part. Metabase handles that for you. PEAR
does not provide any support for this level of database portability.

I think this is an important point to mention about this limitatation of
PEAR because I noticed that a lot of people that use PEAR did not know
about it because they develop applications that only deal with text and
integers that need little or no conversion, besides any eventual
quoting.

As soon they need to use other data types like date and time, when they
need to run their applications in different databases, they realize that
PEAR was not a good idea because, unlike Metabase, it doesn't handle
datatype representation format differences.

This may not be a problem for you James, but it is a problem for a lot
of database developers that really care about portability because it
costs a lot of time and money to maintain the applications that need to
work with different databases if you have to tweak your application to
handle the differences of the databases.

This is the main reason why Java JDBC provide such an high level of
database application portability, that in the PHP world only has
parallel with Metabase.

 
> But, I doubt even metabase can rewrite your SQL queries for you so that it's
> optimized for postgres AND mysql (and any other option you would like to
> choose).

Metabase does not rewrite queries. You need to know Metabase better. It
just converts datatypes of between a database independent format that
applications use and the native database datatype format, if and when
the develop wants that.

 
> you're much better off either picking one DB system, or use both but
> maintain seperate SQL for each, to provide full optimization.

If the original poster would not mind to have the major headache of
doing that, he would not have posted, don't you think?

Regards,
Manuel Lemos

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




[PHP-DB] Definitive answer for large scale registration/authentication

2002-04-15 Thread Brad Hubbard

Can I get some feedback on the conventional wisdom as to the best solution 
for high volume registration and authentication of users accessing a secure 
site? I have worked before with database/session based methods as well as 
htaccess. Which is preferred? Are there alternatives?

Thanks for the feedback,
Brad

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




[PHP-DB] Re: Definitive answer for large scale registration/authentication

2002-04-15 Thread Manuel Lemos

Hello,

Brad Hubbard wrote:
> 
> Can I get some feedback on the conventional wisdom as to the best solution
> for high volume registration and authentication of users accessing a secure
> site? I have worked before with database/session based methods as well as
> htaccess. Which is preferred? Are there alternatives?

Probably the fastest way to keep session profile information is by
serializing the data array into a string that will be encrypted and then
stored in cookie. The security weakness of this method is that if the
secret key leaks, hackers may use to forge new sessions.

A more secure but eventually less scalable method is to store the
session data in a shared memory cache, so you minimize database accesses
to just one after the server is restarted. This is probably the one you
want to use as long you know how to deal with shared memory and
semaphores.

Regards,
Manuel Lemos

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




Re: [PHP-DB] Re: Definitive answer for large scale registration/authentication

2002-04-15 Thread Brad Hubbard

On Tue, 16 Apr 2002 14:01, Manuel Lemos did align ASCII characters thusly:
> Probably the fastest way to keep session profile information is by
> serializing the data array into a string that will be encrypted and then
> stored in cookie. The security weakness of this method is that if the
> secret key leaks, hackers may use to forge new sessions.

Is this documented anywhere? 

> A more secure but eventually less scalable method is to store the
> session data in a shared memory cache, so you minimize database accesses
> to just one after the server is restarted. This is probably the one you
> want to use as long you know how to deal with shared memory and
> semaphores.

Is this documented anywhere?

My understanding was that htaccess authentication was more secure that 
session based because of the porblems of session hijacking???

Brad

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




Re: [PHP-DB] Re: Definitive answer for large scale registration/authentication

2002-04-15 Thread Manuel Lemos

Hello,

Brad Hubbard wrote:
> 
> On Tue, 16 Apr 2002 14:01, Manuel Lemos did align ASCII characters thusly:
> > Probably the fastest way to keep session profile information is by
> > serializing the data array into a string that will be encrypted and then
> > stored in cookie. The security weakness of this method is that if the
> > secret key leaks, hackers may use to forge new sessions.
> 
> Is this documented anywhere?

Yes, but where I know I can't tell you because it is part of a
proprietary system. Maybe somebody else did it like this and documented
somewhere but I have no knowledge of that. Anyway what part didn't you
understand?


 
> > A more secure but eventually less scalable method is to store the
> > session data in a shared memory cache, so you minimize database accesses
> > to just one after the server is restarted. This is probably the one you
> > want to use as long you know how to deal with shared memory and
> > semaphores.
> 
> Is this documented anywhere?

Probably only in my mind . :-)


> My understanding was that htaccess authentication was more secure that
> session based because of the porblems of session hijacking???

I guess you mean HTTP based authentication. No, AFAIK that is very
unsecure because you can't end a "session" because browsers cache
authenticated passwords and only drop them (of they do, IE may not do
it) when you quit your browser. If you leave your browser terminal for
some time, somebody may come in and take advantage of your account
privileges.

Regards,
Manuel Lemos

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




[PHP-DB] Re: database table layout help

2002-04-15 Thread David Robley

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
says...
> I am setting up a music info site and have decided on the follow tables 
> ( not to sure weather to add the mp3 part). The one main question I have 
> before starting to make the tables is weather mysql_insert_id() would be 
> able to handle this with the way I have it ?
> :Artist
> id
> artist_name
> 
> :Album
> id - auto-inc
> artist_id   
> album_name
> rec_id
> image_id
> 
> :Songs
> id  -  auto-inc
> album_id
> genre_id
> mp3_id
> lyrics
> 
> :Genre
> id  -  auto-inc
> genre
> 
> :Recording
> id  -  auto-inc
> recording_studio
> date
> 
> :Album Image
> id  -  auto-inc
> image
> 
> :Artist Info
> id  -  auto-inc
> info
> 
> :Mp3
> id  -  auto-inc
> mp3_location
> 
> Any other suggestions are welcome.
> 
> B.J.Rumsey

In answer to your specific question, yes, mysql_insert_id will work for 
you as you have auto-increment fileds on each table.

In passing, you could probably combine your artist and artist_info into 
one table - assuming there will only be one 'info' for each artist. 
Similarly, album and album_image could be combined.

I don't see a song title field? Is that deliberate, or did you miss that 
(or am I blind?)

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

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




Re: [PHP-DB] Delete from mysql table is there a way to....

2002-04-15 Thread Lisi

What exactly does it mean when a table becomes fragmented? How do you know 
when it's happened and something should be done? All the docs and books 
talk about how bad it is but I'm still confused on what this is and when it 
happens.

Thanks,

-Lisi


At 05:00 PM 4/14/02 -0700, Jennifer Downey wrote:
>Hi all,
>
>Is there a way to delete a record from a mysql table without fragmenting the
>db?
>
>Here is the query I am using and it does a horrible job. Fragment city.
>
>
>
>
>
>
>if ($quantity == 0)
>  {
> $gone = mysql_query("DELETE FROM {$config["prefix"]}_my_items WHERE
>uid={$session["uid"]} AND id = '$item'");
>   }
>
>
>
>
>
>
>
>Thanks
>Jennifer
>
>--
>The sleeper has awaken
>
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002
>
>
>
>--
>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] Re: Definitive answer for large scale registration/authentication

2002-04-15 Thread Brad Hubbard

On Tue, 16 Apr 2002 14:51, Manuel Lemos did align ASCII characters thusly:
> > > then stored in cookie. The security weakness of this method is that if
> > > the secret key leaks, hackers may use to forge new sessions.
> >
> > Is this documented anywhere?
> Anyway what part didn't you
> understand?

I think I understand all of it. Serialization of a session (or session 
object) is fairly straightforward and I know how to store that in a cookie. I 
was just hoping there was a "cookbook" out there. Don't have any classes on 
your site that do this do you?  ;-)

> > > accesses to just one after the server is restarted. This is probably
> > > the one you want to use as long you know how to deal with shared memory
> > > and semaphores.
> >
> > Is this documented anywhere?
>
> Probably only in my mind . :-)

Can I borrow it

> I guess you mean HTTP based authentication. 

Yes.

> No, AFAIK that is very
> unsecure because you can't end a "session" because browsers cache
> authenticated passwords and only drop them (of they do, IE may not do
> it) when you quit your browser. If you leave your browser terminal for
> some time, somebody may come in and take advantage of your account
> privileges.

The physical security of the users machine is their responsibility. I'm 
looking for good security, ease of implementation, and scalability.

At the moment it seems to be a case of "pick any two".

Brad

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