RE: [PHP-DB] Convert String to Array

2005-09-30 Thread Hutchins, Richard
Is it possible for you to store the vehMdlCd array as a serialized field in
your database?

I'm not sure how your data is structured, but you would serialize() your
data on the way into the db then unserialize() it when you select it. When
it's unserialized, you'll get it back in the original array format and you
can do with it whatever you please.

Chek out serialize() and unserialize() in the PHP docs and see if that will
work for you.

Rich

-Original Message-
From: Ng Hwee Hwee [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 29, 2005 11:23 PM
To: PHP DB List
Subject: [PHP-DB] Convert String to Array


Hi guys,

this looks like a very simple problem but i really have no idea how to do
it.. please help me! thanks!

my MySQL database has a table of which 2 fields are as follow

T100FieldNmT100Value
==   =
vehMdlCd[0] MER
vehMdlCd[1] LEX
vehMdlCd[2] TOY

and I need to echo out the value for $vehMdlCd[0]...[2]. but when I retrieve
T100FieldNm from the database, PHP recognises it only as a string. Thus, in
order to get the value of $vehMdlCd[0], I need to do the following.

for($i=0; $i$numOfRows; $i++)
{
   $tmpVehMdlCd = vehMdlCd[$i];
   $vehMdlCd[$i] = $$tmpVehMdlCd;
}

where $numOfRows has been calculated by doing a count of  all T100FieldNm
like vehMdlCd%.

Can someone enlighten me with a simpler way?! Potentially I can have a 100
over different T100FieldNm! =(

I tried using settype and type-casting but still don't get the respective
T100Value! *sob*

Thanks sooo much!

Best regards,
Hwee Hwee

-- 
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] PHP Forms - upload VS text

2005-09-30 Thread Rui Cruz
Hi, I'm a fairlly experienced developer but there's something that just 
really gets to me...

I can:

- Use a form to upload a file or files
- Use a form to write text to whaever is needed (DB, e-mail contents, 
etc...)

but I CAN'T

- Use the same form to do both.

I've tried so many diferent things and never got my scripts to upload a file 
and insert data to a DB.

I find it dificult to accept this. Is this normal or am I doing things 
wrong? Could anyone shed some light on this issue please? 

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



RE: [PHP-DB] Convert String to Array

2005-09-30 Thread Norland, Martin
Are you sure you even want to be storing it that way?  What happens when
you delete the following row?  Do you have to re-index each column?
There's no (trivially) easy way to do that with an update statement as
it stands.

vehMdlCd[1] LEX

You're likely better off storing it simply as field/value, and storing
the numbering in another column if you actually need the number at all.
Then you can pull each out and simply

$T100s[$row['T100Field']][] = $row['T100Value']; // or equivalent

This also gives you the benefit of being able to make a unique key
against t100field/t100value to prevent duplicates at your database
level.

T100FieldT100Nm  T100Value
==   =   =
vehMdlCd 0   MER
vehMdlCd 1   LEX
vehMdlCd 2   TOY

* again, I'd only keep T100Nm around if you need it for sorting
purposes, don't use it as an array index, if you do or might even remove
rows/etc. and need the array condensed.
---
Otherwise I'd just pull each row out, match it to its prefix
/(^[^\[]*)[([^\]]*)]/ and make an array out of the result.  Still, lots
more effort than the separate columns method.

cheers,
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257

The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


-Original Message-
From: Ng Hwee Hwee [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 29, 2005 10:23 PM
To: PHP DB List
Subject: [PHP-DB] Convert String to Array. .

Hi guys,

this looks like a very simple problem but i really have no idea how to
do
it.. please help me! thanks!

my MySQL database has a table of which 2 fields are as follow

T100FieldNmT100Value
==   =
vehMdlCd[0] MER
vehMdlCd[1] LEX
vehMdlCd[2] TOY

and I need to echo out the value for $vehMdlCd[0]...[2]. but when I
retrieve
T100FieldNm from the database, PHP recognises it only as a string. Thus,
in
order to get the value of $vehMdlCd[0], I need to do the following.

for($i=0; $i$numOfRows; $i++)
{
   $tmpVehMdlCd = vehMdlCd[$i];
   $vehMdlCd[$i] = $$tmpVehMdlCd;
}

where $numOfRows has been calculated by doing a count of  all
T100FieldNm
like vehMdlCd%.

Can someone enlighten me with a simpler way?! Potentially I can have a
100
over different T100FieldNm! =(

I tried using settype and type-casting but still don't get the
respective
T100Value! *sob*

Thanks sooo much!

Best regards,
Hwee Hwee

-- 
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] Convert String to Array

2005-09-30 Thread Miles Thompson

At 12:22 AM 9/30/2005, Ng Hwee Hwee wrote:

Hi guys,

this looks like a very simple problem but i really have no idea how to do
it.. please help me! thanks!

my MySQL database has a table of which 2 fields are as follow

T100FieldNmT100Value
==   =
vehMdlCd[0] MER
vehMdlCd[1] LEX
vehMdlCd[2] TOY

and I need to echo out the value for $vehMdlCd[0]...[2]. but when I retrieve
T100FieldNm from the database, PHP recognises it only as a string. Thus, in
order to get the value of $vehMdlCd[0], I need to do the following.

for($i=0; $i$numOfRows; $i++)
{
   $tmpVehMdlCd = vehMdlCd[$i];
   $vehMdlCd[$i] = $$tmpVehMdlCd;
}

where $numOfRows has been calculated by doing a count of  all T100FieldNm
like vehMdlCd%.

Can someone enlighten me with a simpler way?! Potentially I can have a 100
over different T100FieldNm! =(

I tried using settype and type-casting but still don't get the respective
T100Value! *sob*

Thanks sooo much!

Best regards,
Hwee Hwee


Look to your data - why are you storing an array element name matched with 
a vehicle line? The T100Value appears to be the key field, retrieve it and 
build your array within your script.


Think hard about why we have relational databases -- you are tying a value 
to a position with this structure. If ever something has to be inserted in 
the middle everything that follows will be broken, or you will be driven 
into v. peculiar constructs to solve a problem which could have been 
avoided up front.


On the other hand, I know nothing about your data or your application, o 
maybe I'm blowing smoke.


Regards - Miles Thompson  


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



RE: [PHP-DB] PHP Forms - upload VS text

2005-09-30 Thread Norland, Martin
form action=?php tpl($_SERVER['REQUEST_URI']) ? method=post
enctype=multipart/form-data

Beyond that it's just the $_FILES array and $_POST array. 

cheers,
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257

The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


-Original Message-
From: Rui Cruz [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 30, 2005 8:18 AM
To: php-db@lists.php.net
Subject: [PHP-DB] PHP Forms - upload VS text. .

Hi, I'm a fairlly experienced developer but there's something that just 
really gets to me...

I can:

- Use a form to upload a file or files
- Use a form to write text to whaever is needed (DB, e-mail
contents, 
etc...)

but I CAN'T

- Use the same form to do both.

I've tried so many diferent things and never got my scripts to upload a
file 
and insert data to a DB.

I find it dificult to accept this. Is this normal or am I doing things 
wrong? Could anyone shed some light on this issue please? 

-- 
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] Connecting to two MySQL databases

2005-09-30 Thread Jarratt Ingram
Hi Charles,

I had this problem a while ago, when you try to create the second connection
to the database with the same login credentials, i.e username and password.
If mysql / php detect there is a connection already established with those
details it will return that specfic resouce and not create an new
connection. The only way around this is to create a new username + password
for this database and use those details to generate the second connection.

Hth
Jarratt



On 9/29/05, Miguel Guirao [EMAIL PROTECTED] wrote:



 I agree with this solution!!

 -Original Message-
 From: Micah Stevens [mailto:[EMAIL PROTECTED]
 Sent: Jueves, 29 de Septiembre de 2005 01:10 p.m.
 To: php-db@lists.php.net
 Subject: Re: [PHP-DB] Connecting to two MySQL databases


 I don't see a reason to duplicate the class code, just make it keep track
 of
 the $link variable, and each instance of the class can be a seperate
 connection.. Then you can do what you want:

 $db1 = new dbconn;
 $db2 = new dbconn;

 $db1-dbconn($host, $user, $pw);
 $db2-dbconn($host2, $user2, $pw2);

 $result_from_first_db = $db1-retrieveData($sql);
 $result_from_second_db = $db2-retrieveData($sql);


 You're making the class too specific. IMHO.
 -Micah


 On Thursday 29 September 2005 10:56 am, Charles Kline wrote:
  Hi all,
 
  I am working on an application that requires me to connect to two
  MySQL databases both hosted on the same server.
 
  I have an existing set of class files I created to handle the db
  connection to the main database. To connect to the second database, I
  duplicated my db class files and renamed them, and also renamed the
  functions etc. but what is happening, is that the calls made to the
  second database connection seem to get made against the first
  database. So that I get errors like: dbname.tablename was not found
  (or something like that).
 
  What is the best practice for this? I need to have two open db
  connections for just two little things in my application.
 
  My class files are one makes the connection and the other calls the
  various get and set functions to the db.
 
  Here is what I have for the dbconnect.php class:
 
  class dbconn {
  // database setup. These should be changed accordingly.
  var $dbpath = localhost;
  var $dbname = mydb;
  var $dblogin = test;
  var $dbpass = test;
 
 
  function dbconn() {
  $link = mysql_connect($this-dbpath, $this-dblogin, $this-
 
  dbpass) or die ('Not Connected: ' . mysql_error());
 
  mysql_select_db($this-dbname, $link) or die ('Can\'t use this
  database: ' . mysql_error());
 
  }
 
  function retrieveData( $sql ) {
  $rs = mysql_query( $sql ) or die(Invalid query:  . mysql_error
  ());
  // if no result, return null
  if (($rs == null) || (mysql_num_rows($rs) == 0)) {
  return null;
  } else {
  return ( $rs );
  }
  }
 
  function insertData( $sql ) {
  mysql_query( $sql );
  // return new complaint id if insert is successful
  if ( mysql_affected_rows()  0 ) {
  return ( mysql_insert_id() );
  } else {
  return null;
  }
  }
 
  function updateData( $sql ) {
  $rs = mysql_query( $sql );
  if (mysql_affected_rows()  0) {
  return ( $rs );
  } else {
  return null; // no changes were made
  }
  }
  }
 
 
  I posted this to the php-general list the other day, but never got it
  working right with the suggestions. Sorry if this is a repeat for
  anyone.
 
  - Charles
 
  --
  RightCode, Inc.
  900 Briggs Road #130
  Mount Laurel, NJ 08054
  P: 856.608.7908
  F: 856.439.0154
  E: [EMAIL PROTECTED]

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


 Este mensaje es exclusivamente para el uso de la persona o entidad a quien
 esta dirigido; contiene informacion estrictamente confidencial y legalmente
 protegida, cuya divulgacion es sancionada por la ley. Si el lector de este
 mensaje no es a quien esta dirigido, ni se trata del empleado o agente
 responsable de esta informacion, se le notifica por medio del presente, que
 su reproduccion y distribucion, esta estrictamente prohibida. Si Usted
 recibio este comunicado por error, favor de notificarlo inmediatamente al
 remitente y destruir el mensaje. Todas las opiniones contenidas en este mail
 son propias del autor del mensaje y no necesariamente coinciden con las de
 Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas,
 controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no
 contiene acentos.

 This message is for the sole use of the person or entity to whom it is
 being sent. Therefore, it contains strictly confidential and legally
 protected material whose disclosure is subject to penalty by law. If the
 person reading this message is not the one to whom it is being sent and/or
 is not an employee or the responsible agent for this information, this
 person is herein notified that any unauthorized dissemination, distribution
 or copying of the materials included in this facsimile is strictly
 prohibited. If you 

Re: [PHP-DB] PHP Forms - upload VS text

2005-09-30 Thread Rui Cruz

Humm.. in the form action you use a function called tpl();

What function is that, I find no reference of it on the php.net function 
list.



- Original Message - 
From: Norland, Martin [EMAIL PROTECTED]

Newsgroups: php.db
To: php-db@lists.php.net
Sent: Friday, September 30, 2005 3:36 PM
Subject: RE: [PHP-DB] PHP Forms - upload VS text


form action=?php tpl($_SERVER['REQUEST_URI']) ? method=post
enctype=multipart/form-data

Beyond that it's just the $_FILES array and $_POST array.

cheers,
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257

The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


-Original Message-
From: Rui Cruz [mailto:[EMAIL PROTECTED]
Sent: Friday, September 30, 2005 8:18 AM
To: php-db@lists.php.net
Subject: [PHP-DB] PHP Forms - upload VS text. .

Hi, I'm a fairlly experienced developer but there's something that just
really gets to me...

I can:

   - Use a form to upload a file or files
   - Use a form to write text to whaever is needed (DB, e-mail
contents,
etc...)

but I CAN'T

   - Use the same form to do both.

I've tried so many diferent things and never got my scripts to upload a
file
and insert data to a DB.

I find it dificult to accept this. Is this normal or am I doing things
wrong? Could anyone shed some light on this issue please?

--
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] joining tables in postgres

2005-09-30 Thread redhat
On Thu, 2005-09-29 at 19:51 -0300, Miles Thompson wrote:
 At 04:13 PM 9/29/2005, redhat wrote:
 anyone know of any good tutorials on simple joining of tables in
 Postgres using PHP?  I did some Googling and didn't find anything
 satisfactory.
 thanks,
 Doug
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 You mean like this, after establishing the connection ...
 
 $sql = SELECT childname, childinitial, surname FROM children, parent WHERE 
 children.familykey = parent.familykey;
 
 $result = pg_query( $sql);
 
 and then process the results using the appropriate pg_ commands. See the 
 manual.
 
 But the join is done with the SQL.
 
 Regards - Miles 
 
I have been given a database with two tables in it that I need to
extrapolate the data into some sort of readable format.  On the first
table (call it logon) it really only has three columns:
logon_id logon_name  logon_passwd

The second table (call it client_data) has quite a few columns in it -
most of which are not used - some of them are as follows:
client_idlast_name   first_name   home_phone   addr   logon_id

In both tables the common denominator is the logon_id field.  I need
to tie the two together and display this information.  If I run the
following command:
$sql = SELECT  logon_name, logon_passwd, last_name, first_name,
home_phone, addr FROM logon, client_data WHERE logon.logon_id =
client_data.logon_id;
$result = pg_query($sql);
etc...
Does this look right?

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



Re: [PHP-DB] Connecting to two MySQL databases

2005-09-30 Thread Larry E. Ullman
I had this problem a while ago, when you try to create the second  
connection
to the database with the same login credentials, i.e username and  
password.
If mysql / php detect there is a connection already established  
with those

details it will return that specfic resouce and not create an new
connection. The only way around this is to create a new username +  
password
for this database and use those details to generate the second  
connection.


Actually, the mysql_connect() function takes an optional fourth  
argument indicating whether or not a new connection should be made.  
If omitted, then PHP will do exactly what you are describing. If set,  
then PHP will create a new connection, even if the same username/ 
password/host combination is being used.


Larry

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



[PHP-DB] Trouble with conections between php and postgre

2005-09-30 Thread luis linietsky
Hi !, first of all: sorry about my english, i'm not from us.
I 'm using latest versions of postgre 7.4 with php4 and apache2, on a debian
system. I'm working with a really big database, so there are many querys
that takes too much time to be executed that blocks the php page that's
being loaded. The problem is that usually, one excepcts to stop the query or
even close the conection if the stupid user stops the explorer or closes it.
However, this isn't hapening, the query keeps running in the database, using
resources.
I already try uselessly ignore_user_abort(False), and I don't want to set a
time limit.
¿Any ideas? ¿Am I missing something ?
Thnxs !
(Please, try avoid msg. like Get more resources, Optimize your querys,
/etc/init/postgresql restart, etc.)


RE: [PHP-DB] PHP Forms - upload VS text

2005-09-30 Thread Norland, Martin

Ahh, ignore that - our tpl() is an echo() replacement that our codebase
has, which can take parameters to do fun things.  There's no logical
reason to use it in this place, except it's shorter  to type than echo,
and it's habit.

Wiz 'o Oz Pay no attention to the man behind the curtain.

:)

cheers,
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257

The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


-Original Message-
From: Rui Cruz [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 30, 2005 10:26 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] PHP Forms - upload VS text. .

Humm.. in the form action you use a function called tpl();

What function is that, I find no reference of it on the php.net function

list.


- Original Message - 
From: Norland, Martin [EMAIL PROTECTED]
Newsgroups: php.db
To: php-db@lists.php.net
Sent: Friday, September 30, 2005 3:36 PM
Subject: RE: [PHP-DB] PHP Forms - upload VS text


form action=?php tpl($_SERVER['REQUEST_URI']) ? method=post
enctype=multipart/form-data

Beyond that it's just the $_FILES array and $_POST array.

cheers,
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257

The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


-Original Message-
From: Rui Cruz [mailto:[EMAIL PROTECTED]
Sent: Friday, September 30, 2005 8:18 AM
To: php-db@lists.php.net
Subject: [PHP-DB] PHP Forms - upload VS text. .

Hi, I'm a fairlly experienced developer but there's something that just
really gets to me...

I can:

- Use a form to upload a file or files
- Use a form to write text to whaever is needed (DB, e-mail
contents,
etc...)

but I CAN'T

- Use the same form to do both.

I've tried so many diferent things and never got my scripts to upload a
file
and insert data to a DB.

I find it dificult to accept this. Is this normal or am I doing things
wrong? Could anyone shed some light on this issue please?

-- 
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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Email Article, Print Article

2005-09-30 Thread Tramelw
Hello,
 
I am running an article-based site, where I would like to add two buttons:  
print this article and email this article.
 
Does anyone know where I could look to find out how to program this code  
into my article.php page?
 
 
Thanks in advance,
 
 
Eddie Wonder


RE: [PHP-DB] Email Article, Print Article

2005-09-30 Thread Bastien Koert

Sure, not that hard...the usual trick with printing is to add this button

input type='button' value='print' onclick='window.print();'

To email it, I would add a button that has a link to the article (like the 
id reference no) and then with the onlclick open a small window with the 
form to add the email address(es). On submitting that little form, it pulls 
the article from the storage and either embeds it or attaches it to an 
email...depending on how you want to handle it...


Does that help?

Bastien




From: [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Email Article, Print Article
Date: Fri, 30 Sep 2005 13:50:37 EDT

Hello,

I am running an article-based site, where I would like to add two buttons:
print this article and email this article.

Does anyone know where I could look to find out how to program this code
into my article.php page?


Thanks in advance,


Eddie Wonder


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



Re: [PHP-DB] Email Article, Print Article

2005-09-30 Thread Micah Stevens

No, but it's pretty straightforward, just have each link to another script 
along with a get variable that defines which article (assuming they're in a 
database or something)

email_article.php?article=$articleID
print_article.php?article=$articleID

email_article.php: (pseudo code)

?php

// first get article from storage

// setup mail_mime session (Pear class)

// attach article to friendly email, or insert directly. 

// send it

?

print_article.php:

?php

// get article from storage

// print it on screen without headers and stuff you don't want to print. 

?


Done.. 

-Micah 


On Friday 30 September 2005 10:50 am, [EMAIL PROTECTED] wrote:
 Hello,

 I am running an article-based site, where I would like to add two buttons:
 print this article and email this article.

 Does anyone know where I could look to find out how to program this code
 into my article.php page?


 Thanks in advance,


 Eddie Wonder

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



Re: [PHP-DB] Email Article, Print Article

2005-09-30 Thread Tramelw
Thank you Bastian and Micah.
 
I had no idea the concept was so straightforward.
 
I guess I was close to making a mountain out of a molehill.
 
 
Thanks again,
 
 
E. Wonder
 


[PHP-DB] More random RAND() in MYSQL

2005-09-30 Thread Graham Anderson

The ORDER BY RAND() function is not incredibly random
Is there some way to make RAND() a bit more spontaneous ?


$sql = SELECT media.id,
artist.name as artist,
artist.spanish as bio,
artist.purchaseLink,
artist.picture,
media.spanish as trackName,
media.path,
media.quality,
mediaType.id as mediaType
FROM artist, media, playlistItems, mediaType
WHERE playlistItems.playlist_id = $myID
AND playlistItems.media_id = media.id
AND media.artist_id = artist.id
AND media.mediaType_id = mediaType.id
ORDER BY RAND() LIMIT 0, 30;


many thanks
g

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