php-general Digest 1 May 2004 22:23:15 -0000 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]


----------------------------------------------------------------------
--- Begin Message ---
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 ---
--- Begin Message ---
"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 ---
--- Begin Message --- 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 ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message --- 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
--- End Message ---
--- Begin Message ---
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
 

--- End Message ---
--- Begin Message ---
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
 

--- End Message ---
--- Begin Message --- 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
--- End Message ---
--- Begin Message ---



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]                                             
             om>                                                        To 
                                       <[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

--- End Message ---
--- Begin Message ---
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?
>
> /\/\ \/\/

--- End Message ---
--- Begin Message ---
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?

--- End Message ---
--- Begin Message ---
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
 

--- End Message ---
--- Begin Message --- hello,

how can i set |XSLT_SABOPT_DISABLE_ADDING_META option to true ?

Fabrice
|

--- End Message ---
--- Begin Message --- hello,

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

Regards,
Fabrice
|

--- End Message ---
--- Begin Message ---
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
 

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message --- 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

--- End Message ---
--- Begin Message --- 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
--- End Message ---
--- Begin Message --- 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

--- End Message ---
--- Begin Message --- 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>

--- End Message ---

Reply via email to