[PHP] Batch/Prepared statements for Mysql in PHP

2004-05-01 Thread electroteque
I was wondering if there is any current API for creating match/prepare
statements, therefore say i have a script to insert, update and insert in
the same post, is there a way to reduce to many queries to the database to
do it all in one hit ? Although i usually return the last inc id then add it
to the second query ?

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



[PHP] @session_start()?

2004-05-01 Thread Brandon Goodin
I noticed this notation in one of the PEAR packages @session_start()? What
is the purpose of the '@' sign?

 

Thanks

Brandon



[PHP] Script never returns from funktion.

2004-05-01 Thread Lars . Pedersen




Hi ,  i am having problems with a funktion call never returns from the
funktion.

The script is started from ldaptest.php with call the funktion
authenticate().
when inserting the real name and password the script stop's at the end and
dont return to ldaptest.php


system info:
linux Suse 9.0
php 4.3.5
http server is domino R 6.5.1.

//the code //

script ldaptest.php:

?php
include auth3.php;
if ($_COOKIE[auth] == 1) {
$msg = pYou are an authorized user./p;
} else {
authenticate(); // the script never returns from this line
   }
echo user = $username;
$ip = localhost;
$dn=CN=klaus, O=oz2lpr;
$password = fakeword;
if (!($ldap = ldap_connect($ip))) {
   die (Could not connect to LDAP server);
}
print connected to b$ip/bbr/;
if (!($res = @ldap_bind($ldap, $dn, $password))) {
   die (Could not bind to $dn);
}
print user b$dn/b authenticated.br/;
$sdn = O=fakeword2;
$filter = (objectclass=*);
print executing search...bDN: $sdn; Filter: $filter/bbr/;
$sr=ldap_search($ldap, $sdn, $filter);
$info = ldap_get_entries($ldap, $sr);
print $info[count]. entries returnedhr;
print PRE;
print_r($info);
print /PRE;
ldap_close($ldap);
die;
?


script auth3.php:

?php
function authenticate() {
if ((!$_POST[username]) || (!$_POST[password])) {
header(Location: ask.php);
}
$server=localhost;//change to ip address of ldap server
$basedn=O=oz2lpr; //change to reflect the ou and domain that your
users are in.
  $username=$_POST['username'];
  $password=$_POST['password'];
  $filter = (objectclass=*);
  $dn = CN=$username,O=oz2lpr;
if (!($connect = ldap_connect($server))) {
header(Location: ask.php);
exit;
}
if (!($bind = @ldap_bind($connect, $dn,
$password))) {
header(Location: ask.php);
exit;
} else {
  ldap_close($connect);
setcookie(auth, 1, 0, /, fakeword2.dk, 0);
return $username;
}
}
?


script ask.php:

html
head
titleAuth User Login Form/title
/head
body
H1Login Form/H1
FORM METHOD=POST ACTION=auth3.php
PSTRONGUsername:/STRONGBR
INPUT TYPE=text NAME=username/p
PSTRONGPassword:/STRONGBR
INPUT TYPE=password NAME=password/p
PINPUT TYPE=SUBMIT NAME=submit VALUE=Login/P
/FORM
/body
/html




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



[PHP] Re: @session_start()?

2004-05-01 Thread Torsten Roehr
Brandon Goodin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I noticed this notation in one of the PEAR packages @session_start()? What
 is the purpose of the '@' sign?

It suppresses/ignores any error output for this function.

Regards, Torsten




 Thanks

 Brandon



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



RE: [PHP] Script never returns from funktion.

2004-05-01 Thread PHP Email List
 Subject: [PHP] Script never returns from funktion.

 Hi ,  i am having problems with a funktion call never returns from the
 funktion.


Now I'm still new to PHP so bare with me if this is wrong. But don't you
have to assign the authenticate() function to something as your returning
the $username? I believe you need to assign it to a variable name that of
which you are echo'ing on the very next line, as the function doesn't allow
for global scope of your $username variable.

[...]
 authenticate(); // the script never returns from this line

$username = authenticate();

  }
echo user = $username;
[/...]

The PHP Pros can correct me if I'm wrong now. I thought I'd take a shot at
this one though. Thanks and HTH.
Wolf

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



php-general Digest 1 May 2004 10:14:04 -0000 Issue 2737

2004-05-01 Thread php-general-digest-help

php-general Digest 1 May 2004 10:14:04 - Issue 2737

Topics (messages 185076 through 185090):

Re: https  sessions failing to persist
185076 by: Michael R. Wayne
185077 by: Curt Zirzow

initializing HTML form using PHP
185078 by: Denis Kertz
185079 by: Daniel Clark

Separating spaces from the rest
185080 by: Anguz
185081 by: Anguz
185082 by: Curt Zirzow
185083 by: Justin Patrin

dollar sign ASCII code
185084 by: David T-G
185085 by: John W. Holmes

Batch/Prepared statements for Mysql in PHP
185086 by: electroteque

@session_start()?
185087 by: Brandon Goodin
185089 by: Torsten Roehr

Script never returns from funktion.
185088 by: Lars.Pedersen.oz2lpr.dk
185090 by: PHP Email List

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
On Fri, Apr 30, 2004 at 08:52:37PM +, Curt Zirzow wrote:
 
 session.cookie_path
 session.cookie_domain
 session.cookie_secure

session.cookie_path /
session.cookie_secure   Off
session.cookie_domain   no value

But we never use cookies:
session.use_cookies Off

/\/\ \/\/
---End Message---
---BeginMessage---
* Thus wrote Michael R. Wayne ([EMAIL PROTECTED]):
 On Fri, Apr 30, 2004 at 08:52:37PM +, Curt Zirzow wrote:
  
  session.cookie_path
  session.cookie_domain
  session.cookie_secure
 
 session.cookie_path   /
 session.cookie_secure Off
 session.cookie_domain no value
 
 But we never use cookies:
 session.use_cookies   Off

do'h.. i completly missed that.  



Curt
-- 
I used to think I was indecisive, but now I'm not so sure.
---End Message---
---BeginMessage---
I have a large HTML form (~100 form elements) that I used a year ago to
conduct a survey.  Now I would like to use this same form but rather than
starting with an empty form I would like to populate the form with a user's
survey response from last year.  I have the survey data in a mysql db and I
know how to use PHP to retrieve a user's data.  However, the only way I know
to insert a user's data into a form is to embed value=?php echo $var; 
statements for each form element (text, checkbox, drop-down, etc).  This is
pretty messy, especially for drop-down lists.

Is there a cleaner, easier way to do this?

Denis
---End Message---
---BeginMessage---
That is the way I've done it.

I hear that with PEAR, you can add elments to the HTML page.

 I have a large HTML form (~100 form elements) that I used a year ago to
 conduct a survey.  Now I would like to use this same form but rather than
 starting with an empty form I would like to populate the form with a
 user's
 survey response from last year.  I have the survey data in a mysql db and
 I
 know how to use PHP to retrieve a user's data.  However, the only way I
 know
 to insert a user's data into a form is to embed value=?php echo $var; 
 statements for each form element (text, checkbox, drop-down, etc).  This
 is
 pretty messy, especially for drop-down lists.

 Is there a cleaner, easier way to do this?

 Denis

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


---End Message---
---BeginMessage---
I have an array with many strings, of which most have spaces or tabs at 
the beginning, but no fixed number of them. Example:

$arr[0] = 'Hello.';

How can I separate them into two strings? Like:

Array
(
[0] = Array
(
[0] =   //I added the quotes to notice the space.
[1] = Hello.
)
)
TIA!
Anguz
---End Message---
---BeginMessage---
Thanks! I was just reading that function in the manual when I got your 
reply. I tested it but I still have a couple of problems with it.

print_r(preg_split('(\s+)',word1 word2 word3., -1, 
PREG_SPLIT_DELIM_CAPTURE));

I get this:

Array
(
[0] =
[1] = word1
[2] = word2
[3] = word3.
)
In [0] the spaces aren't there and it's splitting the other spaces too, 
where I need to only split the leading spaces. How should I write it?

TIA,
Anguz
Kemper, Helmut wrote:
 Hi,

 See preg_explite and use /(\s+)/ for explode string into array.

 Tanks,
 Kemper


 
 -
 Helmut Kemper
 [EMAIL PROTECTED]
 Celular (Mobile): 55 81 99268744


 On 30/04/2004, at 20:22, Anguz wrote:

 I have an array with many strings, of which most have spaces or tabs
 at the beginning, but no fixed number of them. Example:

 $arr[0] = 'Hello.';

 How can I separate them into two strings? Like:

 Array
 (
 [0] = Array
 (
 [0] =   //I added the quotes to notice the space.
 [1] = Hello.
 )
 )

 TIA!
 Anguz

[PHP] reversing an IF statement

2004-05-01 Thread Kim Steinhaug
Often I end up using a dumb IF statement which to me seems that
it could have been done some other way.

Example :
if(
($_GET[id]==1) or
($_GET[mode]==home) or
((!isset($_GET[item]))  ($_GET[mode]==news))
  ) {
// Here we do nothing
 } else {
// This is where we do it
}

If we translate the above to simpler reading we could say :
if(statement)
// skip
else
// Do the stuff

I'm ofcourse looking for this
if(!statement)
// Do the stuff

Problem is, when using more statements I never seem to find the
way of doing it without having an empty {} in it, dont know if you
see my problem here however, its the best I can exmplain.

For all I know it has to be like this.

-- 
-- 
Kim Steinhaug
--
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
--
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
--

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



[PHP] Re: reversing an IF statement

2004-05-01 Thread Torsten Roehr
Kim Steinhaug [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Often I end up using a dumb IF statement which to me seems that
 it could have been done some other way.

 Example :
 if(
 ($_GET[id]==1) or
 ($_GET[mode]==home) or
 ((!isset($_GET[item]))  ($_GET[mode]==news))
   ) {

Wouldn't this be the opposite (just inverting every condition)?:

if(
($_GET[id]!=1) 
($_GET[mode]!=home) 
((isset($_GET[item])) || ($_GET[mode]!=news))
  ) {

What do you think?

Regards, Torsten

 // Here we do nothing
  } else {
 // This is where we do it
 }

 If we translate the above to simpler reading we could say :
 if(statement)
 // skip
 else
 // Do the stuff

 I'm ofcourse looking for this
 if(!statement)
 // Do the stuff

 Problem is, when using more statements I never seem to find the
 way of doing it without having an empty {} in it, dont know if you
 see my problem here however, its the best I can exmplain.

 For all I know it has to be like this.

 --
 --
 Kim Steinhaug
 --
 There are 10 types of people when it comes to binary numbers:
 those who understand them, and those who don't.
 --
 www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
 --



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



[PHP] Re: reversing an IF statement

2004-05-01 Thread Anguz
Kim Steinhaug wrote:

Often I end up using a dumb IF statement which to me seems that
it could have been done some other way.
Example :
if(
($_GET[id]==1) or
($_GET[mode]==home) or
((!isset($_GET[item]))  ($_GET[mode]==news))
  ) {
// Here we do nothing
 } else {
// This is where we do it
}
Wouldn't it then be like this?

if($_GET['id']!=1  $_GET['mode']!='home'  (isset($_GET['item'])  
$_GET['mode']!='news'))
   // Do stuff.

I may be wrong though. Note that I used AND instead of OR for the 
conditions, because you want them all true at the same time. But then 
again, you'd have to test it, with so many conditions it becomes a bit 
difficult to picture it in my head :P

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


Re: [PHP] Re: Separating spaces from the rest

2004-05-01 Thread Anguz
Curt Zirzow wrote:
You forgot the pattern deliminator:
  
 print_r(preg_split('/(\s+)/',word1 word2 word3., -1, PREG_SPLIT_DELIM_CAPTURE));

Curt
You're right, that fixed the space capturing.

Justin Patrin wrote:
 ...I wonder why you're doing this, but here's an answer for you.

 BTW, if you use var_dump or var_export, you can see the whitespace :-).

 $arr = preg_split('/(^\s+)/',word1 word2 word3., -1,
   PREG_SPLIT_DELIM_CAPTURE);

 The ^ means beginning of string.

 This will still give you an empty string in $arr[0], so do something 
like:

 unset($arr[0]);
 $arr = array_values($arr);

 Or just write your code to expect the extra entry. ;-)

The ^ did the trick, thanks! I noticed the empty [0].

I'm doing this to display code in an indented way and to keep the indent 
if the line wraps, instead of going back all the way to the left. So I'm 
putting the spaces in a td and the code line in another td, with a 
table for each line. I tested it and looks very well, now I'm writting 
the code to generate it.

Thank you all for your help! :)

Anguz

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


[PHP] Strip_tags issue / question

2004-05-01 Thread Dave Carrera
Hi List,

I am using stip_tags to return to me just the words contained in a page from
my website but what is displayed is some thing like this :

--- Output Example ---
hello



world

Why

so much






space ?

--- End -

So where the tags were, whitespace is inserted or kept. Is there a way to
remove the whitespace so that the output is something like this?

I have tried trim() prg_replace() str_replace(' ','',$contents) but none
of these seem to work.

--- Example of what I want ---
Hello world why so much space ?
--- End ---

Thank you in advance for any help or pointers with this one.

Dave C


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28/04/2004
 

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



[PHP] PHP Conference in Amsterdam

2004-05-01 Thread Filip de Waard
Hey,

Next week I will be attending the International PHP Conference in 
Amsterdam and since I don't know anybody who will attend I thought it 
would be nice to get some contacts before I go. I'm sure there are some 
people on this list who will be going to the conference, so I thought 
this might be a good way to find some people to 'socialize' with since 
three days can be quite long ;)

Anybody who is not coming to Amsterdam can read my weblog 
(http://www.filipdewaard.com), where I will post daily updates about 
what's going on at the conference.

Cheers, Filip

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


RE: [PHP] Strip_tags issue / question

2004-05-01 Thread Dave Carrera
Thanks David,

That sorted that out nicely :-)

I hope that helps someone else on the list.

Dave C
-Original Message-
From: David Risner [mailto:[EMAIL PROTECTED] 
Sent: 01 May 2004 14:36
To: Dave Carrera
Subject: Re: [PHP] Strip_tags issue / question


How about something like:

$cleanString = preg_replace(/\s+/m,  , $spaceyString);

I haven't tried this particular preg_replace, but the 'm' option is the
important one that tells preg_replace to use the whole string instead of
breaking it up by lines.

-- David

- Original Message - 
From: Dave Carrera [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, May 01, 2004 6:27 AM
Subject: [PHP] Strip_tags issue / question


Hi List,

I am using stip_tags to return to me just the words contained in a page from
my website but what is displayed is some thing like this :

--- Output Example ---
hello



world

Why

so much






space ?

--- End -

So where the tags were, whitespace is inserted or kept. Is there a way to
remove the whitespace so that the output is something like this?

I have tried trim() prg_replace() str_replace(' ','',$contents) but none
of these seem to work.

--- Example of what I want ---
Hello world why so much space ?
--- End ---

Thank you in advance for any help or pointers with this one.

Dave C


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28/04/2004


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




---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28/04/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28/04/2004
 

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



RE: [PHP] Script never returns from funktion.

2004-05-01 Thread Lars . Pedersen




Hi Wolf

Thanks for the try. but sorry to say that the script stil hangs in the
auth3.php script.


Med venlig hilsen - Best Regards
Lars Pedersen
Notes Administrator





   
 PHP Email List  
 [EMAIL PROTECTED] 
 omTo 
   [EMAIL PROTECTED]   
 01-05-2004 12:14   cc 
   [EMAIL PROTECTED] 
   Subject 
   RE: [PHP] Script never returns from 
   funktion.   
   
   
   
   
   
   




 Subject: [PHP] Script never returns from funktion.

 Hi ,  i am having problems with a funktion call never returns from the
 funktion.


Now I'm still new to PHP so bare with me if this is wrong. But don't you
have to assign the authenticate() function to something as your returning
the $username? I believe you need to assign it to a variable name that of
which you are echo'ing on the very next line, as the function doesn't allow
for global scope of your $username variable.

[...]
 authenticate(); // the script never returns from this line

 $username = authenticate();

  }
echo user = $username;
[/...]

The PHP Pros can correct me if I'm wrong now. I thought I'd take a shot at
this one though. Thanks and HTH.
Wolf

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



[PHP] Re: https sessions failing to persist

2004-05-01 Thread Luis Bernardo

Apache or IIS? CGI or ISAPI module?

Michael R. Wayne [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 Upgraded our PHP installation from 4.1.2 to 4.3.4, scripts that
 worked fine before are no longer doing so.  The failure can be
 traced to the fact that sessions are never being reused (i.e. a new
 session gets started with each connection).  The session files get
 written with proper information but never get read.

 The relevant session variables are:
Session Support enabled
session.auto_start On
session.use_cookies Off
session.use_trans_sid On
 and, as noted in the subject line, all connections are via https.

 Any suggestions on how to debug this?

 /\/\ \/\/

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



[PHP] Php MySql selection question

2004-05-01 Thread Dave Carrera
Hi List,

I am trying to make a search box for my site and I ask the list how can I
search 24 tables to find a search string posted by a form.

I get Column: 'listing' in where clause is ambiguous when I run 

$sql = mysql_query(select * from $tbs where listing like
\$_POST[tglstring]\) or die(mysql_error());
  
$tbs is a string containing 24 table names (1 for each letter of the
alphabet).

Have a made a obvious boo boo here or is the a simple solution to what I am
trying to do?

Thank you in advance for any help or pointers

Dave C

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28/04/2004
 

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



RE: [PHP] reversing an IF statement

2004-05-01 Thread Chris
The easiest method is just to encase all the checks in parenthese, then
negate it:

if(!(
($_GET[id]==1) or
($_GET[mode]==home) or
((!isset($_GET[item]))  ($_GET[mode]==news))
  )) {
// This is where we do it
}

-Original Message-
From: Kim Steinhaug [mailto:[EMAIL PROTECTED]
Sent: Saturday, May 01, 2004 3:29 AM
To: [EMAIL PROTECTED]
Subject: [PHP] reversing an IF statement


Often I end up using a dumb IF statement which to me seems that
it could have been done some other way.

Example :
if(
($_GET[id]==1) or
($_GET[mode]==home) or
((!isset($_GET[item]))  ($_GET[mode]==news))
  ) {
// Here we do nothing
 } else {
// This is where we do it
}

If we translate the above to simpler reading we could say :
if(statement)
// skip
else
// Do the stuff

I'm ofcourse looking for this
if(!statement)
// Do the stuff

Problem is, when using more statements I never seem to find the
way of doing it without having an empty {} in it, dont know if you
see my problem here however, its the best I can exmplain.

For all I know it has to be like this.

--
--
Kim Steinhaug
--
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
--
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
--

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

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



Re: [PHP] Re: https sessions failing to persist

2004-05-01 Thread Michael R. Wayne
On Fri, Apr 30, 2004 at 10:01:40PM -0500, Luis Bernardo wrote:
 
 Apache or IIS? CGI or ISAPI module?

FreeBSD4.8 
apache+mod_ssl-1.3.29+2.8.16_1
CGI

 Michael R. Wayne [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
  Upgraded our PHP installation from 4.1.2 to 4.3.4, scripts that
  worked fine before are no longer doing so.  The failure can be
  traced to the fact that sessions are never being reused (i.e. a new
  session gets started with each connection).  The session files get
  written with proper information but never get read.
 
  The relevant session variables are:
 Session Support enabled
 session.auto_start On
 session.use_cookies Off
 session.use_trans_sid On
  and, as noted in the subject line, all connections are via https.
 
  Any suggestions on how to debug this?

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



[PHP] XSLT_SABOPT_DISABLE_ADDING_META option

2004-05-01 Thread Fabrice Dufour
hello,

how can i set |XSLT_SABOPT_DISABLE_ADDING_META option to true ?

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


[PHP] XSLT_SABOPT_DISABLE_ADDING_META option

2004-05-01 Thread Fabrice Dufour
hello,

how can i turn |the following sablotron option 
XSLT_SABOPT_DISABLE_ADDING_META to true ?

Regards,
Fabrice
|
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Select from 24 tables

2004-05-01 Thread Dave Carrera
Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list

I want to select where like $_POST[var] from a form all of the tables but I
am having trouble :(

I thought making a var string like

$string = table1,table2,table3,.;

And doing

(select * from $string where list like \%$_POST[var]%\);

Would work but I get a MySql error which say Column: 'list' in where clause
is ambiguous

I am stumped so I ask the list for help or advise please.

Any advise is very much appreciated and I thank you in advance for any help
or pointers.

Thank you

Dave C


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28/04/2004
 

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



[PHP] Re: Select from 24 tables

2004-05-01 Thread Red Wingate
First, this is a MySQL Question, next time you better send your request
to a list which covers your type of question.
use tablename.fieldname in your WHERE clause if you have fields with the
same name.
 -- red

Dave Carrera wrote:
Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list

I want to select where like $_POST[var] from a form all of the tables but I
am having trouble :(
I thought making a var string like

$string = table1,table2,table3,.;

And doing

(select * from $string where list like \%$_POST[var]%\);

Would work but I get a MySql error which say Column: 'list' in where clause
is ambiguous
I am stumped so I ask the list for help or advise please.

Any advise is very much appreciated and I thank you in advance for any help
or pointers.
Thank you

Dave C

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 28/04/2004
 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Select from 24 tables

2004-05-01 Thread John Nichel
Dave Carrera wrote:

Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list

I want to select where like $_POST[var] from a form all of the tables but I
am having trouble :(
I thought making a var string like

$string = table1,table2,table3,.;

And doing

(select * from $string where list like \%$_POST[var]%\);

Would work but I get a MySql error which say Column: 'list' in where clause
is ambiguous
I am stumped so I ask the list for help or advise please.

Any advise is very much appreciated and I thank you in advance for any help
or pointers.
Thank you

Dave C
SELECT * FROM dbname.table1, dbname.table2, dbname.table3, ...etc
WHERE table1.list LIKE '%$_POST['var']%', table2.list LIKE 
'%$_POST['var']%', table2.list LIKE '%$_POST['var']%', ...etc

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Select from 24 tables

2004-05-01 Thread John W. Holmes
Dave Carrera wrote:

Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list
The first thing you need to do is reorganize your database schema and 
put all of this into one table. You can see what a pain it is having 24 
similar tables already and it's only going to get worse.

You could probably use a UNION to join all of the tables together in 
your query, but I doubt it's going to very efficient. You can't select 
from a list of tables the way you're trying to, though.

Last option is putting your query in a loop and executing it 24 
different times, but you _really_ need to just fix the database 
structure now.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


Re: [PHP] Select from 24 tables

2004-05-01 Thread John Nichel
John W. Holmes wrote:
Dave Carrera wrote:

Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list


The first thing you need to do is reorganize your database schema and 
put all of this into one table. You can see what a pain it is having 24 
similar tables already and it's only going to get worse.

You could probably use a UNION to join all of the tables together in 
your query, but I doubt it's going to very efficient. You can't select 
from a list of tables the way you're trying to, though.

Last option is putting your query in a loop and executing it 24 
different times, but you _really_ need to just fix the database 
structure now.

Yeah, better what John said than what I said. ;)

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Select from 24 tables

2004-05-01 Thread Travis Low
This isn't always desirable, or even possible.  I once designed a database to 
hold characteristics for a series of 70 different tests.  There were about 50 
different characteristics used in various combinations for each test.  Each 
characteristic could be one of many values.  So the characteristics tables all 
looked like this:

  id, name, value

And the test tables looked like this:

  id, name, value

And the mapping of characteristics to test looked like this:

  test_id, characteristic_id

This is actually a gross oversimplification, but you get the idea.  Displaying 
test results typically required joining 30-40 tables together, but since each 
characteristic table was small (10-15 entries), performance was acceptable.

So do as John Nichel first suggested, and do this:

select c1.id as characteristic1_id, c2.id as characteristic2_id from 
characteristic1 c1, characteristic2 c2 etc.

cheers,

Travis

John W. Holmes wrote:
Dave Carrera wrote:

Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list


The first thing you need to do is reorganize your database schema and 
put all of this into one table. You can see what a pain it is having 24 
similar tables already and it's only going to get worse.

You could probably use a UNION to join all of the tables together in 
your query, but I doubt it's going to very efficient. You can't select 
from a list of tables the way you're trying to, though.

Last option is putting your query in a loop and executing it 24 
different times, but you _really_ need to just fix the database 
structure now.

--
Travis Low
mailto:[EMAIL PROTECTED]
http://www.dawnstar.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


php-general Digest 1 May 2004 22:23:15 -0000 Issue 2738

2004-05-01 Thread php-general-digest-help

php-general Digest 1 May 2004 22:23:15 - Issue 2738

Topics (messages 185091 through 185110):

reversing an IF statement
185091 by: Kim Steinhaug
185092 by: Torsten Roehr
185093 by: Anguz
185101 by: Chris

Re: Separating spaces from the rest
185094 by: Anguz

Strip_tags issue / question
185095 by: Dave Carrera
185097 by: Dave Carrera

PHP Conference in Amsterdam
185096 by: Filip de Waard

Re: Script never returns from funktion.
185098 by: Lars.Pedersen.oz2lpr.dk

Re: https  sessions failing to persist
185099 by: Luis Bernardo
185102 by: Michael R. Wayne

Php  MySql selection question
185100 by: Dave Carrera

XSLT_SABOPT_DISABLE_ADDING_META  option
185103 by: Fabrice Dufour
185104 by: Fabrice Dufour

Select from 24 tables
185105 by: Dave Carrera
185106 by: Red Wingate
185107 by: John Nichel
185108 by: John W. Holmes
185109 by: John Nichel
185110 by: Travis Low

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
Often I end up using a dumb IF statement which to me seems that
it could have been done some other way.

Example :
if(
($_GET[id]==1) or
($_GET[mode]==home) or
((!isset($_GET[item]))  ($_GET[mode]==news))
  ) {
// Here we do nothing
 } else {
// This is where we do it
}

If we translate the above to simpler reading we could say :
if(statement)
// skip
else
// Do the stuff

I'm ofcourse looking for this
if(!statement)
// Do the stuff

Problem is, when using more statements I never seem to find the
way of doing it without having an empty {} in it, dont know if you
see my problem here however, its the best I can exmplain.

For all I know it has to be like this.

-- 
-- 
Kim Steinhaug
--
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
--
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
--
---End Message---
---BeginMessage---
Kim Steinhaug [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Often I end up using a dumb IF statement which to me seems that
 it could have been done some other way.

 Example :
 if(
 ($_GET[id]==1) or
 ($_GET[mode]==home) or
 ((!isset($_GET[item]))  ($_GET[mode]==news))
   ) {

Wouldn't this be the opposite (just inverting every condition)?:

if(
($_GET[id]!=1) 
($_GET[mode]!=home) 
((isset($_GET[item])) || ($_GET[mode]!=news))
  ) {

What do you think?

Regards, Torsten

 // Here we do nothing
  } else {
 // This is where we do it
 }

 If we translate the above to simpler reading we could say :
 if(statement)
 // skip
 else
 // Do the stuff

 I'm ofcourse looking for this
 if(!statement)
 // Do the stuff

 Problem is, when using more statements I never seem to find the
 way of doing it without having an empty {} in it, dont know if you
 see my problem here however, its the best I can exmplain.

 For all I know it has to be like this.

 --
 --
 Kim Steinhaug
 --
 There are 10 types of people when it comes to binary numbers:
 those who understand them, and those who don't.
 --
 www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
 --


---End Message---
---BeginMessage---
Kim Steinhaug wrote:

Often I end up using a dumb IF statement which to me seems that
it could have been done some other way.
Example :
if(
($_GET[id]==1) or
($_GET[mode]==home) or
((!isset($_GET[item]))  ($_GET[mode]==news))
  ) {
// Here we do nothing
 } else {
// This is where we do it
}
Wouldn't it then be like this?

if($_GET['id']!=1  $_GET['mode']!='home'  (isset($_GET['item'])  
$_GET['mode']!='news'))
   // Do stuff.

I may be wrong though. Note that I used AND instead of OR for the 
conditions, because you want them all true at the same time. But then 
again, you'd have to test it, with so many conditions it becomes a bit 
difficult to picture it in my head :P

HIH,
Anguz
---End Message---
---BeginMessage---
The easiest method is just to encase all the checks in parenthese, then
negate it:

if(!(
($_GET[id]==1) or
($_GET[mode]==home) or
((!isset($_GET[item]))  ($_GET[mode]==news))
  )) {
// This is where we do it
}

-Original Message-
From: Kim Steinhaug 

[PHP] Sorting text with multibyte characters

2004-05-01 Thread Michal Migurski
Hi,

Does anyone have any thoughts on how to effectively sort text with
multi byte characters? I am working on a project that uses lots of German
text, and the letters with umlauts don't sort correctly. I'm using the
mb_* functions in a few places (to adapt an ASCII-encoded database to XML
output for flash, which is always expected to be in UTF-8), but none of
them seems to be made for string comparison.

thanks,
-mike.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



[PHP] - Delete records in an Access DB

2004-05-01 Thread francesco
Hi all, 
I have this problem:
I want to delete records in an Access DB. I use this code:

$query=DELETE FROM Test_Table WHERE name='franco';; 
// the connection parameters

$path=d:/inetpub/webs/my_site/mdb-database/ ;

$db_name=test.mdb ;

$dsource=$path.$db_name ;

$cn_string=Provider=Microsoft.Jet.OLEDB.4.0; ;

$cn_string.=Data Source=$dsource; ;

// connection

$cn=new COM(ADODB.Connection);

$cn-open($cn_string);

// object Recordset and send query by  Open() metod

$rs=new COM(ADODB.Recordset) ;

$rs-open($query,$cn) ;

// clean Recordset object

$rs-Release() ;

$rs=null ;

/* close connection */

$cn-Close() ;

$cn-Release() ;

$cn=null ;



but I have this error message:

Fatal error: Call to undefined function: open() in 
D:\Inetpub\webs\metagenonlinecom\canc.php on line 11


Where is the problem? Is this the correct way to delete records from an Access DB? If 
this is a bad tecnic, can you suggest me what is the correct way?

Thanks in advance to all.

(The server where this script run is a Microsoft server).

Francesco  







Re: [PHP] - Delete records in an Access DB

2004-05-01 Thread Torsten Roehr
So the problem is not the delete statement but that you cannot even open a
connection, right? Have you tried PHP's ODBC functions to connect to the
Access DB?:

http://de.php.net/manual/en/function.odbc-connect.php

There are some user comments regarding Access - maybe this helps.

Regards, Torsten


[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi all,
I have this problem:
I want to delete records in an Access DB. I use this code:

$query=DELETE FROM Test_Table WHERE name='franco';;
// the connection parameters

$path=d:/inetpub/webs/my_site/mdb-database/ ;

$db_name=test.mdb ;

$dsource=$path.$db_name ;

$cn_string=Provider=Microsoft.Jet.OLEDB.4.0; ;

$cn_string.=Data Source=$dsource; ;

// connection

$cn=new COM(ADODB.Connection);

$cn-open($cn_string);

// object Recordset and send query by  Open() metod

$rs=new COM(ADODB.Recordset) ;

$rs-open($query,$cn) ;

// clean Recordset object

$rs-Release() ;

$rs=null ;

/* close connection */

$cn-Close() ;

$cn-Release() ;

$cn=null ;



but I have this error message:

Fatal error: Call to undefined function: open() in
D:\Inetpub\webs\metagenonlinecom\canc.php on line 11


Where is the problem? Is this the correct way to delete records from an
Access DB? If this is a bad tecnic, can you suggest me what is the correct
way?

Thanks in advance to all.

(The server where this script run is a Microsoft server).

Francesco

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



[PHP] Re: Sorting text with multibyte characters

2004-05-01 Thread Red Wingate
Run into this before, PHP seams to do quite well when you set the locale
right ( de_DE ) which will place AÄBCD instead of ABCDÄÖÜ.
Hope this helps :-)

 -- red

Michal Migurski wrote:

Hi,

Does anyone have any thoughts on how to effectively sort text with
multi byte characters? I am working on a project that uses lots of German
text, and the letters with umlauts don't sort correctly. I'm using the
mb_* functions in a few places (to adapt an ASCII-encoded database to XML
output for flash, which is always expected to be in UTF-8), but none of
them seems to be made for string comparison.
thanks,
-mike.
-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Select from 24 tables

2004-05-01 Thread Richard A. DeVenezia
Dave Carrera wrote:
 Hi List,

 How do I select data from 24 table in my database.

 Each one is identical in structure layout being

 Id,name,list

 I want to select where like $_POST[var] from a form all of the tables
 but I am having trouble :(

 I thought making a var string like

 $string = table1,table2,table3,.;

 And doing

 (select * from $string where list like \%$_POST[var]%\);

 Would work but I get a MySql error which say Column: 'list' in where
 clause is ambiguous

 I am stumped so I ask the list for help or advise please.

 Any advise is very much appreciated and I thank you in advance for
 any help or pointers.

 Thank you

 Dave C

Try constructing a query that looks like this...

select 't1' as source, t1.* from t1 where t1.list like $criteria
union
select 't2' as source, t2.* from t2 where t2.list like $criteria
union
select 't3' as source, t3.* from t3 where t3.list like $criteria
union
...
select 't24' as source, t24.* from t24 where t24.list like $criteria
;


This query can be created by
1. storing all the table names in an array
2. constructing the individual select portion using array_map()
3. combining all individual selects using join($selects, 'union')


-- 
Richard A. DeVenezia

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



Re: [PHP] Select from 24 tables

2004-05-01 Thread Michal Migurski
 This isn't always desirable, or even possible.  I once designed a
 database to hold characteristics for a series of 70 different tests.
 There were about 50 different characteristics used in various
 combinations for each test.  Each characteristic could be one of many
 values.  So the characteristics tables all looked like this:

id, name, value

 And the test tables looked like this:

id, name, value

In my experience, it's usually a safe assumption that if you have a bunch
of tables all structured identically and used in similar ways, you should
probably merge them all into a single table with an extra column that
corresponds to whatever differentiating characteristic used to distinguish
your original tables.

I.e., go with John Holmes' suggestion before you're really up the creek.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Re: Sorting text with multibyte characters

2004-05-01 Thread Michal Migurski
 Run into this before, PHP seams to do quite well when you set the locale
 right ( de_DE ) which will place AÄBCD instead of ABCDÄÖÜ.

 Hope this helps :-)

Thanks, I hadn't thought of that.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



[PHP] php user management functionality

2004-05-01 Thread bruce
hey

doing some basic research... has anyone found a seriously good user
management script (preferably free) that can be incorporated within a web
application.

i'm looking for something that allows for the following functions:
 - user registration/login
 - admin function
 - group/team definition
 - email verification
 - database driven (mysql/postgres)
 - ability to grant user multiple rights/access levels
 - ability to check/deny by IP Address
 - session based function
 - page security
 - linux/apache/php

we've seen a few, but nothing that really grabs us we're considering
taking something like phpbb/gforge and just ripping the login/admin function
out, although we'd prefer another approach but if we have to rip the
functionality out of another app, has anybody seen an app (open source/free)
that has a serious login/admin/user management function that we should look
at...

thanks

bruce
[EMAIL PROTECTED]

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



Re: [PHP] Select from 24 tables

2004-05-01 Thread Travis Low
Michal Migurski wrote:
In my experience, it's usually a safe assumption that if you have a bunch
of tables all structured identically and used in similar ways, you should
probably merge them all into a single table with an extra column that
corresponds to whatever differentiating characteristic used to distinguish
your original tables.
I.e., go with John Holmes' suggestion before you're really up the creek.
Up what creek?  You didn't really provide any technical justification for your 
suggestion.

In my experience, the best way to deliver a quality application is to start 
with a fully-normalized database schema, then de-normalize it slightly here and 
there if performance is really a problem.  But I've rarely had to do that.  In 
most cases, an upgrade to a faster server with more memory solves the problem 
more quickly and cheaply than an application re-write would.

On the other hand, I've been called in many times to deal with application 
problems that arise from using mashed-together schemas such as the one you 
propose.

John W. Holmes wrote:
 The first thing you need to do is reorganize your database schema and
 put all of this into one table. You can see what a pain it is having 24
 similar tables already and it's only going to get worse.
The pain only occurs when writing the SQL statements to join the tables.  I 
don't think it's a good idea to optimize the database schema for the sake of 
the programmer, who only has to write the SQL one time.  Later, when the 
customer wants to fix bugs, or add enhancements, the pain is far greater. 
That's usually when I get called in, long after the original programmer has 
flown the coop.

The only times I ever purposely deliver denormalized applications such as you 
suggest are when the customers are asking for quick-and-dirty stopgap 
solutions.  Then it makes sense to optimize for the application writer. 
However, I have found that stopgap solutions have a way of becoming permanent. 
 These days, I usually turn down such jobs.

cheers,

Travis

--
Travis Low
mailto:[EMAIL PROTECTED]
http://www.dawnstar.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] reversing an IF statement

2004-05-01 Thread Curt Zirzow
* Thus wrote Kim Steinhaug ([EMAIL PROTECTED]):
 Often I end up using a dumb IF statement which to me seems that
 it could have been done some other way.
 
 Example :
 if(
 ($_GET[id]==1) or
 ($_GET[mode]==home) or
 ((!isset($_GET[item]))  ($_GET[mode]==news))

For starters, don't intermatch 'OR' with , the have different
precedence's and can lead to unexpected behaviour. The proper 'OR'
that should be used is ||. see: http://php.net/operators

Here is an approach I use to avoid making the if statement real
complicated and kinda makes it more understandable what you are
trying to accomplish with the condition:

$is_ok = $_GET[id]  == 1 ||
 $_GET[mode] == home ||
 (!isset($_GET[item])  $_GET[mode] == news));

if (! is_ok ) {
  // yada...
}


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] php user management functionality

2004-05-01 Thread Travis Low
I wrote a job-tracking/workflow management application called Willow Job 
Tracker.  You can download a copy of the free GPL version from here:

  http://dawnstar.com/index.php?display=ProductDetailsid=780

And there's a demo here:

  http://dawnstar.com/wjtf/

Login to the demo using admin/admin.

Currently, only the MySQL DB is supported, but you can add support for other 
databases by implementing the Db.class.php for each database.

Also, there are no provisions for denying based on IP, but you could add that 
pretty easily.  Though I question the utility of that, since so many people 
live behind firewalls.

As for user registration, you'd have to clone the Add User page to make a 
Registration page, but that should be pretty easy too.

Other than that, I think it has everything you listed.  You'd have to rip out 
the job tracking stuff, but frankly, you could just remove the links and leave 
the code.  There is also extensive documentation to help you get started with 
your customizations.

Have fun.

cheers,

Travis

bruce wrote:
hey

doing some basic research... has anyone found a seriously good user
management script (preferably free) that can be incorporated within a web
application.
i'm looking for something that allows for the following functions:
 - user registration/login
 - admin function
 - group/team definition
 - email verification
 - database driven (mysql/postgres)
 - ability to grant user multiple rights/access levels
 - ability to check/deny by IP Address
 - session based function
 - page security
 - linux/apache/php
we've seen a few, but nothing that really grabs us we're considering
taking something like phpbb/gforge and just ripping the login/admin function
out, although we'd prefer another approach but if we have to rip the
functionality out of another app, has anybody seen an app (open source/free)
that has a serious login/admin/user management function that we should look
at...
thanks

bruce
[EMAIL PROTECTED]
--
Travis Low
mailto:[EMAIL PROTECTED]
http://www.dawnstar.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Select from 24 tables

2004-05-01 Thread Michal Migurski
 Up what creek?  You didn't really provide any technical justification
 for your suggestion.

Up the creek of having to call for help on php-general because you have 24
identical tables you need to join, having never performed a join before.

 The pain only occurs when writing the SQL statements to join the
 tables.  I don't think it's a good idea to optimize the database schema
 for the sake of the programmer, who only has to write the SQL one time.

I wholeheartedly disagree. :) I think that optimizing for the sake of the
programmer, the bug fixer, and the possible inheritor of the project is a
/great/ idea. Servers keep getting faster, while the human attention span
and rate of familiarization with code stays approximately constant, so
optimizing your development time is at least as sensible as optimizing SQL
select performance, which is probably better handled through well-chosen
indexes anyway.

Optimizing for the programmer usually translates into thinking about the
humans who will need to interpret your code, and making it easy to pick up
the gist of your intent. A 24-table join is not a typical characteristic
of what I'd consider a well-planned DB schema, whose meaning can be
quickly grokked by a newcomer to the project.

If all those 24 tables store the same kind of data, then there's no reason
to split them up. Of course, we haven't seen the specific usage of those
tables in this thread, but I'm basing my posts on the assumption that it's
better for the OP to have a marbles table with a color  column, than
tables named red_marbles, blue_marbles, 'green_marbles,  etc. If
that's not the kind of data we're talking about, then I stand corrected,
and John Nichel's initial response is all that's needed.

A huge table count is often evidence of a need for some refactoring.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Php MySql selection question

2004-05-01 Thread Curt Zirzow
* Thus wrote Dave Carrera ([EMAIL PROTECTED]):
 Hi List,
 
 I am trying to make a search box for my site and I ask the list how can I
 search 24 tables to find a search string posted by a form.

oohh.. ouch ;)

 
 I get Column: 'listing' in where clause is ambiguous when I run 
 
 $sql = mysql_query(select * from $tbs where listing like
 \$_POST[tglstring]\) or die(mysql_error());
   
 $tbs is a string containing 24 table names (1 for each letter of the
 alphabet).

You cant search tables like that and get back what your expecting.
If you have two tables say:

  create table t1 {
id int,
name  varchar(50)
  )
  create table t2 {
id int,
name  varchar(50)
  )


If you select from both of those tables like:
  select * from t1, t2

The field list returned from mysql will be:
  id, name, id, name

And If you add a condition to the sql statement:
  select * from t1, t2 where name like 'foo%'

Mysql complains about ambiguous column, because It has no idea from
which table you want 'name' to be like. And even if you did tell it
what tables too look at:

  select * from t1, t2 where t1.name like 'foo%' or t2.name like
  'foo%'

Your data is going to be all messed up anyway. You can use a UNION
statment to fix this problem or restructure your data so you dont
have this problem, the later being prefered method.

You should get on the mysql mailing list. I think i've already said
to much about mysql.

Curt.
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] Select from 24 tables

2004-05-01 Thread Travis Low
Hi Michal,

Getting back to the original posting, I'm basically saying that I don't think 
it's a good idea to structure or restructure a database for the sake of 
simplifying a few SQL statements.  Especially if the data being joined is in 
separate tables for a good reason.

Regarding optimizing for programmer/bug-fixer/etc, after thinking about it, I 
realized that what constitutes optimization really depends a lot on your 
development situation, so I'll refrain from further comments on that.  I 
probably shouldn't have brought it up, sorry.

cheers,

Travis

Michal Migurski wrote:
Up what creek?  You didn't really provide any technical justification
for your suggestion.


Up the creek of having to call for help on php-general because you have 24
identical tables you need to join, having never performed a join before.

The pain only occurs when writing the SQL statements to join the
tables.  I don't think it's a good idea to optimize the database schema
for the sake of the programmer, who only has to write the SQL one time.


I wholeheartedly disagree. :) I think that optimizing for the sake of the
programmer, the bug fixer, and the possible inheritor of the project is a
/great/ idea. Servers keep getting faster, while the human attention span
and rate of familiarization with code stays approximately constant, so
optimizing your development time is at least as sensible as optimizing SQL
select performance, which is probably better handled through well-chosen
indexes anyway.
Optimizing for the programmer usually translates into thinking about the
humans who will need to interpret your code, and making it easy to pick up
the gist of your intent. A 24-table join is not a typical characteristic
of what I'd consider a well-planned DB schema, whose meaning can be
quickly grokked by a newcomer to the project.
If all those 24 tables store the same kind of data, then there's no reason
to split them up. Of course, we haven't seen the specific usage of those
tables in this thread, but I'm basing my posts on the assumption that it's
better for the OP to have a marbles table with a color  column, than
tables named red_marbles, blue_marbles, 'green_marbles,  etc. If
that's not the kind of data we're talking about, then I stand corrected,
and John Nichel's initial response is all that's needed.
A huge table count is often evidence of a need for some refactoring.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html



--
Travis Low
mailto:[EMAIL PROTECTED]
http://www.dawnstar.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Select from 24 tables

2004-05-01 Thread Curt Zirzow
* Thus wrote Travis Low ([EMAIL PROTECTED]):
 Hi Michal,
 
 Getting back to the original posting, I'm basically saying that I don't 
 think it's a good idea to structure or restructure a database for the sake 
 of simplifying a few SQL statements.  Especially if the data being joined 
 is in separate tables for a good reason.

The problem is that we're not talking about normalization in this
case. The OT post is using 24 tables for each letter of the
alphabet (Dont ask me how that number was derived.) So each table
represents the same exact scructure.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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