[PHP] Re: problems setting up php5 on apache2 (WinXP Pro)

2004-09-10 Thread Richard Harb
I have no experience with PHP5 so far but this subject was asked
before often enough with PHP4 - so the advice should still be valid...

I generally didn't put any files in the %SYSTEMROOT% folder (which
usually translates to C:\WINDOWS on a default installed WinXP machine)
but instead I put the php.ini and php4ts.dll into the apache
respectively apache2/bin folder and modified the php.ini to point to
the dlls. works like a charm for me.

With all the stuff related to the local webserver put into
'c:\webroot' those entries in php.ini are:

include_path = ".;c:\webroot\php4\dlls\;c:\webroot\php4\pear"
extension_dir = "c:\webroot\php4\extensions"

... you get the idea.

HTH
Richard



On Fri, 10 Sep 2004 09:31:43 -0400, [EMAIL PROTECTED] (Mathieu
Dumoulin) wrote:

>(Don't write to me telling me to use linux, i dont want to, this is my home
>machine not a production server, thank you, now if you really want to help
>keep on reading)
>
>I got a most recent copy of PHP 5.01 extracted into "C:\php" and everything
>seems to be working fine as long as i dont ask to load extensions. Any
>extension that i try to add will fail to load and i'm clueless.
>
>At first in the PHP.ini file this was the original directive:
>
>; Directory in which the loadable extensions (modules) reside.
>extension_dir = "./"
>
>And it would not work so i changed it to a hardcoded path
>
>; Directory in which the loadable extensions (modules) reside.
>extension_dir = "C:\php\ext"
>
>Still no extensions wont load. Whats the weirdest, all the DLLs are at the
>correct location, apache reports: "PHP startup: Unable to load dynamic
>library 'C:\php\ext\php_mysql.dll' - The specified module could not be
>found."
>
>but it IS there, at the exact location, i even looked and compared both
>paths manually letter by letter. Another weird thing to note is that some
>extensions DO load while some don't, here is a list of the extensions that
>i'm loading and which one fails (Note ALL extensions DLL are indeed in the
>folder intended, they just dont load)
>
>extension=php_bz2.dll
>extension=php_gd2.dll
>extension=php_imap.dll
>extension=php_mysql.dll <<< fails but it's vital to me
>
>these extensions are activated, only mysql fails, but there are other i
>wanted earlier lemme see which ones: (These would be nice to have, i'll tell
>you which one fails too)
>
>;extension=php_exif.dll <<< fails
>;extension=php_ldap.dll <<< fails (The file really isnt there so it's not a
>real problem)
>;extension=php_openssl.dll <<< fails
>;extension=php_pdf.dll
>;extension=php_pgsql.dll
>;extension=php_snmp.dll
>;extension=php_sockets.dll
>;extension=php_tidy.dll
>;extension=php_zip.dll
>
>All of these will load... S I'm stuck there, i need help, tell me if you
>need to know anything else. i'll be glad to give you info, i want to set
>this up to further my PHP developement at home. We intensively use PHP4 at
>work but i wanted to start working on PHP5 to see how good it is.
>
>Till then
>See ya'll
>TheInsaneCoder

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



Re: [PHP] string function that adds before and after

2004-06-25 Thread Richard Harb
-Original Message-
From: Gabe
Sent: Friday, June 25, 2004, 9:06:15 PM
> Philip Olson wrote:

>There's a number of functions in PHP that will give me the position of
>the *first* instance of the matched string, but it doesn't look like the
>function would keep searching after the first match.  Anyway, am I
>overlooking a function that already has the functionality that I'm
>searching for?  Or does anyone have any ideas how I can accomplish this
>efficiently since my search strings can be quite long?


try this

preg_replace('/(weather)/i', "$1", 'This is the worst
weather ever.  Weather around
here is terrible. ')
>>>
>>>Thanks Matt.  I think that will do the trick.  Let me see if I 
>>>understand it correctly.  the "i" will make the search case-INsensitive,
>>>and the parenthesis around "weather" will store what it finds in the
>>>variable $1?  Is that right?
>> 
>> 
>> Also consider str_replace() as it's faster albeit case
>> sensitive.  str_ireplace() exists in PHP 5.  Just another
>> option, I'm surprised you didn't find it when looking
>> around strpos() and friends.
>> 
>> Your assumptions above are correct, sorry Matt for stepping
>> in! :)  I prefer cold weather.
>> 
>> Regards,
>> Philip

> Thanks Philip.  I did notice str_replace() but it didn't look like I
> could use it without it actually replacing what it found instead of just
> adding strings before and after it.  Am I wrong?

I'd say it will do the job just fine if case sensitivity is not an
issue:

$word = 'weather';
$new = str_replace($word, "$word", $phrase);

... speaks for itself ;)

/rh

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



Re: [PHP] TIFF display problem...

2004-06-24 Thread Richard Harb
Argh, I see your problem was already solved (answers haven't been
listed as one thread, so I missed em). Oh well.

-Original Message-
Sent: Thursday, June 24, 2004, 11:58:15 AM
> Are you certain there are no other characters being sent (introduced
> by the addition) in the 'body' beside the image?

> Will you get any output (characters and all) if you request the image
> file directly - without embedding it into a page using  whatever?

> While I have used only the "supported by default" images like jpg, png
> and the like, that always turned out to be the problem for me ...

> Richard

> -Original Message-
> Sent: Monday, June 21, 2004, 9:43:19 PM
>> Hi All,

>>  I've run into a jam..  I have the follow PHP script:

>> >  header("Content-type: image/tiff");

>>  $_GET['id'] = str_replace( ".", "", $_GET['id'] );
>>  $_GET['id'] = str_replace( "/", "", $_GET['id'] );

>>  $blah = "/usr/local/apache/chm-images/" . $_GET['id'] . ".A";

>>  readfile( $blah );
?>>>

>> This works just fine...

>> When I add...

>>  session_start();

>>  if ( !$_SESSION['user_id'] )
>>  {
>>  exit();
>>  }

>> ...to it, the image does not display.

>> What I need to do is read in images from a secured directory and display it
>> on the page.  I was using JPGs before and now need to display TIFF files.
>> We have the plugins for IE all setup.  Could someone tell me how I could fix
>> this?  I'm at a complete loss...

>> -Dan Joseph

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



Re: [PHP] TIFF display problem...

2004-06-24 Thread Richard Harb
Are you certain there are no other characters being sent (introduced
by the addition) in the 'body' beside the image?

Will you get any output (characters and all) if you request the image
file directly - without embedding it into a page using  Hi All,

>   I've run into a jam..  I have the follow PHP script:

>header("Content-type: image/tiff");

>   $_GET['id'] = str_replace( ".", "", $_GET['id'] );
>   $_GET['id'] = str_replace( "/", "", $_GET['id'] );

>   $blah = "/usr/local/apache/chm-images/" . $_GET['id'] . ".A";

>   readfile( $blah );
?>>

> This works just fine...

> When I add...

>   session_start();

>   if ( !$_SESSION['user_id'] )
>   {
>   exit();
>   }

> ...to it, the image does not display.

> What I need to do is read in images from a secured directory and display it
> on the page.  I was using JPGs before and now need to display TIFF files.
> We have the plugins for IE all setup.  Could someone tell me how I could fix
> this?  I'm at a complete loss...

> -Dan Joseph

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



Re: [PHP] imagecolortransparent & IE

2004-06-16 Thread Richard Harb
That's sort of a known issue with our oh so standards compliant
favourite browser...

Search google for
   ie png transparency

and though shall be enlighted.
Richard

-Original Message-
> Hi, I have been working to create a program that takes a user-uploaded
> background image, a little alpha blending, some data, and a pinch of
> fairy dust, and outputs a nice image.  I have had trouble with the image
> displaying properly in Internet Explorer.  An example:

> http://ffxi.nerdlife.net/ffxi.php?id=1

> If you open it in any non-IE browser, it looks fine, but if you open it
> in IE, the gray background is not made transparent.

> My question is, how can I fix this, and if I can't, is there any 
> alternative for making a transparent background.  Here's my code snipplet:

>   $color = ImageColorAt($im, 1, 1);
>   imagecolortransparent($im, $color);

> Also, I output the file as a png file, but I don't care what it is 
> output as (although my server for some reason doesn't recognize 
> ImageGif...):

>   header("Content-Type: image/png");
>   Imagepng($im);

> Any advice?

> Thanks,
> Brian

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



Re: [PHP] Limit the number of characters in a string

2004-06-12 Thread Richard Harb
actually it is:
substr($string, 0, 100);

http://www.php.net/substr

-Original Message-
From: php-general
Sent: Friday, June 11, 2004, 3:17:15 PM
> substr( xxx, 1, 100)

>>>
>>>Hi
>>>
>>>Anyone know how to clip the number of characters in a string? For instance,
>>>I have a string carrying a long piece of text, say, of 200 characters, but I
>>>want to reduce this to just the first 100 characters.
>>>
>>>
>>>Thanks in advance.
>>>
>>>Russell

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



Re: [PHP] Re: search engine optimization and php

2004-06-08 Thread Richard Harb
http://www.w3.org/TR/html401/struct/global.html#h-7.4.4

-Original Message-
From: electroteque
Sent: Tuesday, June 8, 2004, 11:58:30 PM
> On the topic of meta tags, can these be sent via the header or not ?? :\

>> -Original Message-
>> From: Manuel Lemos [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, June 09, 2004 2:02 AM
>> To: [EMAIL PROTECTED]
>> Subject: Re: [PHP] Re: search engine optimization and php
>>
>>
>> Hello,
>>
>> On 06/08/2004 12:04 PM, Aaron Wolski wrote:
>> >>>Just curious as to how people handle search engine optimization when
>> >>
>> >>most of
>> >>
>> >>>the page content is dynically built from the db.  Doesn't the bots
>> >
>> > need
>> >
>> >>to
>> >>
>> >>>crawl the static pages and match your keywords to actual words in
>> >
>> > the
>> >
>> >>file?
>> >>
>> >>Practically, only Google matters these days as most sites get over 70%
>> >>of leads from Google.
>> >
>> >
>> > Since Yahoo! Dropped their affiliation with Google, many, including
>> > myself and my client, have seen a significant increase in Y! refers. 70%
>> > is not the case anymore.
>> >
>> > Keeping all your eggs in one basket is a bad decision at best.
>>
>> Yes, but if you just keep optimizing for Google you will be optimizing
>> for most of the others that have significant share because Google always
>> been the most successful in providing relevant results for the users and
>>   others tend to imitate Google.
>>
>>
>> >>For Google, it matters that your pages are served as fast as possible.
>> >>If your pages are taking too long to be served, Google assumes it is
>> >>causing too much load to your site and slows down giving more time
>> >>between crawls.
>> >>
>> >>There is a myth regarding the interpretation of this explanation for
>> >>Google not indexing dynamic as many site pages because of the use of
>> >
>> > URL
>> >
>> >>with query parameters (?some=thing&this=too).
>> >>
>> >>http://www.google.com/webmasters/2.html#A1
>> >>
>> >>Query parameters is is not the reason why Google does not index so
>> >
>> > many
>> >
>> >>pages. I can demonstrate that just by let you see that Google indexes
>> >>for 700.000 pages of php.net, many of which have many query
>> >
>> > parameters:
>> >
>> >>http://www.google.com/search?q=site%3Aphp.net
>> >>
>> >>So, do not bother with all those bogus advices telling you to use URL
>> >>rewriting because that is not what matters. What matters is that your
>> >>pages are served as fast as possible cause as less load to your server
>> >>as possible.
>> >
>> >
>> > Speed is a factor, page size is a factor but the number of query strings
>> > within a URL is why Google (and other bots) only go so deep into a site
>> > 0 for fear of getting caught in a endless loop.
>> >
>> > They are getting better, however.
>> >
>> > It's definitely not bogus information. I can get a site's pages indexed
>> > a lot quicker with URL rewriting than I can without.
>>
>> My point is that if your pages are served slowly, URL rewriting does not
>> matter and only a subset of your pages will be indexed. OTOH, if you
>> make your pages be served very fast, URL rewriting is not necessary, at
>> least for Google. I know that for experience. I have seen it several
>> times Google crawling thousands of pages with no URL rewriting.
>>
>> As for other search engines, I don't know because it is possible that
>> they try to copy Google crawling logic the way they understand it, which
>> may not be the actual way it works as Google does not disclose it .
>>
>>
>> --
>>
>> Regards,
>> Manuel Lemos
>>
>> PHP Classes - Free ready to use OOP components written in PHP
>> http://www.phpclasses.org/
>>
>> PHP Reviews - Reviews of PHP books and other products
>> http://www.phpclasses.org/reviews/
>>
>> Metastorage - Data object relational mapping layer generator
>> http://www.meta-language.net/metastorage.html
>>
>> --
>> 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] dynamic table

2004-05-26 Thread Richard Harb
$i = 0;
while ($myrow = mysql_fetch_array($sql)) {
  if (++$i % 5 == 0) echo '';
  ...

  
Note: if used repeatedly do not increment the $i again in the loop.

HTH
Richard


-Original Message-
From: nabil
Sent: Wednesday, May 26, 2004, 2:28:28 PM
> Hiya,

> How can i draw a new  AFTER FIVE   in the following loop

> (i want to echo the records in 5 columns width tables whatever the number of
> records will be fetched)

> ..
> echo '';

> while ($myrow = mysql_fetch_array($sql))
> {
> echo $myrow[0];
> }
> echo '';


> regards

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



Re: [PHP] export mysql to excel

2004-05-13 Thread Richard Harb
You could get yourself the mySQL ODBC driver and 'Get External Data'
in Excel ...

Richard

-Original Message-
From: CurlyBraces Technologies ( Pvt ) Ltd
Sent: Friday, May 14, 2004, 7:18:17 AM
> hi , 

> i want to export data in mysql to excel . but problem is mysql runs in the linux 
> machine ,
> How can i get that data from mysql-Linux machine  to
> windows-Excel machine , plz help asap

> thanx in advance
> curlys

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



Re: [PHP] Does this "directory detection" script work for you?

2004-05-09 Thread Richard Harb
Hello,

I see one potential problem with this detection in one special case.

This will only occur if you use Apache's feature PATH_INFO.

There $current_page will be inaccurate as the scriptname might
be /index.php but the URL could be /index.php/path/to/mypage or just
/index/path/to/mypage - depending on Apache's configuration and link
presentation.

I mention this because I have used this extensively to work around
having to rely on mod_rewrite.

Richard


-Original Message-
From: John W. Holmes
Sent: Monday, May 10, 2004, 2:21:36 AM
> Hello. I'm relying on the following code so that a script can 
> automatically detect where it's installed and create paths and URLs from
> the information. This way absolute paths and URLs are always used.

> I've had a couple people report that the script wasn't finding the paths
> correctly, though, so I'm asking if people could test this out on their
> server and see if it detects the paths or not.

>   //Install path (path to survey.class.php)
>  $path = dirname($_SERVER['PATH_TRANSLATED']);

>  //Determine protocol of web pages
>  if(isset($_SERVER['HTTPS']) && 
> strcasecmp($_SERVER['HTTPS'],'ON') == 0)
>  { $protocol = 'https://'; }
>  else
>  { $protocol = 'http://'; }

>  //HTML address of this program
>  $dir_name = dirname($_SERVER['SCRIPT_NAME']);
>  if($dir_name == '\\')
>  { $dir_name = ''; }

>  $html = $protocol . $_SERVER['SERVER_NAME'] . $dir_name;

>  //Determine web address of current page
>  $current_page = $protocol . $_SERVER['SERVER_NAME'] . 
> $_SERVER['SCRIPT_NAME'];

>  echo "Path to script: $path";
>  echo "URL to script directory: $html";
>  echo "URL to current script: $current_page";
?>>

> It should print out the file system path to where the script was placed
> as well as a URL to the directory it was placed and a URL to the file
> itself.

> I've never had an issue with it personally and I've tested it on Apache
> and IIS on both Windows and Linux. So maybe it's some obscure CGI or OS
> configuration where this isn't working? I just need to know so I can
> plan accordingly.

> The only two substitutions that can be made (that I know of) are:

> $_SERVER['SCRIPT_NAME'] => $_SERVER['PHP_SELF']
> and
> $_SERVER['PATH_TRANSLATED'] => $_SERVER['SCRIPT_FILENAME']

> If it doesn't work for you, does it work if you do one of those 
> substitutions?

> Also, this will test if the script is in subdirectories or not, also, so
> testing it within one and seeing if that works, too, is appreciated.

> Thanks for any help and time you're willing to provide.

> -- 
> ---John Holmes...



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



Re: [PHP] $myobject->$$varname doens't work ??

2004-05-09 Thread Richard Harb
Try
echo $obj->$varname;


-Original Message-
From: greg
Sent: Sunday, May 9, 2004, 9:21:52 AM
> Hello,

> I was just trying this but it doesn't work :
>  class a {
>public $foo = "hello world";
> }

> $obj = new a();
> $varname = "foo";
echo $obj->>$$varname;

> $bar = "this is working";
> $varname = "bar";
> echo $$varname; // display "this is working" as expected
?>>

> Is it a bug or is it normal ?
> I didn't find anything about it in documentation (php4 / php5).

> Greg

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



Re: [PHP] using cookies

2004-05-09 Thread Richard Harb
-Original Message-
From: David T-G
Sent: Sunday, May 9, 2004, 6:09:06 AM
> Hi, all --

> I guess I need a primer on cookie usage.  I've read the manual regarding
> setcookie and have gone back to look at everything having to do with
> cookies on this list in the past few months (it seems that I'm not the
> only one with some troubles, but most of them appear to have been having
> sent some HTML output before trying to set a cookie).

> I want to check to see if the user has my cookie to then log him in
> automatically, and if he doesn't then I show the login screen and he logs
> in and then I set the cookie if the box is checked.

> Of course, $_COOKIE is set, so I have to check for my cookie name.  Even
> something as simple as

>   $_COOKIE['test'] = 'tested';

Under normal circumstances you don't need to do that (unless you know
what you are doing - but it will not set a cookie on the client side,
it only modifies your superglobal variable for as long as the script
runs. I guess I'm once again stating the obvious).


> followed by a load of the page and a print doesn't show it.

> Do I only call setcookie if the cookie isn't set, or do i call it every
> time I load the page to initialize it?  Once I set it, how do I read it?

Once you setcookie() you can optionally give it something on its way:
like name, value, expire time/date, etc.

You could for example set a cookie to expire in half an hour - i.e.
for a session. It might make sense to refresh that cookie on every
page request, so that a session timeout will be postponed on each
refresh.

If you omit the expire time, it will be valid until the end of the
session (browser closes) - see the docs.


How do you get your cookie back?

If your visitor has a browser that allows cookies and you already sent
him one (or more) before, he will automatically transmit it to you as
part of the HTTP request headers. PHP does its magic and places the
values received into that Superglobal $_COOKIE (as well as $_REQUEST)
for you to play with...

So, if that array is empty that could mean two things:
1) you didn't send any cookie before (either because you already sent
your headers and thus have a f***up in your code or because the
visitor hasn't been to your page before)
2) the visitor does not allow cookies - too bad.


I guess that's all there is to it. Someone correct me or add to that
:)


> Does anyone have any pointers to a basic tutorial?

I didn't use any other page except the obvious one ...
http://www.php.net/manual/en/function.setcookie.php

I hope that answers at least part of what you were looking for ...

Richard

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



Re: [PHP] Re: Active PHP Sessions

2004-05-07 Thread Richard Harb
Friday, May 7, 2004, 3:40:06 PM, thus was written:
> I've read stuff like that also.  However, if I choose to do this, I must
> write all the session handling myself, correct?

Well, yes and no:
You could still use the default session handler and just add a
function/whatever to the top of the page that updates the database,
reads the number of sessions and on occasion makes a garbage
collection:

You could for eaxmple use a simple table with two columns:
session_id, last_access

if ( there is a valid session )
   update last access of this session_id in the table
   // if mySQL you could use a REPLACE INTO
   count number of sessions
 WHERE last_access < timespan counting as active session
   // have some basic form of garbage collection
   if ( rand (1, n) == 1 ) delete from session
  WHERE last_access > session timeout

I think that might work... (at least it's an outline of how I did it.)

Two/three (depending on the database) DB queries and on occasion
three/four .. not too much overhead, considering you would have to
read the whole session directory if you chose to check the files...

my 2c
Richard



>>From: "Torsten Roehr" <[EMAIL PROTECTED]>
>>To: [EMAIL PROTECTED]
>>Subject: [PHP] Re: Active PHP Sessions
>>Date: Fri, 7 May 2004 15:30:29 +0200
>>
>>"Paul Higgins" <[EMAIL PROTECTED]> wrote in message
>>news:[EMAIL PROTECTED]
>> > Hi all,
>> >
>> > I'm on a shared server, and I do not believe that I have access to the
>>/tmp
>> > directory where the session files are stored (I believe that is how it
>>works
>> > :).  I want to keep track of which sessions are active.  Basically, I
>>just
>> > want a list of the active sessions for my site.
>> >
>> > How can I do this?
>>
>>If you use a database as container for your session data you could easily
>>do
>>a SELECT COUNT(*) FROM sessions to get the number of the sessions. Using a
>>DB as session container is also more secure on a shared server (at least
>>that's what I often read about session security).
>>
>>Regards, Torsten

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



Re: [PHP] A work around my HTTP_REFERER Prob...

2004-05-07 Thread Richard Harb
What about allowing your UK server to access the database of your USA
Server? You could open a port to that specific IP address only, ...

Then authenticating users on the UK server would work like a charm.
You could even create a 'shared' database for basic session
information.

I think if sessions are used the overhead would not be overly serious
except for the one time a user has to log in.

Ok, I have no idea whatsoever about how to access a Domino Server, but
there just has to be a way... XMLRPC?

just a thought ...
Richard


Friday, May 7, 2004, 11:39:12 AM, thus was written:
> To recap...
> We have two servers:
> 1. USA - holds most of our databases, and E-mail. but specifically, the
> usernames and passwords, or all our users (Lotus Domino Server)
> 2. UK - Runs our website. (Unix Server)

> We wanted to be able to allow people to login on on server 1, and getr
> authenticated etc, and then get redirected to server 2.
> Using http_referer we would confirm that they came from server 1

> However, as I discovered, that is not possible.
> So what we did was this:

> On the login form on server 1, the referering URL to server 2, contains a
> varibale called 'secure'
> we asign that variable that value of '4654376534' and divide it by the day
> (eg: if it's the 12th of may, we divide by 12.. 7th of June, we divide by
> 7)
> I know that this is crackable, but it's just a stop gap measure...

> My problem today is this:
> It's not confirming the values?
> See my code below
> 
> session_start();
> $today_day = date("d");
> $code1 = ($today_day+1) * $secure;
> $code2 = $today_day * $secure;
> $code3 = ($today_day-1) * $secure;
> $master_code = 4654376534;
> if (($code1 == $master_code) || ($code2 == $master_code) || ($code3 ==
> $master_code)) {
> $_SESSION[logged] = 'true';
> $login_info = "You are now Logged in";
> } else if ($_SESSION[logged] == 'true') {
> $login_info = "You are still Logged in";
> }
> =

> I start by getting the date $today_day
> As we're in two time zones, I don't wanna get caught out by the time
> difference, so I've created a +/- 1 each side ($code1-3)
> and fianlly, asigned the master input variable (the decoder)

> Now it all works great..! (all variables echo what they should) however,
> I'm not getting logged in?
> I'm really stumped...
> any ideas?

> Tris...

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



Re: [PHP] Showing only part of string

2004-05-07 Thread Richard Harb
I guess the easiest way to do this would be to use a regular
expression:

if (preg_match("/(.*)<\/title>/i", $string, $m)) {
$found = $m[1];
}
echo $found;

Richard


Friday, May 7, 2004, 12:11:02 PM, thus was written:
> Hi List,

> $string = "This is a test string to SHOW ONLY THIS BIT of the
> string";

> I have tried strpos, str_replace and other string manipulation things but I
> cant get my head around how to achieve showing the text with the
>  tags of the string.

> Any help is appreciated and I thank you in advance for any help given.

> Thank you

> Dave Carrera

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



Re: [PHP] Class Help Extended

2004-05-05 Thread Richard Harb
More often than not it's a good thing to assign 'default' values to
class variables like that.

In this case though I've observed that common practice is to get the
user/pass values from a config file and pass them along as variables
when creating an instance of the class.

Classes are most beneficial if you can take your class include file
from one project to the next and just pass along different parameters
and they work. Including user/pass would force you to edit/change
those values on every project you use that class in.

HTH
Richard


Thursday, May 6, 2004, 7:56:01 AM, thus was written:
> First off thanks Curt for the attempt at explaining what the purpose was for
> those, I'm convinced enough to start doing that since that's what the "pros"
> use. :)

> However, I know have another concern. As for as class security. Is it wrong
> to initialize the static variables for my database assignment class ie..

> [..Example..]

>  class db_connection {
>   var $user = "dbuser";
>   var $pass = "dbpass";
>   var $db = "db";
>   var $host = "localhost";
>   var $connection;
?>>

> [../Example..]


> or should I still be using the normal seperate file for those values ie...

> [..Example2..]

>  include_once("dbconn.php");
> class db_connection {
>   var $user;
>   var $pass;
>   var $db;
>   var $host;
>   var $connection;

...?>>

> [../Example..]

> Where in the included file I have the variables listed as
> $user = username;
> $pass = password;
> etc.

> The Class files that I am creating are going to be seperate "template"
> includes if you will where they also are going to be "include_once()" items
> aswell. Is it over redundant to have both of the files includes?

> Any help is much appreciated as I'm still learning this exciting language!
> :)
> TIA,
> Wolf

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



Re: [PHP] Looking for Advanced PHP Developers

2004-05-05 Thread Richard Harb
... and onsite would be where ?

Thursday, May 6, 2004, 2:03:04 AM, thus was written:
> Hello,
>   I'm looking for advanced PHP Developers. the responsibilites will 
> include the following:

> - Being able to architecture huge web applications ( 1 Million lines of
> code or bigger)
> - Ability to advise on how to control huge projects and help writing
> guidlines( CVS usage, documentation, coding styles.. etc)
> - Good RDBMS skills.
> - Strong PHP knowledge
> - OOP & design patterns methodolgies are a big plus.

> Full Time Job. Onsite. no contractors, online workers please.

> Also Senior Developers with 3+ years experience can apply. We'll send
> good offers to people who will be accepted, the offer includes housing.

> Please send your CVs to [EMAIL PROTECTED]

> Ammar Ibrahim
> CTO
> GNUIX

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



Re: [PHP] sessions failing to persist

2004-05-02 Thread Richard Harb
If the sample of code is the whole page... where do you actually start
your session?

I didn't see a session_start() anywhere.

AFAIK the $_SESSION var doesn't exist until you do just that.

session_is_registered(): mabe I'm reading the documentation wrong, but
I interpret this function as checking whether there is the global var
(in this case $stage) ... and since register_globals is off there
shouldn't be such a var automatically any more.

..

In the user comments there's a good example of how to handle sessions.

http://www.php.net/session_is_registered#26464

hth
Richard


Monday, May 3, 2004, 6:40:18 AM, thus was written:

> As I posted last week, I seem unable to have sessions persist.  I
> have ruled out https as a problem, the following simple script,
> installed as xxx.php will generate a new session number every time
> the field is filled in and "Submit" is hit.

> Note that I am not using cookies, the relevant session variables are:
>Session Support  enabled
>session.auto_start   On
>session.use_cookies  Off
>session.use_trans_sidOn

> When run, the session file appears to contain stage=1 but never is being
> read.

> I suspect I'm missing something obvious, any pointers?

> /\/\ \/\/

>  if (!session_is_registered("stage")) {
>$_SESSION["stage"] = 0;
>$_POST['field'] = "";
>session_register("stage");
>}
?>>
>  PHP Test page
> 
>echo "Stage:"; echo $_SESSION["stage"];
>   echo " SessionID: "; echo  session_id();
>   $_SESSION["stage"] = 1;
?>>
>
>value="">
>   
>
>echo "Stage:"; echo $_SESSION["stage"];
?>>

>  

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



Re: [PHP] Installing sendmail in win9X/Me

2004-04-30 Thread Richard Harb
Google: searched for "windows mail server"
came up with http://www.pmail.com/ as first link.

Incidentially I know this program ... easy to set up and use.

hth



Friday, April 30, 2004, 7:05:53 PM, thus was written:
> Hi,

> My english is very poor.

> I need install sendmail in windows 9X/Me for use mail() command.

> PHP work only in localhost which active site server (similar to apache)
> and send mail by proxy network.

> Please, help.

> Thanks,
> Kemper

> 
> -
> Helmut Kemper
> [EMAIL PROTECTED]
> Celular: 55 81 99268744


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

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



Re: [PHP] Register globals off, still not secure?

2004-04-30 Thread Richard Harb
Friday, April 30, 2004, 5:37:15 PM, thus was written:
> Hi, Even with register globals off isn't it possible to have a webpage
> like this:

Not sure what you are asking. You can have a webpage like this. And I
guess it even does what it should - print the information.

> 
> 
> 

> Hello, 
> I know your password is 

> 
> 
> 


> Is there a way to make sure apache doesn't set the $SERVER['PHP_AUTH_PW
> '] global?

No, there is no way. The docs state that those Superglobals are always
set.
But I wouldn't necessarily say that this is insecure: A user does not
have access to those superglobals, except he managed to sneak in some
code onto your server - but then you'd have a problem somewhere else.

register_globals was intended as a shortcut for lazy programming (my
biased opinion only!) to automagically have $PHP_AUTH_PW, etc
available. That way some user would have been able to set this
variable easily, e.g. with a GET request. No way to directly set a
superglobal though by conventional means.

Richard

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



Re: [PHP] PHP & Apache Version

2004-04-30 Thread Richard Harb
Friday, April 30, 2004, 3:21:41 PM, thus was written:

> Is there a version of Apache 2+ that now works with PHP?


Yes there is. Works without problems.

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



Re: [PHP] re-keying an array

2004-04-30 Thread Richard Harb
Uh, I was wrong...

Foreach evaluates only once at initialisation... You can even unset
the array once into the loop and it still works perfectly well (not
that I recommend this as good practice or whatever, just did some
checking to be sure :)

Richard


Friday, April 30, 2004, 9:55:14 AM, thus was written:
> * Thus wrote Mattias Thorslund ([EMAIL PROTECTED]):
>> Just a quick follow-up question on that:
>> 
>> Curt Zirzow wrote:
>> 
>> >foreach(array_slice($filenames, 0, 2) as $filename) {
>> > $files[] = "path/to/" . $filelname;
>> >}
>> > 
>> >
>> 
>> Will a function (such as the array_slice here) in a foreach statement
>> get re-evaluated for each iteration, or is it evaluated just once?

> Only once.

>> 
>> In other words, is there anyhing gained by doing:
>> 
>> $short_array = array_slice($filenames, 0, 2);
>> 
>> foreach($short_array as $filename) {
>>  $files[] = "path/to/" . $filelname;
>> }

> Nothing really except mabey that it might be a little readable.


> 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] re-keying an array

2004-04-30 Thread Richard Harb
Yes and no (in this case).

Yes, it'll be evaluated in each iteration and no, I don't think you'd
gain that much in this case because the evaluation would only take
place twice. Though I don't know how expensive array_slice vs.
creation of another variable and assigning a value to it is 

But if you'd operate on large arrays it might make sense pulling the
eval out of the loop.

At least that's what I read in a tuning related article on zend.com

Richard


Friday, April 30, 2004, 8:37:10 AM, thus was written:
> Just a quick follow-up question on that:

> Curt Zirzow wrote:

>>foreach(array_slice($filenames, 0, 2) as $filename) {
>>  $files[] = "path/to/" . $filelname;
>>}
>>  
>>

> Will a function (such as the array_slice here) in a foreach statement
> get re-evaluated for each iteration, or is it evaluated just once?

> In other words, is there anyhing gained by doing:

> $short_array = array_slice($filenames, 0, 2);

> foreach($short_array as $filename) {
>   $files[] = "path/to/" . $filelname;
> }


> /Mattias
  

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



Re: [PHP] making changes on arrays

2004-04-29 Thread Richard Harb
Hi,

that's something I tripped over myself when I started out :)

foreach takes one element after another from the array and copies it
into that new variable - in your case $value ...

you can modify it all you want - the value 'still' being in the array
will not be affected.

you could operate directly one the value in the array with:

// calculate the number of items in the array before starting the
// loop - will be faster the larger the array
$arCount = count($array);
for ($i = 0; $i < $arCount; ++$i) {
stripslashes($array[$i]);
}

although, on second thought I don't think that stripslashes will do
what you want it to, because it's designed to get rid of slashes
before special characters like the songle quote (I think, but try it
for yourself).

So, if you want your array to change from
  $array = ('zero\0', 'one\1', 'two\2', 'three\3');
to
  $array = ('zero0', 'one1', 'two2', 'three3');

(as I understood) then I'd recommend using str_replace.
That one also has the advantage of taking arrays as arguments so you
can save the whole for / foreach

$array = str_replace('\'', '', $array);

Richard


Friday, April 30, 2004, 6:01:30 AM, thus was written:
> I'm practicing from a beginning PHP book regarding
> arrays and the PHP manual, so please no one flame me
> that I didn't try to research before posting.  I'm
> thinking that what I want to do requires me to use the
> function array_walk or a foreach loop, but I'm not so
> sure so maybe someone help here can help.

> I want to have an array, perform an action on the
> values in the array, and have those actions
> permanently affect the values in the array.  Here's
> something I've written to test it out how I thought it
> could be done:

>  $array = ('zero\0', 'one\1', 'two\2', 'three\3');
> // look at array before changes
> print_r($array);
> // maybe use foreach or array_walk next?
> foreach ($array as $value)
> {
>  stripslashes($value);
> }
> // look at array after changes
> print_r($array);
?>>

> I'm guessing by now someone can see my error, but I
> don't know enough programming to spot it.  What I
> thought would happen is my values would have the
> backslash removed in the second print_r().  What I
> would want is for any changes made in the array
> (meaning my "values") to be permanent in the array
> afterwards.  If I can accomplish the code above, I
> figure I can create my own functions to affect changes
> on values or at least better understand what I'm
> looking at in other people's examples/comments at the
> online PHP manual.

> Thank you in advance.

> Katie




> __
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs  
> http://hotjobs.sweepstakes.yahoo.com/careermakeover 

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



Re: [PHP] re-keying an array

2004-04-29 Thread Richard Harb
http://www.php.net/manual/en/function.array-values.php ?

Richard


Friday, April 30, 2004, 3:48:06 AM, thus was written:
> been RTFMing for about 10 minutes, and can't find the function to 
> re-key an array.  In other words, I want an array of items to remain in
> their current order, but have the keys renumbered counting from zero.

> yes, I know it can be done with a foreach, but I was hoping for 
> something native :)

> can anyone point me to the right page in the manual?

> ---
> Justin French
> http://indent.com.au

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



Re: [PHP] substrings

2004-04-25 Thread Richard Harb
$color = '#aabbcc';

if (strlen($color) == 7) {
   echo ' r: ' . substr($color, 1, 2);
   echo ' g: ' . substr($color, 3, 2);
   echo ' b: ' . substr($color, 5, 2);
} elseif (strlen($color) == 4) {
   echo ' r: ' . str_repeat(substr($color, 1, 1), 2);
   echo ' g: ' . str_repeat(substr($color, 2, 1), 2);
   echo ' b: ' . str_repeat(substr($color, 3, 1), 2);
}

Sunday, April 25, 2004, 10:00:30 PM, thus was written:
> Hi, all --

> I must be having a brain fart as well as going blind because I can't find
> in the manual how to do this.

> Given a string like #AABBCC or #112233 how do I get the

>   2nd-3rd
>   4th-5th
>   6th-7th

> position substrings so I can break out the red, green, and blue values?
> All of the regular expressions seem to hinge on matching a separator, and
> the closest thing seems to be a

>   preg_match(".(..)(..)(..)",$color,$colors) ;
>   $r = $colors[1] ;
>   $g = $colors[2] ;
>   $b = $colors[3] ;

> but it just seems like I should be able to return a list like

>   ($r,$g,$b) = fn(operands,$color) ;

> or so.


> TIA & HAND

> :-D

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



Re: [PHP] From IIS to Apache

2004-04-24 Thread Richard Harb
Though this isn't stricly a PHP question - here we go:

It sounds as if IIS didn't really go away...

There's a nice utility out there that lets you know what ports are
active and in use ...
It's called Active Ports (duh!) and is a small download from
http://www.ntutility.com (section /freeware.html). Though it needs
admin rights to run I found this very useful.

Alternatively you could just open a command shell and:

telnet localhost 80

if the connection is opened type "GET /" to check what might be
answering ... (there's no local echo, so you're typing blind).

If all else fails you can always edit apache's configuration file in
notepad: C:\program files\apache2\apache\conf\httpd.conf (or some
such) and tell it to listen on another port (like the ever popular
8080 for example) .. the config file is very well documented, you
shouldn't have a problem finding your way.

HTH
Richard


Saturday, April 24, 2004, 7:57:53 PM, thus was written:
> I've been running IIS for a while now and I'm really sick of it and all it's
> security flaws. I decided today to upgrade to Apache, so I download the msi
> from the Apache website. I install it, but once it tries to install it as a
> service onto my XP Pro box, it gives me an error telling me that port 80
> cannot be used. IIS ran on port 80 and I uninstalled it, rebooted, but I got
> the error.

 > I've tried reinstalling Apache, rebooting, and pretty much everything I know
> to do. Any help here would be greatly appreciated.

 

> Thanks,

> Stephen Craton

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



Re: [PHP] Question about the mail() php function

2004-04-23 Thread Richard Harb
If I had to take a wild guess I'd say that there's no mail server on
your machine that would be capable of accepting email for delivery.
And that Warning is PHP's effort to tell you just that.

Hint: google - and I bet most other search engines - give you plenty
of sites providing good information on SMTP. When done reading a bit I
also recommend php.net/mail and maybe php.net/ini-set.

Richard
PS: the right place? It is, as long as you've done your homework and
made a reasonable effort to figure things out by means of reading
documentation and doing a search on the net for the obvious.


Saturday, April 24, 2004, 7:02:43 AM, thus was written:
> Hello,
> I was browsing your site and came across the mail() PHP function. I tryed it
> out:

>  mail("[EMAIL PROTECTED]", "My Subject", "Line 1\nLine 2\nLine 3");
?>>

> [EMAIL PROTECTED] is my e-mail adress, obviously enough..
> The problem is, the e-mail doesn't get sent.
> A warning appears on the page:

> Warning: mail(): Failed to connect to mailserver at "localhost" port 25,
> verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in
> C:\Program Files\Abyss Web Server\htdocs\page.php on line 24

> What is this all about?  Why wont it work?
> Thanks you very much

> If this is not the right place to send a question, please tell me where that
> right place would be :)

> shlagish (or Shawn, you choose)

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



Re: [PHP] PHP modifying data from DB?

2004-04-23 Thread Richard Harb
Have a look at strtotime() in addition to date()

Richard

Friday, April 23, 2004, 8:20:14 PM, thus was written:
> I have a field in a DB that contains a date.  The format of the date is:

> 04/08/2004

> However, when I retrieve the date from DB using PHP, it displays the
> following:

> 2004-04-08 00:00:00

> Is PHP tacking on the zero's?  I've tried using the date() function to
> reformat it back to how I want it, but haven't gotten it to work.

> Any ideas?

> Thanks!

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



Re: [PHP] OK SQL experts...

2004-04-23 Thread Richard Harb
AFAIK phpMyAdmin uses backticks for table/field names, not single
quotes ...


Friday, April 23, 2004, 5:22:35 PM, thus was written:
> I tried it both ways - didn't make any difference (phpmyadmin adds the
> single quotes when I was trying to use its sql function to debug, so I
> figured what the hell)...


> On Apr 23, 2004, at 8:27 AM, Edward Peloke wrote:

>> why are the table and field names surrounded by single quotes?
>>
>> -Original Message-
>> From: Brian Dunning [mailto:[EMAIL PROTECTED]
>> Sent: Friday, April 23, 2004 11:19 AM
>> To: [EMAIL PROTECTED]
>> Subject: [PHP] OK SQL experts...
>>
>>
>> I STFW and RTFM and I still can't figure out why this returns a 1064
>> parse error:
>>
>> SELECT * FROM 'my_table' WHERE ('field_1' LIKE '%$keyword%' OR
>> 'field_2' LIKE '%$keyword%' OR 'field_3' LIKE '%$keyword%') AND
>> 'status' = 'active';
>>
>> Anyone? TIA!
>>
>> - B1ff Lamer
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
> - Brian

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



Re: [PHP] require_once('') relative path problem

2004-04-22 Thread Richard Harb
did you check the online manual for those funcitons yet?

I have found the user notes to be a wealthy ressource on that matter.

This topic also came up very recently on this list so checking the
archives might solve it.

Richard


Thursday, April 22, 2004, 10:34:23 PM, thus was written:
> Hi,
> I have problem in undertanding the
> require_once/require/include/include_once
> functionality. Php files in my project are located in different folders.
> Some folders have common files for other files. And file layout is like this

> /*
> File: a.php
> */
> require_once('../test/db.php');
> ...


> /*
> File: db.php
> */
> require_once('../globals/global.php');
> ...


> when i include a.php in another file i get error for global.php file that
> path could not be found. And if i correct the path in db.php then someother
> file which is using db.php will get error. So, can someone elaborate that
> how relative path works in require_once. what is the starting directory for
> require_once function which is using relative path.

> Or

> Is there any way that i can included some constant which include the
> absolute path from which all relative paths can be determined?

> Comments welcome.

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



Re: [PHP] Adding includes to files

2004-04-22 Thread Richard Harb
You could either include the files without assigning the contents to a
variable - but that would display those right away:
   

or you could read the contents of the file like:

   

Richard
   
Thursday, April 22, 2004, 5:12:21 PM, thus was written:
> I need to add PHP calls to include a file to each page as it is
> generated, the only thing is I can't get the includes to come through
> correctly:

> 
>$display_block .= "";
>$display_block .= "";
> 

> At the end of the generation I write $display_block to a file as
> $display_block holds all the data it accumulates through the run. How
> do I rewrite the inlclude to work, or do I need to find another way to
> make the includes?  The includes are all template files that I used on
> the site to keep everything consistent.

> Thanks,
> Robert

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



Re: [PHP] session var puzzle

2004-04-18 Thread Richard Harb
Hi,

As I have no idea what those var contain ..
what does a print_r() of it give you?
print it right when you assign it to the session var to check if
it actually contains a value.

like:
print_r($Data['ID']);

and maybe even
print_r(intval($Data['ID']));

I suspect that this $Data['ID'] is empty from the start - otherwise
you ought to have something in your session var.

Richard


Monday, April 19, 2004, 12:46:02 AM, thus was written:
> Dear list,
> I am sorry for the second posting, but this is going
> to drive me to drink something other than lattes! 

> I have one page, index.php.  when it calls mod_sub, a
> directory type of page is printed.  Here I am trying
> to set a session var of the most recently selected
> category to allow the user to return the to same place
> in the directory.

> when I do this:
> $_SESSION['CategoryID'] = 230; in mod_sub

> then in mod_profile:
> print($_SESSION['CategoryID']);
> will print 230

> when I do this:
> $Tmp = 230;
> $_SESSION['CategoryID'] = $Tmp; in mod_sub

> in mod_profile:
> print($_SESSION['CategoryID']);
> will print 230

> BUT, when I do this:
> $_SESSION['CategoryID'] = $Data['ID']; in mod_sub
> $_SESSION['CategoryID'] = intval($Data['ID']);


> in mod_profile:
> print($_SESSION['CategoryID']);
> will print '' and 0

> I am setting several other session variables
> throughout the code without any unexpected behavior. 
> I have even tried changing the index to something odd
> in case I am resetting 'CategoryID' somewhere and
> forgotten it.  But no matter what I try, once I set it
> "= $Data['ID']" I get the odd result.

> BTW, if I print $_SESSION['CategoryID'] from mod_sub
> right after setting, it holds the expected value. 
> This is really frustrating, I must be missing
> something basic about the way session vars can be set.


> Kathleen

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



Re: [PHP] Regexp hyperlink

2004-04-18 Thread Richard Harb
A while ago I've been looking at some piece of code of the tikiwiki
project to see how they did some of their magic...

Basically they run through the whole text and if they found something
that was translated they made a hash and replaced the actual text with
it and stored the link in an assoc array.
when all occurrences of translatable elements were found they ran
through the array and replaced all hashes with the translated text.

I found that to be quite an ingenious way of doing it ...
Then again it might have misread/misinterpreted the code :)

Richard


Sunday, April 18, 2004, 10:08:51 PM, thus was written:
> I can't figure out how to do this.

> I've four different methods for changing a piece of text into a hyperlink.
> the text:
> [link=www.hotmail.com]hotmail[/link] 
> [link=http://www.hotmail.com]hotmail[/link] www.hotmail.com 
> http://www.hotmail.com

> what it should become (offcourse in HTML it will change to a real 
> hyperlink):
> http://www.hotmail.com"; target="_blank">hotmail  href="http://www.hotmail.com"; target="_blank">hotmail  href="http://www.hotmail.com"; target="_blank">www.hotmail.com  href="http://www.hotmail.com";
> target="_blank">http://www.hotmail.com

> i've got this regexps, at this point there are two different ones and I
> would like to combine them (not really necessary):
> 1.
> $text= str_replace("[link=http://";, "[link=", $text);
> $text= preg_replace("/\[link=(.+)\](.+)\[\/link\]/U", " href=\"http://\\1\"; target=\"_blank\">\\2", $text);

> 2.
> $text= 
> preg_replace("!(((http(s?)://)|(www|home\.))([-a-z0-9.]{2,}\.[a-z]{2,4}(:[0-9]+)?)((/([^\s]*[^\s.,\"'])?)?)((\?([^\s]*[^\s.,\"'])?)?))!i",
> "\\1", $text);
> // I copied this one, maybe someone knows a better one?

> the problem is that it's replaced a second time resulting in this:
> http://www.hotmail.com 
target="_blank">>http://www.hotmail.com]hotmail[/link] [link= href="http://www.hotmail.com"; target="_blank">www.hotmail.com" 
target="_blank">>hotmail http://www.hotmail.com"; 
target="_blank">>www.hotmail.com http://www.hotmail.com"; 
target="_blank">>http://www.hotmail.com

> the last two (without the [link=] part) are working

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



Re: [PHP] example from meloni not working

2004-04-18 Thread Richard Harb
From what I've seen you didn't actually transmit the first query to
the database.
You assigned the query string to the variable $sql ... but didn't
submit with:
mysql_query($sql);

hth
richard

Sunday, April 18, 2004, 7:41:47 PM, thus was written:
> A basic ht counter script from Meloni's book on mysql (page 318).

> Not working for me.
> Every time I load the page the counter stays at zero.

> Thanks for help.
> TR
> ..

>  $page_name="test1";
> $db=mysql_connect("localhost","root",'mypass");
> mysql_select_db("sitename");
> $sql = "UPDATE test_track SET hits = hits + 1 WHERE page_name =
> '$page_name';
> $sql2="SELECT hits FROM test_track WHERE page_name='$page_name'";
> $res=mysql_query($sql2);
> $hits = mysql_result($res,0,'hits');
?>>
> 
> 
> You have been counted.
> 
> The current number is 
> 
> 
> .

> // mysql SCHEMA

> CREATE TABLE test_track(
> id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
> page_name VARCHAR(50),
> hits INT
> );

> INSERT INTO test_track VALUES(1,'test1',0);
> 

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



Re: [PHP] Array Problem

2004-04-17 Thread Richard Harb
Saturday, April 17, 2004, 7:38:46 PM, Arthur Radulescu wrote:

>> That's how you could do it ...
>> 
>> $ar = array();
>> 
>> $len = strlen($a);
>> for ($i = 0; $i < $len; ++$i) {
>> $ar[] = $a{$i};
>> }

> If I remember well strlen is used for checking the length of a string...

It does ...
I didn't look closely enough :(
So .. the var has to be converted to str first ... or use a temp var
converted to string ...

except of course someone comes up with a better method of solving the
problem at hand.



just for reference: the original problem (as I now understand it) was
how to 'convert' a number into an array ...


Friday, April 16, 2004, 11:00:49 PM, Flavio Fontana wrote:

> Hi

> I have i Problem i got a variable a=2351 now i need to create an array out of this 
> variable
> a[0]=1
> a[1]=3
> a[2]=5
> a[3]=1

> I have an idea to use the modulo function an do some Math but im
> sure there is a nicer way of solving my prob

> thx Flavio

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



Re: [PHP] Array Problem

2004-04-17 Thread Richard Harb
That's how you could do it ...

$ar = array();

$len = strlen($a);
for ($i = 0; $i < $len; ++$i) {
$ar[] = $a{$i};
}

HTH

Richard



Friday, April 16, 2004, 11:00:49 PM, you wrote:

> Hi

> I have i Problem i got a variable a=2351 now i need to create an array out of this 
> variable
> a[0]=1
> a[1]=3
> a[2]=5
> a[3]=1

> I have an idea to use the modulo function an do some Math but im
> sure there is a nicer way of solving my prob

> thx Flavio

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



Re: [PHP] Using ' to access session variables?

2004-04-16 Thread Richard Harb
If used outside any strings (like in your $query example)
$_SESSION[foo]  --  here foo technically is a constant
and php ought to produce a notice
$_SESSION['foo']  --  is the correct way as there is no doubt that foo
  is a string

When used inside a string the rules are slightly altered
@see http://www.php.net/manual/en/language.types.array.php
section Array do's and don'ts

Richard


Friday, April 16, 2004, 6:32:11 PM, you wrote:

> Whats the difference between $_SESSION[foo] and $_SESSION['foo'] I have been
> using the 's but they seem to be unecessary?

> I run into trouble if I try something like:


> $query = " select * from table where (test.id = '$_SESSION['foo']') ";

> but the following works:

> $query = " select * from table where (test.id = '$_SESSION[foo]') ";


> I know there is some way to properly escape characters but is there any
> reason why I shouldn't just omit the 's?


> Thanks!

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



Re: [PHP] session timeout

2004-04-16 Thread Richard Harb
Friday, April 16, 2004, 4:35:30 PM, you wrote:


> Hello Marek,


>I had similar trouble with my PHP application. I used an .htaccess
> file with the same line. But it still did not work. I guess I even tried
> ini_set() function.

> I have a question with this point :

I can only answer part of it:

>> 2. No other application can access your session storage. Other
>> applications could have shorter session lifetime, and the shortest 
>> would apply for all other applications.

If you have your own session_save_path('/my/session/path') and make
sure no other application writes to the same one those sessions are
'safe' and in theory cou can have any session timeout you want. (same
argument, rephrased)

> Does it mean that the shortest session lifetime associated with an
> application applies to all other applications in the domain ?

yes,

The reason for this is that the session garbage collector gets called
with a certain (configurable) probability that will remove any files
older than TTL in that directory - automagically invalidating any
session ids having been inactive - no file to validate against.


> Has anyone been able to get the session_life to last atleast a couple
> of hours // my appl logs the user out after about 30 mins

I can't confirm on having longer session timeouts as I didn't really
care / had the need to...


> Thanks in advance
> Pushpinder Singh

Richard


> On Friday, April 16, 2004, at 08:54 AM, Marek Kilimajer wrote:

>> pete M wrote:
>>
>>> Am trying to increae the session lifetime to 8 hours ish
>>> using this code
>>> ini_set('session.gc_maxlifetime',28800);
>>> does not work ?
>>> any ideas
>>> Pete
>>
>> There are 3 conditions that must be met:
>>
>> 1. You must set it before session_start()
>>
>> 2. No other application can access your session storage. Other 
>> applications could have shorter session lifetime, and the shortest 
>> would apply for all other applications.
>>
>> 3. The session cookie must live long enough. The default lifetime for
>> session cookie is 0, that means untill the browser closes.
>>
>> HTH
>>
>> -- 
>> 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: AW: [PHP] smarty

2004-04-16 Thread Richard Harb
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Could we please close the thread already?

I think in the previous week there's been everything said what there's
been to say. whoever is still interested in reading the same arguments
over and over should please take a look at the archives.

I value the opinion of every poster if (s)he has something to
contribute - but contribution also includes adding something not
already present in abundance.

... and I really don't want to killfile any members of this list.

Thanks

Richard

PS: sorry if it sounds kinda pissed.



Friday, April 16, 2004, 4:10:20 PM, you wrote:

> pete M said:
>> Smarty is a cool tool and lots of people use it. You have decided NOT to
>> use it.

> I don't believe you've read a word I've written.

> I've been trying to tell people like myself that one can easily template
> with PHP.  I thought I *needed* Smarty or any nice templating engine to
> seperate business and presentation logic; I was wrong.  I was ignorant and
> perhaps there are others like me.

> I've also been saying that I'll probably use Smarty in the future.
> Advantages: numerous time-saving built-in functions, performance (debatable)
> Disadvantages: must learn yet another language and work with that
> language's shortcomings.

> I never said I've decided NOT to use it.  I've never said it wasn't a cool
> tool.  Please read carefully.

> /dev/idal

-BEGIN PGP SIGNATURE-
Version: PGPsdk 2.0.5 Copyright (C) 2001 Networks Associates Technology, Inc. All 
rights reserved.
Comment: ""

iQA/AwUBQH/ti0LEeLYDwe5mEQKW2ACeKc1lBSCJe4x8cMmbjt6Fii87koQAnRHl
q70qB+EHK8HlwhVnCok+wfTm
=NyMA
-END PGP SIGNATURE-

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



Re: [PHP] Encrypting Source

2004-04-16 Thread Richard Harb
Two come to mind:
- Zend Encoder
  costs $, but is widely supported as it 'only' needs zend optimizer to decode
- Turck MMCache/phpcoder on sf.net
  open source but not available on most webhosters. though IMHO the cache
  alone is worth looking into

There may be other solutions
/me steps back for more/other suggestions

Richard

-- 
My sig: To save a couple bytes just imagine having read 'de bello
gallico' in the original latin text as well as the english, german and
spanish translations. Consider yourself enlightened.


Friday, April 16, 2004, 8:45:27 AM, you wrote:

> Greetingz,

> We are looking for some encryption software for our PHP source code,
> We know of a couple but wanto find out which are good and which are not...

Well, the ones I just suggested are probably on your list, but as we
don't know what is ...


> Till We Meet Again...



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



Re: [PHP] Re: PHP editor

2004-04-15 Thread Richard Harb
Finally somebody else who does it that way
Unfortunately most of the $ signs usually get messed up...

So ... which ocr program do you use / recommend for that?

:)


Thursday, April 15, 2004, 2:12:44 PM, you wrote:

> I code with pencil and paper then scan it  with OCR ;-))



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



Re: [PHP] Session confusion again :( - Thanks!

2004-04-15 Thread Richard Harb
Actually for me it isn't unclear at all:

The (super-) global variables are created when php starts working on
your script.

That pesky function/ini parameter (register_globals=on) is just a
replacement for an extract() on each of the global vars just then.

Whatever you do later with any of the variables is up to you - that
extract won't 'run' again - even with register_globals on

Similar to this: if you change some $_POST or $_GET var 'manually' the
$_REQUEST doesn't get updated ...

Richard


Thursday, April 15, 2004, 1:35:19 PM, you wrote:

> On 14 April 2004 17:53, Paul Fine wrote:

>> Thanks guys but I have register globals ON so once the
>> session variable is
>> defined I should be able to address it without specifying $_SESSION ?

> I don't think the documentation is clear on this point -- it may be that the
> association between the global variable and the $_SESSION array doesn't
> "take" until the next page load and session_start(), and in any case the
> behaviour seems to be different between 4.2 and 4.3.  I *think* you may have
> to session_register('element_countp') to make the association in the current
> page, but this is buggy and seriously disrecommended in 4.2 (although fixed
> in 4.3).

> Personally, I'd just use the $_SESSION[] variable anyway, and not bother
> with the equivalent global.

> Cheers!

> Mike

> -
> Mike Ford,  Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] OOP variables

2004-04-15 Thread Richard Harb
http://www.php.net/manual/en/language.oop.php states:

[quote]
In PHP 4, only constant initializers for var variables are allowed. To
initialize variables with non-constant values, you need an
initialization function which is called automatically when an object
is being constructed from the class. Such a function is called a
constructor (see below).
[/quote]

Richard

PS: Isn't it cool when every explanation is already written down in a
manual?


Thursday, April 15, 2004, 10:27:00 AM, you wrote:

> Hello, 

> I was wondering if somebody would mind explaining this to me, is there a
> big difference or requirement to pre defining variables your going to
> use in a class eg: 

> class name {
>   $var1 = '';
>   $var2 = '';

>   function blah(){
>   $var2
>   }
>}//-- End class  

> Or is this also right 

> class name {

>   function name(){

  $this->>var1 = '';
  $this->>var2 = '';
>   }   
>   function blah(){
>   
>   }
>   }//-- End class


> Thanks 
> Jarratt

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



Re: [PHP] Command line include path?

2004-04-13 Thread Richard Harb
If all else fails, try setting the include path in your project:
http://at.php.net/manual/en/function.set-include-path.php

(check out the comments section)
hth
Richard

Tuesday, April 13, 2004, 10:45:23 PM, you wrote:

> I'm getting started with PEAR's DB_DataObject and am trying to follow along
> with the tutorial:

> http://pear.php.net/manual/en/package.database.db-dataobject.intro-purpose.p
> hp

> It tells me to create the ini file (which I did) and then run
> createTables.php from the command line to generate my class files. I'm
> trying to run it and am running into an include issue:

> zorn$ php -f createTables.php
> /Library/WebServer/Websites/ASMP/config/DB_DataObject.ini

> Warning: main(DB/DataObject/Generator.php): failed to open stream: No such
> file or directory in
> /usr/local/php/lib/php/DB/DataObject/createTables.php
> on line 22

> Fatal error: main(): Failed opening required 'DB/DataObject/Generator.php'
> (include_path='.:/usr/lib/php') in
> /usr/local/php/lib/php/DB/DataObject/createTables.php on line 22

> -- Does the command line have it's own include path. Based on my phpinfo()
> mine is: .:/usr/local/php/lib/php

> ~ Mike
> -
> Mike Zornek
> Web Designer, Media Developer, Programmer and Geek
> Personal site: 
> New Project: 

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



Re: [PHP] automatic doc generation for classes

2004-04-13 Thread Richard Harb
Well, since you already mentionned it:
Why not use phpdoc? I use it on a regular basis: it's pretty good.

(Yes, it works like a charm on a windows box with enough memory)

Richard

Tuesday, April 13, 2004, 9:10:23 PM, you wrote:

> does anybody have any good recommendations for anything to do auto doc
> generation for php classes/functions and stuff.. like phpdoc or something of
> that sort?

> what ones are the best to use for windows

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



Re: [PHP] php 5 install

2004-04-10 Thread Richard Harb
That's just one of those annoying out of office messages...
I could translate it .. but if the sender didn't care I guess it's not
important enough for him to provide an english translation himself.

Saturday, April 10, 2004, 11:17:44 PM, you wrote:

> anybody know how to put that in english?? i have no clude what it says...


> - Original Message - 
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, April 10, 2004 5:13 PM
> Subject: Re: [PHP] php 5 install


>> Hallo und guten Tag,
>>
>> herzlichen Dank für Ihre Mail.
>>
>> Zeit zu leben und Zeit zum Schreiben machen gerade Osterpause, weshalb
> Emails nur sehr sporadisch gelesen werden.
>> Aber keine Sorge - keine Mail geht verloren :-)
>>
>> Der nächste Newsletter für Zeit zu leben erscheinen zum 19.4.04, der für
> Zeit zum Schreiben zum 1.5.04.
>>
>> Ab dem 19.4.04 sind wir dann auch wieder regulär für Sie da - Ihre
> Anfragen werden spätestens dann beantwortet.
>>
>> Wundervolle Frühlingstage und ein schönes Osterfest wünschen Ihnen
>>
>> Tania Konnerth & Ralf Senftleben
>>
>> --
>> Alles für ein aktives Leben - http://www.zeitzuleben.de Lust zum
> Schreiben? http://www.zeitzumschreiben.de
>>
>>
>>

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



Re: [PHP] require_once '../config.php'; doesn't work?

2004-04-09 Thread Richard Harb
Depends on where the executed script is located ...
And it always depends on the script that is called - if you give a
relative path like you did here.

if the script you called would be
http://www.example.com/news/2004-04-10/mypage.php

then config.php would have to be in /news

if your layout is like:
/   (root)
|-settings/
|-news/
  |-2004-04-10/

and you call a script in root then db.php would be included, but not
if called from the dir news ...

You could either prepend something (like $_SERVER['DOCUMENT_ROOT']) or
you define something like
define ('MY_SETTINGS_DIR', '/usr/local/www/settings');
so the path will be absolute ...

or you could write some function that calculates the relative path to
root no matter where the script you called resides in - and prepend
that string then ...

or 

hth

Richard


Saturday, April 10, 2004, 4:36:31 AM, you wrote:

> Is it true I can't include a file up a dir like this:

> require_once '../config.php';

> This seems to work though:

> require_once 'settings/db.php';

> Strange.

> ~ Mike
> -
> Mike Zornek
> Web Designer, Media Developer, Programmer and Geek
> Personal site: 
> New Project: 




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



Re: [PHP] regular expressions

2004-04-09 Thread Richard Harb
Saturday, April 10, 2004, 2:02:04 AM, you wrote:

> I'm trying to 'clean up' some text that is extracted from a web 
> directory, and I need to use (I think) preg_replace or ereg_replace,
> etc. I've read a bunch of tutorials, but none of them seem to cover the
> particular thing I want to do. Here's an example of text I need to 
> process:

> -

> J.  Smith   ( More Info )
> map
> driving directions
> add to My Directory
> update or remove

> Did you go to High School with J.  Smith?



without further ado:
$str = ;
$what = array("/\r\nupdate or remove/", "/\r\nDid you go.*\?\r\n/i");
$with = array('', '');

echo preg_replace($what, $with, $str);

hth
Richard

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



Re: [PHP] Finding value in multi-dimensional array

2004-04-09 Thread Richard Harb
No problem ..
Let's see:
if($_SESSION['OBJ_user']->modSettings['listings']['active'] == '1') {

That should be it ...

Sidenote: use single quotes whenever the string needn't be evaluated
(i.e. is a variable itself) you save a couple cycles every time.

hth
Richard


Friday, April 9, 2004, 10:32:25 PM, you wrote:

> Sorry, my example was poor :) Thanks for the print_r tip. When added to the
> bottom of the page,

> print_r($_SESSION["OBJ_user"]);

> Prints...

> phpws_user Object
> (
> [user_id] => 5
> [username] => agent
> [password] => 77abcd5cb2ef4a366c2749ea9931c79e
> [email] => [EMAIL PROTECTED]
> [admin_switch] => 1
> [deity] => 
> [groups] => Array
> (
> )

> [modSettings] => Array
> (
> [listings] => Array
> (
> [active] => 1
> [first_name] => Agent
> [last_name] => Guy
> )

> )

> [permissions] => Array
> (
> [MOD_debug] => 1
> )

> [groupPermissions] =>
> [groupModSettings] =>
> [error] => Array
> (
> )

> [temp_var] => 
> [last_on] => 1081527610
> [js_on] => 1
> [user_settings] =>
> [group_id] => 
> [group_name] =>
> [description] =>
> [members] => 
> )

> So, should my reference be...

> if($_SESSION["OBJ_user"]["modSettings"]["listings"]->active == "1")

> That didn't seem to work, but if it should, perhaps I need to look somewhere
> else?

> Thanks,
> Verdon



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



Re: [PHP] Finding value in multi-dimensional array

2004-04-09 Thread Richard Harb
do a print_r() for the structure. --> print_r($_SESSION["OBJ_user"]);
and look at the page source.

at each level ...
if is says array refer to it with ['property']
if obj (stdClass or otherwise) use -> that arrow thingy

I am not sure what the arrows in you desc mean, whether it's key/value
pair of the array or hints to it being an object's property.

hth

Richard

Friday, April 9, 2004, 9:43:36 PM, you wrote:

> Hi, being somewhat of a noob, I hope I'm using the right language to phrase
> this question...

> In a project I am working with, I have a multi-dimensional array in session
> when a user logs in. Visually, it looks something like this...

> OBJ_user
> username => value
> isAdmin => value
> modSettings =>  contacts => array
> news => array
> listings => firstname => value
> lastname => value
> active => value
> phone => value
> gallery => array
> anothermod => array
> userID => value
> js => value


> I'm trying to check the value of active for an if() statement and can't seem
> to figure out the correct syntax to get it to work. I've tried

> if($_SESSION["OBJ_user"]->modSettings["listings"]->active == "1") {
> then do something;
> } else {
> then do something else;
> }

> if($_SESSION["OBJ_user"]["modSettings"]["listings"]["active"]) {
> then do something;
> } else {
> then do something else;
> }

> if($_SESSION["OBJ_user"]["modSettings"]["listings"]["active"] == "1") {
> then do something;
> } else {
> then do something else;
> }

> and none of them work even though I know the session value is there.

> Any advice as to what I'm doing wrong?

> Thanks,
> verdon

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



Re: [PHP] Problem running sql stored in the database

2004-04-09 Thread Richard Harb
Not quite sure what you mean...

So I assume the data was written into the worng fields.

If that is the case you could modify your insert query:
INSERT INTO table (id, name) VALUES ('$id', '$name')

hth
Richard

Friday, April 9, 2004, 4:11:05 PM, you wrote:

> Hi,
> I am getting 2 values from a form:

> $client_id and $client_name (for understanding: client_id = '12'
> name='ryan')

> when the client submits the form:
> 1. I run a query in my php script inserts this data into the db,assigns a
> C_ID.

> 2. The query also checks if I have a stored sql statement for this C_ID
> 2a. If "YES" it tries to execute the query (if NO, execution stops here, all
> is well)

> 3.The stored SQL is usually something like "insert into
> tester('$client_id','$client_name')"

> Heres where the problems coming in, it seems to be doing everything as it
> should except when
> I check the database I see that it has inserted:
> "$client_id"  "$client_name"  into the fields instead of "12"  "ryan"

> The above should explain everything but if you want the code I can post it.

> Kindly reply.

> Thanks,
> -Ryan

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



Re: [PHP] Compare Case Insensitive?

2004-04-08 Thread Richard Harb
let's see:
eregi()
preg_match()
strtolower()
... either one could help you
probably fastest is convert the user string to lower case and compare
... or upper case .. your choice.
Damn. so many options.

Thursday, April 8, 2004, 5:21:15 PM, you wrote:

> How can I compare a variable submitted by a form as case
> insensitive? A promotional code will be entered into a form
> and it's important that they can enter the code either way.
> So if I have

> if ($code == 'ABC123') {

> I want that to match 'aBC123' 'abc123' or whatever. Thanks.
> Jeff

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



Re: [PHP] smarty

2004-04-08 Thread Richard Harb
Well, I can't say that it's a 'good' tutorial, it's a little messy,
but it's along the lines of how I am using it ... If you want to have
a look, I put together a page and some explanations and stuffed it
into an archive (162Kb) You can downlad it at
http://www.wegotit.at/sm_demo.zip

If you're going to look at it, drop me a line to let me know if it's
too confusing or if you could actually make something out of it :)

Richard

Thursday, April 8, 2004, 9:11:06 AM, you wrote:


> Does anyone have a 'good' tutorial about Smarty. The one
> available on smarty.php.net is really basic...


> Vincent


> -Original Message-
> From: Robert Cummings [mailto:[EMAIL PROTECTED]
> Sent: jeudi 8 avril 2004 4:02
> To: Kelly Hallman
> Cc: PHP-General
> Subject: Re: [PHP] smarty


> On Wed, 2004-04-07 at 21:35, Kelly Hallman wrote:
>> Apr 8 at 10:26am, Justin French wrote:
>> > PHP itself is a great templating language :)
>> > 
>> > 
>> > 
>> >  
>> > 
>> > 
>> > > href='mailto:'>
>> > 
>> 
>> Uhhh, yeah--that's not a templating, that's called spaghetti code :)
>> 
>> You get the concept. Smarty, as you know, basically takes a Smarty
>> template and writes PHP code similar to what you've done above, then
>> writes out the .php file, and includes it when you render your template.
>> So you'd get nearly the same effect by writing the PHP as a separate file
>> and including it as your last step, and it acts as your display logic.
>> 
>> That may be acceptable to you, as a PHP programmer. If you're the only one
>> who ever needs to modify your templates then that's great, more power to
>> you. I'm sure that you would have no problem having many levels of nesting
>> all over the place and not screwing anything up. So be it. But that's you.
>> 
>> I guarantee another person not as adept at PHP will screw that code up,
>> and there is less potential for that with a Smarty template. If you know
>> PHP as well as yourself, it should be plain to see how Smarty is just a
>> wrapper over PHP that makes templates easier to build and maintain.
>> For a designer or non-coder, Smarty will be easier to learn than PHP.
>>  
>> Unless your needs never exceed the very basics like you have demonstrated
>> above, you'll be hosed when another person needs to modify your template.
>> Which goes back to a templating truism never in dispute: if this is all
>> you want templating for, it's six of one, half a dozen of the other.
>> 
>> However, there are practical limitations on what you can easily accomplish
>> with this approach, and Smarty addresses those issues. And you're worse
>> off if you invest a lot into building your sites this way, and then
>> realize you need some better templating strategies later.
>> 
>> > You can still separate your logic from your presentation, template
>> > designers can still use quick, simple "tags" to include code, and the
>> > upside is that people familiar with PHP don't need to learn ANOTHER
>> > language (that's what Smarty is) -- they can dive straight in.
>> 
>> You can consider it it's own language, but really it's more like PHP with
>> different formatting. Which is why it's different than what you're doing
>> above--it's designed to facilitate templating. Your method is just poking
>> in variables and PHP into inline'd HTML. It works, but you're missing some
>> of the power of Smarty if you think that's all it's good for.
>> 
>> > The question is, do you want to give your templater designers full
>> > access to the power of PHP, or not.
>> 
>> In other words: are your template designers already good PHP programmers?
>> It's not just hype, it solves real problems, even if you don't have them.

> Smarty is a bit of a hack too... why do I need to declare my templates
> within the PHP code? If I'm an HTML designer I'd like to create a new
> page, include templates, use some data that's been made available and
> have it all in the template. I sure as heck wouldn't want to have joe
> programmer edit the main page, add support for importing my template.
> This is the thing that bugs me about Smarty, its still got that hanging
> dependency. And it's still got to include all those templates within the
> source code.

> InterJinn is superior in this respect. You use XML tags to import other
> templates, you use XML tags to load modules and components, and you use
> XML tags to do almost any kind of expansion you want. Of course, you can
> go ahead and use something else, InterJinn provides the ability to plug
> in custom compilers. InterJinn compiles to PHP code, includes are
> INCLUDED at compile time not at run time. So given this scheme anyone
> working on the HTML is already familiar with the syntax... hard to go
> wrong with:

> 

> Hell you can even overload HTML tags. Not only that but Interjinn allows
> recursive includes of templates and source files, and these includes can
> be relative to the outer nested template or source file. Furthermore,
> there's nothing forcing the use of the InterJin

Re: [PHP] html forms class in php

2004-04-07 Thread Richard Harb
Then again you can just put the pear stuff into a subdirectory of your
project site / whatever.

for PHP 4 >= 4.3.0 you could have a look at:
http://www.php.net/manual/en/function.set-include-path.php

for older versions you can use ini_set (@see same url)
I've seen it done - works just as well. The pear libraries are PHP
code anyway, so it doesn't really have to be installed like
ImageMagick or TurckCache or something ...

hth

Richard

Thursday, April 8, 2004, 8:09:09 AM, you wrote:

> hi

> yesterday i posted a msg about wanting to know if it was a good idea to
> write a class that created/dealt with html forms and so on... somebody told
> me to go look at html_quick_forms class and it looks good like everything i
> would want to do but there is 1 problem: is there any classes for the same
> thing out there anybody knows of that does the same thing but doesnt require
> pear to be installed??

> i dont have access to pear on the servers i deal with and the admin refuse
> to install it...

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



Re: [PHP] problems with md5()

2004-04-07 Thread Richard Harb
could it be that the field in the database is of type
varchar(25) ?
looks like it's too small to hold the complete hash: that one always
consists of 32 characters.

Thursday, April 8, 2004, 6:35:47 AM, you wrote:

> hello,
>  I have a database containing usernames and md5 encrypted passwords.
> When i use md5() to encrypt a users password recived via a form
> to compare to the md5ed passwd in the database i get problems...

> for instance ...

> user foo has passwd 'pass' 
> 'pass' md5ed in database is this 

> 1a1dc91c907325c69271ddf0c

> i got this using phps md5.

> Then ... when i md5 a pass i recieve later to compare
> for a login the password 'pass' comes up like this...

> 1a1dc91c907325c69271ddf0c944bc72

> they are the same except the trailing 944bc72

> this happens when i try other password too.

> here is the code that is giving me the problems...

> function auth(){
>  $user = $_POST['user'];
>  $pass = rtrim($_POST['pass']);  // i added this trying to fix :(
>  $pass = md5($pass);  
>  $query = "select password from dealers where username = '$user'";
>  $result = $this->sqlQuery($query);
>  if(!$result){
>   echo "Sorry there was a error, please try again later.\n";
>  }
>  else{
>   $thePass = mysql_fetch_array($result);
>   if($thePass[0]){
>if(strcmp( $pass , $thePass[0]) == 0){
> echo "match\n";
>}
>else{
> echo "pass = $pass "; // from from   
> echo "hash = $thePass[0]";// from db  
>}
>   }
>   else{
>$this->logonPage(1);
>   }
>  }
> }



> can some one tell me what im doing wrong

> thanks,


> [EMAIL PROTECTED]

> "Bad spellers of the world untie!"




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



Re: [PHP] very large and long if statement

2004-04-07 Thread Richard Harb
Thursday, April 8, 2004, 3:59:39 AM, you wrote:

>> I have this very large and long if statement:
>> if
>>  (!empty($_SESSION['add']['type'])
>>  && !empty($_SESSION['add']['start_date']
>>  && !empty($_SESSION['add']['end_date'])
>>  && !empty($_SESSION['add']['name'])
>>  && !empty($_SESSION['add']['county'])
>>  && !empty($_SESSION['add']['discription'])
>>  && !empty($_SESSION['add']['StartingDay'])
>>  && !empty($_SESSION['add']['StartingMonth'])
>>  && !empty($_SESSION['add']['StartingYear'])
>>  && !empty($_SESSION['add']['EndingDay']})
>>  && !empty($_SESSION['add']['EndingMonth'])
>>  && !empty($_SESSION['add']['EndingYear']))
>>  {//run the insert query}



> As I understand it, !empty is redundant (at least, it's always worked for
> me, but I'm no expert).

In a perfect world you would be right, however if the var isn't set
then you'd get a notice (depending on your error reporting levels).

So I personally prefer to check against the !empty ...

---
That being said I have one more point to make:
Your if statement will fail if any  isn't satisfied. But you have no
way to tell which one was missing...

On pages where multiple fields are required I usually use something
like:

$errors = array();
$check_vars = array('type', 'start_date', 'end_date', ...);

foreach ($check_vars as $var) {
  if (empty($_SESSION['add']["$var"])) {
$errors[] = $var;
// or something like: $errors = get_error_desc_for($var);
// ... just making this up.
  }
}
if (count($errors)) {
  $output_errors = implode('', $errors);
} else {
  // run query
}

While I know that this contains a lot more code it's rather easy to
add another element to check against, and it allows me to pinpoint
exactly what's gone wrong ...

ok. not exactly what you asked for ... I was just in the mood :)

Richard

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



Re: [PHP] simple mysql_result() question

2004-04-07 Thread Richard Harb
Uhm .. I usually do:

SELECT COUNT(id) FROM users WHERE name='$username' AND
password='$password'

if (username is found)  // hopefully it's unique
  found ya
else
  sorry

This way you aleays have a value returned...

HTH

Richard

Thursday, April 8, 2004, 3:29:11 AM, you wrote:

> hello,
>  I am trying to authenticate users. I run this MySQL query using
> vars provided via a form

> select password from dealers where username = '$user'

> this works great if $user is actually a user in the database.
> otherwise i get this error

> Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 3
> in /var/www/php/AuthTool.php on line 52

> its because of this

> $thePass = mysql_result($result,'0','password');

> is there a way to stop this error, should i be using mysql_fetch_array
> instead? Code below.

> Thanks,
> jd



> function auth(){
>  $user = $_POST['user'];
>  $pass = $_POST['pass'];
>  $query = "select password from dealers where username = '$user'";
>  $result = $this->sqlQuery($query);
>  if(!$result){
>   echo "Sorry there was a error\n";
>  }
>  else{
>   $thePass = mysql_result($result,'0','password');
>   if($thePass){
>echo "$thePass\n";
>   }
>   else{
>echo "no such user - $user\n";
>   }
>  }
> }
> -- 
> [EMAIL PROTECTED]

> "Bad spellers of the world untie!"

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



Re: [PHP] smarty

2004-04-06 Thread Richard Harb
Tuesday, April 6, 2004, 5:33:03 PM, you wrote:

> hi all has anyone used smarty before? what do you think of it? I think it's
> pretty nice to seperate your script (code) from your design.

> i would like to hear your comments and if you have any alternatives let me
> know.

Hi,

I've used it on a few sites - and I sort of can't do without any more
:) - just kidding, but the clean seperation of logic and presentation
helps a lot creating maintainable code.

Speedwise it's very fast, no complaints there. There might have been a
couple limitation here and there (uhm - new versions took care of that
for me as well), but then you can write your own
extensions in no time and get around those as well.

Bottom line: I definitely recommend it.

Richard

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



Re: [PHP] mysql_query problem with multi dim arrays

2004-04-05 Thread Richard Harb
Tuesday, April 6, 2004, 1:21:52 AM, you wrote:

> hi...
> i cant cut and paste my exact mysql query because it takes the ''
> stuff out doubles the $'s and the ,'s in the whole thing (dont know
> why but anyways...)...

> i have a query that goes something like this:
> mysql_query("insert into $GuestbookTable values(NULL,
> '$_SESSION[add][date]', '$_SESSION[add][name]',
> $_SESSION[add][email]..");

> the problem i get is using the multi dimentional arrays to insert
> text and stuff all i actually get when i echo the query or do a real
> insert is:

> echoed it would be something like:
> insert into rnjresort.guestbook values(NULL, 'array([add]),
> 'array([add])', 'array([add])', ...

> any idea what the problem is here? do i have the '' in the wrong
> places?? i know that works on single dimention arrays but doubled?


Well, then again you can still write your query as:

$sql = "INSERT INTO table (field1, field2, ..., fieldn)"
$sql .= " VALUES ('" . $ar['index1']['index2'][$i] . "'" .
" ,'" . $ar['index1']['index2'][$i] . "'";


or some such ... close/open the strings in between :)

HTH

Richard


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



Re: [PHP] includes

2004-04-05 Thread Richard Harb
Monday, April 5, 2004, 4:47:52 PM, you wrote:

> Hello all,
> I have a problem.  My directory list is similar to this:
>>root
> >tmpl
> >inc
> >forums



> My question is in the test_form and message forums.  How do I do the include
> files to read from the tmpl and inc??

> I can get the include files to work as long as they are in the root (include
> "tmpl/header.htm").



Check the online manual:
http://www.php.net/manual/en/function.dirname.php

and read the comments (bottom first and up ..)
good info there on that very subject.

Richard

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



Re: [PHP] Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Richard Harb
Monday, April 5, 2004, 11:23:29 PM, you wrote:

> I am trying to use fewer resources and processes when making database
> connections in my scripts, so, upon the first call to make a DB connection,
> I store the Link Resource ID in a constant variable that can be accessed by
> all other functions that need a DB connection, like this...

> function connect_db() {

> if (!defined('_CONNECT_DB')) {

> $result = @mysql_pconnect("localhost", "Username", "Password");
> @mysql_select_db("database_name");
> define('_CONNECT_DB', $result);
> }
> return _CONNECT_DB;



From: http://www.php.net/manual/en/language.constants.php

Only scalar data (boolean, integer, float and string) can be contained
in constants.

--
somewhere in the manual it is said that while a resource or link or
some such identifier might look like an integer, it actually isn't.
So by extension it is not a scalar value and thus cannot be stored via
the means of a define().
Use a 'normal' variable instead.

Richard

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



[PHP] Sorting array of objects

2004-04-04 Thread Richard Harb
Hi there,

Supposed I have an array of objects, like:

$this[$i]->property1
$this[$i]->property2

is there any 'cheap' way to sort the array according to the values of
property1?

The only way I thought I would be able to accomplish this is to
transform this into an assoc array or something like it and then sort
it ...

I found plenty of functions for dealing with plain arrays, but nothing
- easy to use - for this. Am I just blind or do I finally have to write
a function doing that on my own?
And if so - anyone who had to do this before and come up with a really
fast solution (I guess my attempts would work - but not very efficient)

Thanks

Richard

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