Re: [PHP] First PHP

2002-11-29 Thread CC Zona
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Khalid El-Kary) wrote:

> http://www.php.net/manual/en/history.php#history.php

First public announcement of PHP by Rasmus:


-- 
CC

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




Re: [PHP] fullname

2002-07-30 Thread CC Zona

In article <001301c23799$2deb3b30$100a0a0a@skink>,
 [EMAIL PROTECTED] (David Freeman) wrote:

>  >   is there some other easyer way to do in one line than this?:
>  > 
>  > $fullname = $session["f_name"];
>  > $fullname .= " ";
>  > $fullname .= $session["l_name"];  
> 
> $fullname = $session["f_name"] . " " . $session["l_name"];

...or *if* f_name and l_name are guaranteed to be the only elements of 
array $session *and* they're in the needed order, you could do:

$fullname=implode(" ", $session);

But that requires the proper foreknowledge.  Simple concatenation, like 
above, is the safer bet.

-- 
CC

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




Re: [PHP] extending class then calling its original function

2002-08-01 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jason Wong) wrote:

> On Wednesday 31 July 2002 18:36, lallous wrote:
> > Hello when I extended a class and overwrite a function, can i after
> > overwriting that function call it so it does what it used to do?
> >
> > for example in Delphi I say:
> >
> > procedure TMyExtendedClass.Proc1;
> > begin
> > // do new stuff here
> > inherited; // calls the TMyClass.Proc1;
> > end;
> 
> Yes.

$answer.="http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php";;

-- 
CC

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




Re: [PHP] include hassle

2002-08-02 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Lallous) wrote:

> how can i programmatically set the include path?

http://php.net/ini-set

-- 
CC

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




[PHP] Re: Include php code as variable

2002-08-03 Thread CC Zona

In article <00d501c23ada$87050590$3404a8c0@alawi>,
 [EMAIL PROTECTED] (Alawi) wrote:

> How can I Include my php code code as variable and excute it ? 

include() can return a value, assignable to a variable.  Some other ways to 
get the content of a file (I assume that's why you're saying "include") 
into a variable: file(), fread().

eval() can execute the value of a variable as PHP code.

http://php.net/include
http://php.net/file
http://php.net/fread
http://php.net/eval

-- 
CC

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




[PHP] Re: flaking out on foreach

2002-08-27 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Robert McPeak) wrote:

> Why is this code:
> 
>
>   $bob=array(1,2,3,5,6);
>   
>   foreach($bob as $foo);
>   {
>   echo "$foo";
>   }
>   ?>
> 
> Rendering only "6".  That's it.  Just "6".  What am I missing here?

What do you see in the HTML source view?

-- 
CC

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




Re: [PHP] register_global variables on Mac OS X

2002-10-08 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jule Slootbeek) wrote:

> Yeah that's the path to where php.ini should be (/usr/local/lib, in my 
> case, but the Jaguar version of PHP doesn't use a php.ini file, so 
> there's nothing there.

Jaguar uses php.ini if it's in the expected location.  That you don't have 
one yet is a matter easily resolved.

You can use an ASCII text editor (BBEdit Lite, for instance 
) to create 
a new document and fill it with your favorite options.

Or do as others have recommended and download a prewritten one from php.net 
and place it in the designated location (renamed to "php.ini" if necessary).

Or see the configuration page  for 
descriptions of other alternatives (ini_set(), .htaccess).

-- 
CC

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




[PHP] Re: Regular Expressions Help

2002-06-05 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (J. Younker) 
wrote:

> Hi,
> I'm trying to use eregi_replace to check a user-submitted URL, but I
> keep getting the following error message:
> Warning: Invalid range end in /var/www/html/_db_db/db_input.php
> This what I'm using:
> $pattern = "(http://)?([^[:space:]]+)([[:alnum:]\.-_?/&=])";

You've already gotten a working substitute using the superior preg_replace 
function, but FWIW: the "invalid range" was caused by a misplaced hyphen.  
In the middle of a character class, it delimits a range; to use it as a 
literal, make it the last character in the character class.

-- 
CC

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




[PHP] Re: preg_replace

2002-06-16 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Gerard Samuel) 
wrote:

> When you think you got it, you don't get it..
> Im trying to scan the link for =A-Z0-9_=, dump the '=' and evaluate the 
> remainder as a defined constant.
> Yes its funny looking, but if I could get this going Im golden.
> $bar is always returned with '=_L_OL_HERE=' as the link and not 'here' 
> as it supposed to be.
> Any help would be appreciated.
> Thanks
> 
> 
>  define('_L_OL_HERE', 'here');
> $foo = '=_L_OL_HERE=';
> $bar = preg_replace('/(=)([A-Z0-9_])(=)/e', ' . constant("$2") . ', $foo);
> 
> echo $bar;
> 
> ?>

You're trying to match one or more characters in the class, so add a "+".  
And you're not concatenating the expression 'constant("$2")' with anything, 
so lose the extra periods.  Parentheses aren't needed around the equals 
signs, so you might as well drop those too.  Ex:

preg_replace('/=([A-Z0-9_]+)=/e', 'constant("$1")', $foo);

-- 
CC

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




[PHP] Re: translate perl unpack to php equivalent

2002-06-16 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Danny Kruitbosch) wrote:

> How would I translate this perl unpack statement to the php equiv.
> 
> my ($salt, $xor) = unpack('a2 a*', $something)

http://php.net/unpack

-- 
CC

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




[PHP] Re: Is this a BUG?

2002-06-23 Thread CC Zona

In article <000c01c21b02$4b69e1b0$1aed0dd1@gateway>,
 [EMAIL PROTECTED] (César aracena) wrote:

>  I have a mainusers.php page, which only calls for functions
> instead of writing them all together inside that page. At one step, it
> calls for an “adduser” function which brings a table that let the
> administrator insert a new user. After the submit button is pressed, it
> calls for a function called “useradded” which resides in the same
> library as the “adduser” function. This useradded function queries the
> database, inserting the user. The problem is that it does not get the
> HTTP POST VARS although they are being passed according to phpinfo.php.

Without an example to look at, I may be mis-understanding your situation.  
But it sounds like this may be a scoping issue: trying to use a global 
($HTTP_POST_VARS) within a function without using the special "global" 
keyword. 

This won't work:

function adduser()
   {
   echo "LOCAL SCOPE: " . $HTTP_POST_VARS['user'];
   }
adduser();

This will:

function adduser()
   {
   global $HTTP_POST_VARS['user'];
   echo "GLOBAL SCOPE: " . $HTTP_POST_VARS['user'];
   }
adduser();

If this is the problem you're having, you can find more information at:

http://php.net/variables.scope
http://php.net/global

-- 
CC

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




[PHP] Re: How to put these 2 IF statements into 1, with regex?

2002-06-30 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
wrote:

> I was wondering if there is anyway to combine these two IF statements 
> into one:
> 
> if (preg_match("@siteUserList.cgi?group=site177@", $QUERY_STRING))  
> 
> and:
> 
> if (preg_match("@siteUserList.cgi?group=site177&@", $QUERY_STRING))

Remember that preg_* functions aren't equivalent to str_*; you're matching 
against a regex pattern now, not just a simple text string.  So you must 
first escape any regex special characters within your text string if you 
want reliable results.  Otherwise, you're going to eventually end up with 
unintended matches like "siteUserList9cggroup=site177&".

Regarding the rest of your question: the "?" character is what you seek.

if (preg_match("/siteUserList\.cgi\?group=site177&?/", $QUERY_STRING))

-- 
CC

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




[PHP] Re: PHP with CSS

2002-06-30 Thread CC Zona

In article <001101c220b8$5338fc30$768c3841@c3>,
 [EMAIL PROTECTED] (Bruce Karstedt) wrote:

> Quick question?
> 
> Is their anything in Apache or PHP that would keep styles from working. Both
> external (CSS) and inline styles are ignored.

If it was the only the external stylesheet that wasn't working, the first 
thing to do would be to check that Apache is configured to the right 
content type (text/css) for it and that the PHP code isn't doing anything 
silly like sending the dynamically-generating the *.css page with a 
header() declaring a different content type; but with the inline styles 
also not working, that scenario would either be unlikely or only part of 
the story.

Have the HTML and CSS both been validated yet?  If the output of your PHP 
includes syntactically-flawed HTML, that could lead to problems with the 
CSS rendering as well.  And of course, invalid CSS will not render as 
expected.  This final thought may already be obvious to you, but is there 
any chance that the styles you're using are either not supported by your 
browser, or that your page's doctype has accidentally triggered the 
browser's less-forgiving "standards mode"? (If any of this sounds 
unfamiliar, you can follow-up with a newsgroup or list where CSS is 
on-topic, such as .)

Good luck!

-- 
CC

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




[PHP] Re: preg_match or not?

2002-07-06 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Steve Fitzgerald) wrote:

> I have been struggling for a couple of hours now trying to write a
> preg_match expression to validate a dollar amount - the user may or may
> not put in the decimals so I want to allow only digits plus a possible
> period followed by two more digits. My eyes are now swimming and I just
> can't seem to get right. This is what I have at the moment:
> 
> if (!preg_match("/[\d]+([\.]{1}[\d]{2})?/", $form_data[amount])) //
> wrong amount
> 
> but it still allows invalid input. Can anyone help or is there a better
> way to do it?

It sounds like you need an exact match; note that your regex is matching 
against substrings, thus additional invalid characters are allowed to pass. 
Anchor the pattern, so that it essentially says "From beginning to end, the 
only chars allowed are one or more digits, optionally followed by the 
combination of a period then two more digits."  (The "^" and "$" special 
chars are anchors.)

A regex special character loses it "specialness" when it's either escaped 
with a backslash, or included within a square-bracketed character class; 
you don't need to do both.

The {1} is implied; you don't need it.

if (preg_match("/^\d+(\.\d{2})?$/", $form_data[amount]))
   {echo "Validated!";}
else
  {exit("That's not a dollar amount.");}

-- 
CC

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




[PHP] Re: Does not work

2002-07-14 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Saci) wrote:

> I tried this simple code
> 
> 
> 
> Page refered by
>  echo $HTTP_REFERER.'';
> echo $_SERVER['HTTP_REFERER'].'';
> ?>
> 
> 
> 
> and I receive blank reply even if referenced from a link from other site.
> 
> What am i doing wrong ? Or perhaps my server does not have referer enabled?

It's possible that your *browser* does not pass referer information.  But 
keep in mind that if there was no referring page, then there is no referer 
value for the browser to set.  Try this instead:




Page refered by
';
echo $_SERVER['HTTP_REFERER'].'';
?>
http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Regular expression for correcting proper nouns

2002-07-17 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Henry) wrote:

> I'm looking for a simple was to correct a list of proper nouns given all in
> lower case!
> 
> For example
> 
> given $string="london paris rome";
> 
> I would like "London Paris Rome".
> 
> However there is one cavet; if the word already has a captital anywhere in
> it, it should be left alone!!!
> 
> Is there a soultion using regular expressions?

Yes.  The topics you'll want to look at (in the PCRE chapter of the manual) 
are: case-sensitivity, character classes, capturing subpatterns, and the 
documentation for preg_replace_callback().  One of the things you'll need 
to do is define for yourself what constitutes a "word" for your purposes.  
Does a single letter word get counted as a "word" (i.e. "i")?  Is there any 
non-alphabet character that can validly appear within the thing you call a 
word (i.e. "hi-fi", "mst3k")?  This is why there's no single ready-made 
solution.

> Also is there one for removing multiple spaces?
> 
> i..e given "A   B C D E" it would give "A B C D E".

Yes.  Again, character classes will be your friend, as will preg_replace().  
Just decide which of the whitespace characters you mean to include in that 
definition of "multiple spaces"...

-- 
CC

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




[PHP] Re: preg_replace_callback

2002-07-17 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Rafael Fernandes) wrote:

> First, sorry for my elementary english...
> I need a function made for PHP3 that works like preg_replace_callback...

Before preg_replace_callback() was introduced, preg_replace() used to have 
another an "f" modifier which had similar functionality.  I'm not sure 
whether that modifier was available back in PHP3, but here's the relevant 
quote about "f" from an old set of PCRE Syntax docs:

> F
> If this modifier is set, preg_replace() treats the replacement parameter as a 
> function name that should be called to provide the replacement string. The 
> function is passed an array of matched elements in the subject string. NOTE: 
> this modifier cannot be used along with /e modifier; and only preg_replace() 
> recognizes this modifier.

If I recall correctly (which I may not), an example would look something 
like this:

$output=preg_replace("/(\w+)/f","'***' . strtolower($1) . '***'",$input);

-- 
CC

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




[PHP] Re: mod_rewrite problem

2002-07-18 Thread CC Zona

In article <003d01c22e58$dcb45240$6601a8c0@yourwrjlo8t8dt>,
 [EMAIL PROTECTED] (Adrian Murphy) wrote:

> the following code redirects www.usersite.mysite.biz  to 
> www.mysite.biz/users/sites/usersite
> 
> the problem is when the 'www' is left out it doesn't work.

> RewriteEngine on
> RewriteCond   %{HTTP HOST} ^www\.[^.]+\.mysite\.biz$
> RewriteRule   ^(.+)%{HTTP HOST}$1  [C]
> RewriteRule   ^www\.([^.]+)\.mysite\.biz(.*) 
> http://www.mysite.biz/users/sites/$1
> RewriteCond   %{HTTP HOST} ^www\.[^.]+\.mysite\.ie$
> RewriteRule   ^(.+)%{HTTP HOST}$1  [C]
> RewriteRule   ^www\.([^.]+)\.mysite\.ie(.*) 
> http://www.mysite.biz/users/sites/$1

Change each of those instances of "^www\." to "^(www\.)?"

-- 
CC

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




[PHP] Session cookies appearing where there is no session

2001-01-15 Thread CC Zona

This must sound pretty far-fetched, but as far as I can tell, my site is 
attempting to set a session cookie from any and all PHP pages, even when 
the page has no calls to session_* functions and where there were also no 
previous visits to pages with such calls.  Where is the setting that is 
initializing these unneccessary sessions and sending the cookies?  I looked 
for something in php.ini or phpinfo() to explain it, but came up empty.  
Below are excerpts from a phpinfo() dump.  

I wondered about that "session.use_trans_sid", but there's no reference to 
it in my php.ini file (yes, I checked that phpinfo says I'm looking at the 
correct one) and I also cannot find anything about it in the PHP.net online 
docs.  What does that setting do, and where is it configured?

TIA

begin excerpts from phpinfo()

Directive   Local Value Master Value
assert.active  1  1
assert.bail 0  0
assert.callback   no value no value
assert.quiet_eval 0  0
assert.warning 1  1
safe_mode_allowed_env_vars PHP_  PHP_
safe_mode_protected_env_vars  LD_LIBRARY_PATH   LD_LIBRARY_PATH
session.use_trans_sid   1  1

session
Session Support   enabled
Directive   Local Value Master Value
session.auto_start   On On
session.cache_expire 60 60
session.cache_limiter   nocache  nocache
session.cookie_domain   no value no value
session.cookie_lifetime 0  0
session.cookie_path  /  /
session.entropy_file no value no value
session.entropy_length  0  0
session.gc_maxlifetime  1800  1800
session.gc_probability  1  1
session.name   SID   SID
session.referer_check   no value no value
session.save_handler files files
session.save_path /tmp  /tmp
session.serialize_handler  php   php
session.use_cookies  On On



HTTP Response Headers
Set-Cookie  SID=0c6a1e4a46c8d9d840ac865d4a9d8e6f; path=/
Expires  Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control  no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0
Pragma   no-cache



-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Session cookies appearing where there is no session

2001-01-15 Thread CC Zona

(responding to myself)

In article <93uoh9$613$[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
(CC Zona) wrote:

> This must sound pretty far-fetched, but as far as I can tell, my site is 
> attempting to set a session cookie from any and all PHP pages, even when 
> the page has no calls to session_* functions and where there were also no 
> previous visits to pages with such calls.  Where is the setting that is 
> initializing these unneccessary sessions and sending the cookies?  I looked 
> for something in php.ini or phpinfo() to explain it, but came up empty.  

It looks like I've finally figured out the answer to this part of my 
question (it's always five minutes after you finally break down and ask for 
help, isn't it? ).  Apparently session.auto_start=1 was the culprit.

I'm still hoping someone can help me with the other question, though:

> I wondered about that "session.use_trans_sid", but there's no reference to 
> it in my php.ini file (yes, I checked that phpinfo says I'm looking at the 
> correct one) and I also cannot find anything about it in the PHP.net online 
> docs.  What does that setting do, and where is it configured?

> session.use_trans_sid   1  1

Thanks again.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] FW: Cookies, Dammit!

2001-01-17 Thread CC Zona

In article <[EMAIL PROTECTED]>, 
[EMAIL PROTECTED] ("Richard S. Crawford") wrote:

> The problem is that the main page doesn't use an include file of any sort;
> it's straight HTML which is frequently updated by hand.  I agree that it
> would be nice if /index.htm had an include file that contained most of the
> content, and if I could convince my boss that it would be the best way to
> go, then I'd be set.  :)  Unfortunately, that's not the route that we've
> chosen to go (in fact, I'm still at the stage where I'm trying to convince
> people around here that PHP is a much better way to go than straight HTML
> for some of these documents).  So, if I were using an include file to build
> /index.htm, then I would use it in microsite45/index.htm.  But since I'm
> not, I can't.  I've got permission to use document.write in /index.htm, so I
> was looking for a solution which would allow /index.htm to remain nothhing
> but static HTML (with the exception of some JavaScript).

Is this on Apache?   I'm wondering if you couldn't 
use an Apache  directive to turn on PHP's auto-append feature for 
that one page.  Then the people who need to tinker with the HTML could do 
so freely without the possiblity of messing with the include; in fact, 
they'd never have to know about the include file's existance, it'd just 
happened "automagically" as far as they (and the boss) are concerned.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] db backup script needed

2001-01-18 Thread CC Zona

In article , 
[EMAIL PROTECTED] (Maxim Maletsky) wrote:

> anyway, is there any script like that (fast and dirty is ok) to run on
> MySQL, PHP4.0.2 ?

What about putting a mysqldump call into a crontab?

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Ethics question...

2001-01-18 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
(Frank Joerdens) wrote:

> > > But why would Microsoft be using PHP? =D
> > 
> > Why would Microsoft be using Solaris, or Linux even?  (hint, the same
> > reason -- their stuff works less good).
> 
> Do you know for a fact that they do? If so, how? That'd be a very cool
> tidbit of information to share . . .

In the Macromedia Dreamweaver newsgroup, there's always someone spotting 
some more pages from the microsoft.com site which were written in DW 
instead of FrontPage or InterDev.  Not quite the same factoid as you were 
seeking, but it does show that not everything with a shiny M$ logo on it is 
necessarily built with M$ products.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Help w/ regular expressions for banned words

2001-01-20 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
(Team JUMP) wrote:

>$num=count($bannedwords);
> for($i=0;$i<$num-1;$i++)
> {
> $string =
> eregi_replace("\b$bannedwords[$i]\b","[censored]",$string);
> }
> 
> 
> For whatever reason, no word in $bannedwords will match in the string.  I've
> tested it with simple expressions like "\btest\b" and it will not match the
> word "test". 

Have you tried it with either "[:space:]$bannedwords[$i][:space:] or 
"\<$bannedwords[$i]\>" yet?  Also, I think using a foreach($bannedwords as 
$current_word) would be a better choice here; more compact, and loops all 
the way to the end of the array even when the numerical index does not 
follow the expected sequence.  (BTW, if you want to stick with the for() 
and you know the index numbers will always be sequentially zero to 
whatever, then your test should be just $i<$num.  Otherwise, you're 
skipping the final loop.)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] " " charactor problem

2001-01-21 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Rick 
Ridgeway) wrote:

> > > I grab this line and try to make it an array like this:
> > print "line: $thelinefromfile\n";   //Check the line
> > > $var1 = trim($thelinefromfile);
> > > $var2 = split(" ", $thelinefromfile);
> > > $count = count($var2);
> >
> > Are you sure $thelinefromfile is actually being set correctly?
> >
> > Regards,
> >
> > Sean
> 
> Yes
> I print it out it says "Array"
> so i then do
> print $thelinefromfile[0];
> and it prints out the whole line instead of the first field from the
> line...

You're print()ing in the order shown above, right?  Print() then trim() 
then split()?  Because that sounds like you're attempting to do a "split()" 
on an array.  That function is for turning a string into an array; if it's 
already an array, then just get rid of the split() and do your count() on 
$thelinefromfile.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Need key() equivalent for string variable

2001-01-22 Thread CC Zona

I'm trying to pass a string variable to a custom function, echoing its 
*value on one line, and its *name (that is, its key if this were an array 
instead of a string) on another line. I searched the manual's sections on 
variable functions and string functions, to no avail.  I tried key(), but 
it just produces a warning that $var is not an array.  Example:

build_select_menu($display,array("Y","N")); 

function build_select_menu($field,$options_array)
   {
   echo '' . "\n";  //need to echo 
name of string passed as first argument

   foreach($options_array as $option)
  {
  echo '$option\n";
  }
   echo  "\n";
   }

Thanks!

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Need key() equivalent for string variable

2001-01-22 Thread CC Zona

In article <069f01c084ca$1642a320$[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
("Richard Lynch") wrote:

> > I'm trying to pass a string variable to a custom function, echoing its
> > *value on one line, and its *name (that is, its key if this were an array
> 
> I think you are looking for "variable variables"...

A variable variable results in a second variable which is named for the 
*value of the first.  So what I need is a sort of "inverse variable 
variable" to extract the *name of the first variable:

$foo="bar"
echo $foo   //"bar"
echo [something] //"foo"

I ended up doing a clumsy workaround by altering $foo--

$foo="bar"
$foo=array("foo"=>$foo)
echo $foo[key($foo)];  //"bar"
echo key($foo); //"foo"

--but then I'm having to tell PHP the very info that I was hoping it'd 
dynamically tell me. Any other suggestions would be much appreciated!

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] check null value

2001-01-23 Thread CC Zona

In article <019301c08581$e9504080$6400a8c0@alsmpdc>, 
[EMAIL PROTECTED] ("Jacky@lilst") wrote:

> If I have one input text box that when it is submitted to next page, I want 
> to check first if it is nothing, then write "na" on next page, else just 
> echo whatever it is, is it correct to do this?
> 
> if (empty($fieldname)){
> $fieldname ="na";
> }

You might also want to throw in a check for !isset($fieldname), either 
before the check for empty() or concurrent with it.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] error with REPLACE or UPDATE

2001-01-24 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote:



>   $connect = mysql_connect(xx); or die ("dBase not connect.")
 

>   $sql = "REPLACE CLIENT SET ID = \"$id\", ITEM = \"$item\", TITLE 
> =\"$title\", AUTHOR = \"$author\", PUBLISHER = \"$publisher\", DELIVERY
> = \"$delivery\", QTY = qty\", PRICE = \"$price\", TOTAL_PRICE = 
> \"$total_price\", DATE = \"$date\", RECORD\"$record\" WHERE RECORD = 
> \"$record\"";

Check the manual at mysql.com for the "REPLACE" syntax.  It's used like 
"INSERT", not "UPDATE".

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] --with-mysql, yet mysql_errno() is "undefined"?

2001-01-24 Thread CC Zona

I use mysql_* functions all the time, PHP was definitely compiled 
--with-mysql, yet for some reason I'm getting "Fatal error:  Call to 
undefined function:  mysql_errorno()" for this one mysql function.  Ex.:

mysql_query($query,$connect);  //echo of $query is successful at 
commandline, and $connect works for other queries on same page
if(mysql_errorno($connect)==1062)   //returns "fatal error"
 {
 $query_status="SKIPPED";
 break;
 }  

Is this normal?  Does PHP need to be compiled with some extra setting to 
support this function?  The manual says this is supported in PHP3 & PHP 4 
function, so I wasn't expecting to have a problem using it with PHP 
4.0.3pl1.  (MySQL is v.3.23.28-gamma; server is Apache 1.3.12)

PHP configured with:'./configure' '--with-gd' '--enable-track-vars' 
'--with-apxs=/usr/sbin/apxs' '--enable-sysvsem' '--enable-sysvshm' 
'--with-zlib' '--prefix=/usr' '--with-config-file-path=/etc/httpd/conf' 
'--enable-memory-limit' '--with-pgsql=/usr' '--with-db2=/usr' 
'--with-gdbm=/usr' '--with-ndbm=/usr' '--with-dbase' '--enable-trans-sid' 
'--with-xml=/usr' '--enable-debugger' '--enable-ftp' '--with-ttf' 
'--with-jpeg-dir=/usr' '--enable-bcmath' '--enable-trans-sid' 
'--with-mysql=/usr' '--with-xpm-dir=/usr/X11R6' '--with-png-dir=/usr' 
'--with-imap' '--with-dom' '--with-imap-ssl' '--with-mhash=/usr' 
'--with-mcrypt=/usr'

This one really has me stumped.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Genuine Opportunity

2001-01-25 Thread CC Zona

In article <[EMAIL PROTECTED]>, 
[EMAIL PROTECTED] (Ernest E Vogelsinger) wrote:

> Hi Postmaster,
> 
> how about letting onl people post to the list who are subscribed to?

For some of us (who don't abuse the list by posting spam), the news 
interface to such a busy list is a godsend.  Forcing everyone to subscribe 
would only penalize many legitimate readers/posters while presenting little 
real obstacle to the spammers.  Similar garbage has appeared on every 
mailing list I've ever been on.  Even the moderated ones let ones slip 
through from time-to-time.  There must be a more effective solution.  Does 
Ezmlm support some form of spam-filtering, perhaps?

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] file handle error? or something else?

2001-02-24 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("rick - SomersNet, Inc.") wrote:

>  $sp=fsockopen($host,80) or brake;
>  socket_set_timeout($sp, 600) or brake;
>  fputs($sp,"GET $filename HTTP/1.1\n") or brake;

Hmm.  What's that 'or brake' stuff?  'brake' is used as a constant, but you 
don't show what it's defined as.  I assume what you're going for is an 'or 
die()' function call...?

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] extract() help

2001-02-24 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jaxon) wrote:

> the following function is supposed to build an html table, creating a
> content row for every row in a database table.  It is creating a table with
> the correct number of rows, but NO content is being echoed...

> $sql="select i.nID, i.date, i.headline, i.subtitle, i.blurb from
> news_items i, news_box b where i.nID = b.nID and b.dID = $i";
> 
> $result = mysql_query($sql, $link_id);
> $row = mysql_fetch_row($result);
> 
> extract($row); //the variables below match field names in this row
> 
> echo "
> $headline
> $subtitle
> $date
> $blurb
> ...more

The elements in $row will have indexes like $row['i.headline'], rather than 
$row['headline'], just as the columns would have those names if you ran the 
query at the command line.

(BTW, I find that doing a var_dump() or print_r() on variables--such as 
$row, in this case--to be very helpful when data isn't coming out in the 
way I expected it to...)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Unwanted Characters

2001-02-24 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Joe Stump) wrote:

> Look at the chr() function - figure out what the character is (number wise) 
> and
> then do an ereg_replace(chr(),'',$string) (from the hip - you can do a 
> replace
> with chr() on one of the replaces, I've done it before)
> 
> --Joe
> 
> On Sun, Feb 25, 2001 at 12:34:21AM -0500, Clayton Dukes wrote:
> > 
> > How do I remove unwanted/unprintable characters from a variable?
> > 
> > $sometext = "ThÀe cØar röøan over mÖy dog"
> > needs to be filtered and reprinted as:
> > "The car ran over my dog"

And you might also want to look at strtr() 
.  You could, I suppose, use 
it to substitute some character that you know would never legitimately 
appear in $sometext, then do a straight str_replace() on the string for all 
occurences of that character.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Join causing Error?

2001-02-25 Thread CC Zona

In article <030601c09f05$2b9e6e70$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Keith Spiller") wrote:

> Can anyone tell me why this:
>   Line 282mysql select db("centraldb",$db);
>   Line 283$qorder++; 
>   Line 284$result = mysql query("SELECT q.questid, q.question, q.answer, 
>   q.qorder, q.depart, q.catid, 
>   q.active, q.global, q.adate, q.author, q.authoremail, 
>   q.askemail, c.catid, c.category, c.under, 
>   c.corder, c.active FROM central groupfaqq q, central 
>   groupfaqcat c WHERE q.active = '1' AND 
>   q.global = '1' AND c.active = '1' ORDER BY c.under, 
>   c.order, q.qorder",$db);
>   Line 285while ($myrow = mysql fetch row($result))
> 
> Would cause this error:
>   Warning: Supplied argument is not a valid MySQL result resource in 
>   faqbody.php3 on line 285
> 
> When changing the same SELECT statement to:
>   Line 284$result = mysql query("SELECT * FROM central groupfaqq WHERE 
>   active = '1' ORDER BY
>qorder",$db);
> 
> Works perfectly?

Sounds like the 'while' loop is failing because mysql_query isn't returning 
to $result what you think it is.  Add some error-checking, starting with at 
least an "or die(mysql_error())" on the query.  Also, try running the same 
query at the command line to confirm that it's valid.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] so what program?

2001-02-25 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Knasen) wrote:

> What I found out in my first mail to the list was..quit working with
> filmaker =). Sure, I can do that. But the question remains..what program
> WILL a macuser use to forfill the needs in MySQL/PHP?

Don't quit working with filemaker entirely.  It has many advantages, such 
being great for quick prototyping.  Just don't waste time trying to use FM 
as a web backend, 'cuz that gets ugly quick.  A Mac user can fulfill that 
need with MySQL/PHP  (or PostgresSQL/PHP) just fine.  I know of at least 
two options for doing this:

1) OS X
2) using one of the Linux distros for Mac (ex. LinuxPPC, YellowDogLinux, 
SuSe)

Both options are very cheap to try, and offer slightly different 
advantages, so no harm in trying out both.  Plan on setting aside 1GB or so 
for a Linux partition, for which you get a dual-boot Mac--giving you all 
the advantages of Mac PLUS all the advantages of Linux in one box.  Not 
bad, eh?

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to wrap output of formatted text

2001-02-27 Thread CC Zona

In article <05d201c0a069$4877e0c0$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Clayton Dukes") wrote:

> $row = mysql fetch array($sth);
> 
>   if ($row[0] != "") {
>   echo $row[0];
> 
> prints the data, but some of the results are long strings of text that don't 
> wrap in the browser, how can I force them to wrap at the edge of the browser?

You already discovered the wordwrap() solution.  The html solution looks 
like this:

if ($row[0] != "") {
 echo "$row[0]";

Cheers!

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Caller's __LINE__

2001-02-28 Thread CC Zona

In article <97ifmk$p85$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("elias") wrote:

>   function debuginfo($msg)
>  {
>   echo"the message is $msg, at line" . __LINE__ . " ";
>  }
> 
> in my code:
>  line 1
>  line 2
>  line x: debuginfo("hello!!!");
> 
> is there is anyway to show the caller's line number? in this case 'x' ?

Pass __LINE__ to the function as one of its arguments:

 function debuginfo($msg, __LINE__)
  {
   echo"the message is $msg, at line" . __LINE__ . " ";
  }

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] checking for a defined function

2001-02-28 Thread CC Zona

In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Eric Peters) wrote:

> how can I do something like
> 
> if(!defined(cybercash_encr())) dl("cybercash.so");
> 
> anyone know of a good way to see if a function/module has been included in
> php?

function_exists()

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Pluralize a word for searching a database

2001-02-28 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (richard merit) wrote:

> I don't think you can since the plural form of English
> words can vary, woman, women, families, family, foot,
> feet, church, churches, sheep, sheep, road, roads...
> 
> ?
> 
> rm
> 
> --- "Robert V. Zwink" <[EMAIL PROTECTED]> wrote:
> > Has anyone every written a function in php to
> > pluralize an english word,
> > particularly when searching a database?
> > 
> > function pluralize($word){
> > return array of pluralized words;
> > }

Maybe by posting a lookup to an online dictionary, and parsing out the 
returned definition for the plural wordform...?

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] multiple query in 1 select ?

2001-02-28 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jack Sasportas) wrote:

> lets say we have a database with the State Names and cities, and I
> wanted to select all the cities in FL I would execute something like
> this
> mysql_query("SELECT * FROM cities WHERE state='FL'");
> and lets say there are 50 records returned
> 
> I want to be able to get all the cities in FL & GA instead of just FL
> and display the results together as if it was 1 restult.  Then the resul
> would be 100 records ( 50 FL & 50 GA ).
> 
> Thanks!
> 
> I did look on php.net and in a php book I have, but could not find
> anything...

The reason you couldn't find you answer in a PHP reference is that it's 
really a SQL question you're asking.  Any basic SQL reference should help.  
In answer to your question: a where clause can have multiple conditions 
such as "WHERE state='FL' or state='GA'", which means if a record matches 
either of the two possible conditions, then that record will be displayed.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Need Function generating integers

2001-03-01 Thread CC Zona

In article ,
 [EMAIL PROTECTED] ("M. A. Ould-Beddi") wrote:

> I need a sequence of small integers for primary
> keys in mysql tables; I want php to generate them.
> How can I do that?

A sequence of integers for the primary of a table in a mysql database  
Mind if I ask why you don't want to use let mysql do that by assigning 
"auto_increment" to the field?

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] The neverending Session

2001-03-01 Thread CC Zona

In article <01030114311802.11459@kilbourne>,
 [EMAIL PROTECTED] ("Sean B.") wrote:

> I'm working on a chat of sorts, and in the main frame that shows the actual 
> messages, there is an infinite loop (while(1)) ... now, for whatever reason, 
> when the browser is closed, the loop/thread/whatever just won't die. There 
> are sessions involved, and the loop basically just checks a MySQL DB for new 
> posts, and updates a timestamp in a user database. Any idea of why the 
> loop/thread/whatever won't die?

PHP is server-side.  It doesn't know anything about a (client-side) browser 
window being closed.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] HREFs that can't be

2001-03-01 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Boget, Chris") wrote:

> Here
> There
> This Place
> That Place
> 
> ---
> 
> As you know, those variables are being passed to the
> linked page via GET variables.  Now, here comes the
> oddball question:
> 
> How can I (is it even possible) pass those variables
> to each page w/o using GETs and w/o using Cookies.

POST.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] HREFs that can't be

2001-03-01 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Boget, Chris") wrote:

> Also, how would I set the (previously GET) vars up as session
> variables?  I'd have to post to yet another script which
> would set the session variables and in turn SUBMIT (with just
> the SESSID this time) to the actual page (remember, I can no
> longer use any GET variables so the header() function would
> be out) that is the final destination...

Just include the SID as a hidden input.  It'll be POSTED to the next page 
right along with your other variables.  There's even a way to configure 
your php.ini file so that PHP includes the hidden SID for you.  I forget 
which setting it is--maybe "trans-id" or something like that...?  Poke 
around in the the "configuration" chapter of the manual; it's in there.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] HREFs that can't be

2001-03-02 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] wrote:

> > > Also, how would I set the (previously GET) vars up as session
> > > variables?  I'd have to post to yet another script which
> > > would set the session variables and in turn SUBMIT (with just
> > > the SESSID this time) to the actual page (remember, I can no
> > > longer use any GET variables so the header() function would
> > > be out) that is the final destination...
> >   
> > Just include the SID as a hidden input.  It'll be POSTED to the next page 
> > right along with your other variables.  There's even a way to configure 
> > your php.ini file so that PHP includes the hidden SID for you.  I forget 
> > which setting it is--maybe "trans-id" or something like that...?  Poke 
> > around in the the "configuration" chapter of the manual; it's in there.
> 
> 
> That won't work.  Clicking on a link does not trigger sending of fields
> (hidden or not).
> 
> 
> There are only three places you can pass data without using forms, and
> using buttons, or images to trigger a POST of the data.

Did you read his previous comments?  He *is planning to pass the info in a 
form, one for each link...

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple question!!!

2001-03-02 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Ricardo D'Aguiar) wrote:

> Imagine the following script:
> 
> 
> Some Title
> 
>  $var = 1;
> if ($var == 1) {
> die ("I'm dead");
> }
> echo "I'm alive";
> ?>
> 
> 
> 
> If I try to execute via Internet Explorer ("5.x") apparently every thing
> works fine.
> It shows the string "I'm dead".
> 
> But if I use the Netscape 4.7x, I get a blank screen.
> When I view the Source Code ("HTML code in Netscape") it shows:
> 
> 
> Some Title
> 
> I'm dead
> 
> Netscape can't render the page if its missing the  and 
> tags in the end.
> I already used 'return' end 'exit' functions but with the same result.
> 
> There is some configuration parameter to the PHP server to send the rest
> of HTML code after exit the script or workaround?

Is it an option to just move the code below the  tag?  Another 
option would be to echo the closing tags from within the conditional, prior 
to calling the die().  I believe output buffering can also be used to 
achieve what you want, but someone else will have to explain how (whether?) 
that can be done here.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Extract() with 2D array

2001-03-03 Thread CC Zona

Does extract() work on multidimensional arrays?  IOW, I have an array 
like...

array($elem1=>array($val1,$val2),$elem2=>$val3)

...from which I'd like to extract $elem1 and $elem2.  Should this be 
possible with extract()?  The docs just say the function takes an array as 
a parameter, but don't specify whether or not the array can have more than 
one dimension.  Since I'm having trouble making this work, I have a feeling 
the answer is no, but wanted to double-check in case it's actually my code 
that's at fault.

TIA!

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Inserting DATE in mySQL!!

2001-03-05 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Thomas Edison Jr.") wrote:

> I'm using the following code to insert date into my
> mySQL table named "Booking". I've created variables
> that store the date with dashes "-" seperating them. 
> But it's not working. It's giving me an error on the
> $SQl line. 
> 
> following is the code :
> 
>  $db = mysql_connect("localhost","root");
> mysql_select_db("motorola",$db);
> $realsdate="$syear"."-"."$smonth"."-"."$stdate";
> $realedate="$eyear"."-"."$emonth"."-"."$endate";
> $realstime="$shh".":"."$smm"."-"."$sttime";
> $realetime="$ehh".":"."$emm"."-"."$entime";
> $sql = INSERT INTO booking
> (room,sdate,edate,stime,etime,purpose,reserved) VALUES
> ('$rooms','$realsdate','$realedate','$realstime','$realetime','$purpose','$res
> ');
> $result = mysql_query($sql) or Die ("An unexpected
> error occured. Please go back and book again.");
> ?>

Your value for the variable "sql" isn't enclosed in quotes.  BTW, tracking 
down problems with a sql query gets easier when you give yourself a more 
informative die() message, such as:

or die ("MySQL says: " . mysql_errorno() . " " . mysql_error() . "\nPHP 
says: $errormsg");

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] help functions

2001-03-05 Thread CC Zona

In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Montgomery-Recht, Evan") wrote:

> Has anyone spent any time and thought into including help within the
> library, ie. so you could do a.
> 
> mysql.connect().help() or something like that so as a developer addeds a new
> function we as end users might be able to understand the function.  Most
> likely by creating a help file to return to the browser because right now
> I'm finding a lot of undocumentented features.

But at the point where a function would be sufficently documented to have 
this built-in help file, wouldn't the same information be readily available 
in the online manual?

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Inserting DATE in mySQL!!

2001-03-05 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Hardy Merrill) wrote:

> > or die ("MySQL says: " . mysql_errorno() . " " . mysql_error() . "\nPHP 
>  ^
> 
> Just a technicality, but I think I remember this to be
> mysql_errno().  But CC is right - in your "die", give yourself
> as much info about the error as possible.

Oops, you're right about the typo.  Sorry about that.  It's *very late at 
night here. 

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Quick Regex Question

2001-03-05 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Jeff Oien") wrote:

> if (preg_match("/[a-Z],[a-Z]/",$text)) {
> 
> Can you tell me where I'm failing here. I want to do something
> if the string has commas in between words with no spaces. 
> Like:
> 
> blah,blah,blah

"Does it have *any instance where a string of letters is separated only by 
a comma?" preg_match("/[a-z]+,[a-z]+/i",$text)

"Does it consist *entirely of strings of letters separated only by comma?" 
preg_match("/^[a-z]+,[a-z]+$/i",$text)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Still an Almost working Regex

2001-03-06 Thread CC Zona

In article <002d01c0a69a$ea2c9aa0$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Murray Shields") wrote:

> $Status = (ereg("^(^[A-Za-z0-9` !@#$%&()=:;\"\'.?/^|{}-]*)(.*)$", $String,
> $List));
> 
> It is definitely working as expected.
> 
> I need to add the square brackets [ ] to the above list of allowed
> characters.

According to the manual ,

"These functions all take a regular expression string as their first 
argument. PHP uses the POSIX extended regular expressions as defined by 
POSIX 1003.2. For a full description of POSIX regular expressions see the 
regex man pages included in the regex directory in the PHP distribution. 
It's in manpage format, so you'll want to do something along the lines of 
man /usr/local/src/regex/regex.7 in order to read it. "

If you do not have access to manpages at the commandline, note that they 
are also widely republished on the web.  A quick search on 
 reveals:

"A bracket expression is a list of characters enclosed in `[ ]'. It 
normally matches any single character from the list (but see below). If the 
list begins with `^', it matches any single character (but see below) not 
from the rest of the list."


"To include a literal `]' in the list, make it the first character 
(following a possible `^')."

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] removing and item out of a string

2001-03-06 Thread CC Zona

In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Brian C. Doyle") wrote:

> I need to remove a comma from inside of 2 quotes ie "1,234.56" I need to 
> change that to "1234.56"
> Unfortunatly I can not do reg_replace(",","","1,234.56");

Possibly because the function is called ereg_replace() ...  

But since you're not doing any special pattern matching, you might as well 
use a simple str_replace(',','','1,234.56') instead.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] HELP with Multi Dimensional Array Problem

2001-03-08 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Yev) wrote:

> So, it sees $name="field[text][email]", and attempts to retrieve the
> value, so in essense $HTTP_GET_VARS[$name] should return
> "[EMAIL PROTECTED]", but it doesn't work..  
> However, if i try to access $HTTP_GET_VARS[field][text][email] that
> properly returns "[EMAIL PROTECTED]".

The reason "it doesn't work" is because these are not the same reference. 
$HTTP_GET_VARS[$name] expands to:

$HTTP_GET_VARS[field[text][email]]

Which, as you can see, is not the same as:

$HTTP_GET_VARS[field][text][email]

Since you're apparently trying to access the data submitted in

> 
> http://www.email.com">

How about using something like:

extract($HTTP_GET_VARS['field']['text']); //note that index names are quoted
echo $email;
echo $url;

?

Otherwise, if you want to stick with the original method, I believe you 
would use something like:

$name="['field']['text']['email']"; //index names quoted, brackets added
echo $HTTP_GET_VARS$name; //brackets dropped

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Error codes from 'mysql_error()'

2001-03-08 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Dennis Gearon) 
wrote:

> I do an insert using phpadmin, and i get back the error message (or
> maybe it's a warning?) The insert is of a duplicate on a unique field. I
> expected an error, but when I do mysql_error() or mysql_errno(), nothing
> comes back(and I do it the next line in the script). the
> 'mysql_query($sql, $link)' function DOES insert when the value is
> unique, DOES return false, but I'd like to inform the user what the
> error was. PHP Admin can get the 'error' why can't I?

Where are the calls placed?  mysql_error() or mysql_errno() can only be 
used after a valid mysql connection has been established, so for instance 
this will not return an error message from mysql:

mysql_connect(stuff) or die(mysql_error());

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Multiple Inserts

2001-03-09 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote:

> $SQLStatement = "INSERT INTO Members (Email) VALUES ('".$GetEmails[$a] ."')" 
> or die ("Problem");
> $db = mysql_select_db($dbase, $connection);
> $SQLResult = mysql_query($SQLStatement);

Whoa, you're mixing apples with oranges.  Try:

$db = mysql_select_db($dbase, $connection);
$SQLStatement = "INSERT INTO Members (Email) VALUES ('" . $GetEmails[$a] . 
"')"; //removed the 'or die' portion
$SQLResult = mysql_query($SQLStatement,$connection) or die ("Problem " . 
mysql_error() ); //moved 'or die' here, using more detailed info

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] search a text file

2001-03-12 Thread CC Zona

In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Peter Benoit) wrote:

> I've got a bit of a task where I need to poll a text file for several lines
> of text which is buried deep within the file.  These lines change each day,
> but the text surrounding them do not.
> 
> Is it possible to extract these lines of information based on the text
> surrounding them?

Sure.  preg_match() would be one way.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] search a text file

2001-03-12 Thread CC Zona

[quotes returned to bottom-posting, for clarity]

In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Peter Benoit) wrote:

> In article 
> <[EMAIL PROTECTED]>,
>  [EMAIL PROTECTED] (Peter Benoit) wrote:
> 
> > I've got a bit of a task where I need to poll a text file for several
> lines
> > of text which is buried deep within the file.  These lines change each
> day,
> > but the text surrounding them do not.
> > 
> > Is it possible to extract these lines of information based on the text
> > surrounding them?
> 
> Sure.  preg_match() would be one way.

> OK, I'm a little new to this, else I would have known that.  Any examples
> out there I could use/modify?  

Probably.  You could check the manual's page on preg_match (the user 
annotations often have very useful code examples), phpbuilder.com, 
hotscripts.com, etc.  A quick, oversimplified example:

Let's say your complete text was (no laughing now ) "Mary had a little 
lamb, its fleece was white as snow." where "Mary had a " and "fleece was 
white as snow." are always consistent but whatever's happens to be the 
portion of the text between them is what you want to extract.  You could do 
something like--

$search_string="Mary had a little lamb, its fleece was white as snow.";
$status=preg_match("/^Mary had a(.*)(?=fleece was white as 
snow.)$/i",$search_string,$match_text);

In which case, $status would evaluate to true if a (case-insensitive) match 
was found, and $match_text[1] would contain " little lamb, its ".

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] In my attempt to read from a text file...

2001-03-12 Thread CC Zona

In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Peter Benoit) wrote:

> I'd like to search inside the text file for my name, then pull all the info
> from that point till the next name which is Fred.
> 
> The text file would be called names.txt
> 
> 
> So I'm trying to 
> 
> preg_match("Peter",names.txt,$myname)
> 
> then do the same for Fred, and grab all the stuff in between.
> 
> Is this the right way to do this?

Nope.  (But see the example in my response to your previous post on the 
same topic.)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] search a text file

2001-03-12 Thread CC Zona

In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Peter Benoit) wrote:

> Very good info, but this text is located in a text file.  How can I
> reference it this way?

Get the contents of the text file--for example, using fopen() with 
fread()--into a variable.  Then use that variable as the second argument to 
preg_match().

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting location bar and stripping file-ending of a string..

2001-03-13 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Aviv Revach) wrote:

> 2. Let's say I have a string such as: 
> "http://www.blabla.com/dir1/dir2/file.php3",
>  How can I can strip the file-ending(".php3") out the string?

Option 1: parse_url()
Option 2: strpos() & str_replace()
Option 3: ereg_replace() or preg_replace()

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Finding existence of a value in a table

2001-03-13 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Dennis Gearon) 
wrote:

> I would like to return ONE ROW if possible from a query that would tell
> me
> whether a value exists in a table. 

If the query could result in more than one record, but you only want to see 
one, 'limit 1' is helpful.

> SELECT FieldValueIn, COUNT(*) FROM TableOfInterest WHERE
> FieldValueIn=ValueOfInterest GROUP BY FieldValueIn;
> 
> I can't seem to figure out how to test the return results to see if
> there is no rows with that value. 

http://www.php.net/mysql-num-rows

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] that whole system() thing again

2001-03-15 Thread CC Zona

[quotes reordered and trimmed]

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Daniel Lynn) 
wrote:

> > > apparently system() and exec() and all tha can't be called from php 
> > > if it is runnig as an apache mod..

>  the person in charge of teh server came to this conclusion for us and 
>  wether he is righ or wrong, we have to face the fact that the exact 
>  same code to make the system call used to work and now doesn't. There 
>  is no error or warning, and it happened right around when we sopped 
>  running php as a cgi script and started running it as an apache mod... 

The new install may be using a different php.ini file, or someone may have 
recently changed a php.ini setting.  There's a new-ish option called 
"disable_functions" which can be used to selectively turn off 
functions--system() and exec() being two of the more obvious targets for 
this.  Call phpinfo() to check whether a global or local setting is 
preventing those functions from running.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Stripping Single Quotes

2001-03-15 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Elan) 
wrote:

> I have a string, "'abc'". How do I convert it to "abc" (i.e. how do I
> strip the embedded single quotes) with a minimum of overhead?

If there's no chance that the string could also contain legit single-quotes 
(such as as an apoostrophe), you can simply use str_replace().

Otherwise, either str_replace() with strpos() -- to search/replace only on 
2nd char and 2nd-to-last character -- or good ol' preg_replace() by itself.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] just wondering ....

2001-03-18 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Peter Houchin") wrote:

> If I have a email script and use the mail() function ... am i able to do
> this ..
> 
> mail(values);
> if ($mail=1){
> do this
> }
> else {
> error
> }

Are you trying to test whether mail() returned true?

if (mail(values)){
do this
}
else {
error
}

(Keeping in mind that when mail() returns true, it's not saying whether the 
mail really reached the destination server, only that it the function 
executed successfully.)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Couple Questions

2001-03-20 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (acleave) 
wrote:

> 1)  How do I return multiple data types at once from a function?  For 
> instance 
> I might want to return 5, "apple", and true (an int, a string, and a boolean) 
> all at once from a function.

return array(5, "apple", TRUE);

> 2)  How does the predefined variable $HTTP_REFERER work with forms?  I know 
> the documentation says that it doesn't work with all browsers as the browser 
> has the actual info but I tested it with IE 5 and NS 4.7 and it worked 
> perfectly (for me).  My real concern is could it be fooled in a simple manner 
> or even turned off by selecting different settings in either of those two 
> browsers?  Or would it require a dedicated cracker and/or someone writing 
> their own browser to give a false report (vs. no report at all)?

IE and NS aren't the only browsers in use today.  I know iCab allows the 
user to disable sending of HTTP_REFERER.  I believe Opera may too.  I'm not 
sure about the capabilities of Konqueror and Lynx in this regard.  Also, 
AFAIK, no browser will send an HTTP_REFERER where the url request was 
typed/pasted in directly by the user, or where the request came via a 
bookmark.  Most of the robots which visit my sites also don't leave an 
HTTP_REFERER.  So there are some common examples of "no report".  

And while I haven't actually tried this, I assume that anyone could write 
their own HTTP_REFERER simply by using fsockopen().  Thanks to PHP's ease 
of use, using fsockopen does not require one to have the skills of a 
"dedicated cracker".

(Relying on HTTP_REFERER for any security-related check is generally 
considered a Bad Idea.)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Couple Questions

2001-03-20 Thread CC Zona

In article <9984hb$c4e$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (CC Zona) wrote:

> And while I haven't actually tried this, I assume that anyone could write 
> their own HTTP_REFERER simply by using fsockopen().  Thanks to PHP's ease 
> of use, using fsockopen does not require one to have the skills of a 
> "dedicated cracker".

Err, obviously I meant fwrite().

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mail() question

2001-03-20 Thread CC Zona

In article <00be01c0b175$1cee4080$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Wade DeWerff") wrote:

> is there a way to do this in a mail() ? I need to add the $Phone and $Email 
> variables too the $message, but I need to format it so that it is on a new 
> line in the emailI tried using  and /n, but it formats as text not 
> code function. 
> 
> 
> $message = $Info ."". $Phone ."". $Email;


"" is used in hypertext markup language (HTML). Email (unless specially 
encoded--MIME headers, ugh!) does not use HTML.

"/n" is a slash followed by the letter n.

"\n" is a newline on *nix system (Unix, Linux, etc.).

"\r\n" is a Wintel linebreak.  It's also the standard for linebreaks within 
emails.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] enum and set possible values

2001-03-20 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Michael George) wrote:

> So if I have an enum with possible values "Yes" and "No" or a set with
> possible values "Single", "Married", "Divorced", "Widowed", I seek a function
> that will return an array of strings containing those possible values.
> 
> Does such a function exist?
> 
> I suppose if not it would be possible to write one from the output of a "show
> columns from X" query...

You do the latter.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Catch timeouts

2001-03-20 Thread CC Zona

I'm resetting set_time_limit() with each iteration of a rather long loop.  
Right now when the script reaches its time limit I sometimes end up getting 
just a blank page.  Even though I call flush() within each iteration and do 
lots of error checking along the way, it seems to not be enough.  

I could have sworn I once saw a function that would check whether the 
script was being cancelled because a timeout had occured, thereby allowing 
you to make a more graceful exit from the script.  But now I can't seem to 
locate anything like that in the manual. If someone could point me to the 
right function, or suggest an alternative method for catching those 
timeouts, I would be grateful.

TIA!

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Catch timeouts

2001-03-20 Thread CC Zona

In article <998dqa$akd$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (CC Zona) wrote:

> I could have sworn I once saw a function that would check whether the 
> script was being cancelled because a timeout had occured, thereby allowing 
> you to make a more graceful exit from the script.  But now I can't seem to 
> locate anything like that in the manual.

Never mind.  Found it: connection_timeout() and 
register_shutdown_function().  Perfect.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PCRE vs. POSIX

2001-04-15 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (bill) wrote:

> i have been using perl for quite some time, but after getting used to
> php4, i think it rocks.
> 
> i am wondering which is better, performance-wise, when trying to match the
> same text: PCRE or POSIX extended in php4?

PCRE.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySQL Query Question

2001-04-15 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Jeff Holzfaster") wrote:

> I have a couple questions... first, is there a notable MySQL General List
> like this one?

Yes.  The list on mysql.com is quite active and, like this one, it's common 
to get responses directly from one of the developers.  (Another similarity: 
the MySQL list is also archived at marc.theaimesgroup.com)  The most 
notable difference is that AFAIK there is no official news mirror of the 
MySQL list as there is for the PHP.net lists.  Darn it.

> Second, how do you write this query properly, or can it be done?
> 
> select concat(date_format(date, "%W, %e %M %Y")," ",time) as date from TABLE
> order by date DESC;

The MySQL manual has a chapter on date/time fuctions.  Or is it the 'order 
by' clause that's giving you trouble...?  I assume that 'date' is a 
reserved word, so it may be confusing mysql.  In which case, try using a 
different alias, like 'f_date".

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] fwrite not writing

2001-04-15 Thread CC Zona

This function suddenly stopped working, and I just can't seem to figure out 
why.  The only change made recently is that now the value of $force at 
calltime is sometimes true instead of being undefined or null.  

build_file("file_content","/path/to/file.inc","w",TRUE);

function build_file($func_name,$filepath,$mode="w",$force=FALSE)
   {
   if($force or !file_exists($filepath) or !filesize($filepath)) //echo 
filesize($filepath) shows '0'
  { 
  $content=$func_name(); //echo $content shows it's all there
   $fp=fopen($filepath,$mode); 
   fwrite($fp,$content);
   rewind($fp); #temp test
  $read_back=fread($fp,10); #temp test
  echo "file content:\n $read_back"; #temp test, displays nothing
 fclose($fp); 
  }
   }

I've tried putting echoes and "or die('Error on __LINE__')" on every line, 
checked all the variable values, and found no answers from that.  
Everything shows exactly as it should be except that the content that 
echoes out so nicely *doesn't ever get written to the file*.  The function 
runs to the end without error and the file's modification date is even 
updated.  But the file remains empty. I'm probably missing something 
ridiculously obvious, but would someone please be kind enough to point out 
what it is?  Thank you!!

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySQL Query Question

2001-04-15 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Jeff Holzfaster") wrote:

> This works:  select date_format(date, "%W, %e %M %Y") as date from table
> This doesn't:  select concat(date_format(date, "%W, %e %M %Y")," ",time) as
> time_of_day
> 
> I'm wondering if it is possible to use concat in this way and how if it is
> possible.  Maybe this is a question better suited for the MySQL list.

Yu'huh. 

Questions about making MySQL do stuff --> MySQL list
Questions about making PHP do stuff --> PHP lists

Questions about making PHP & MySQL play nice with each other...it's a 
judgement call.  IMO, the PHP-DB list is the best (certainly the most 
thematically appropriate) place for PHP/MySQL integration issues, but YMMV.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] fwrite not writing

2001-04-16 Thread CC Zona

> > This function suddenly stopped working, and I just can't seem to figure
> out
> > why.  The only change made recently is that now the value of $force at
> > calltime is sometimes true instead of being undefined or null.
> >
> > build_file("file_content","/path/to/file.inc","w",TRUE);
> >
> > function build_file($func_name,$filepath,$mode="w",$force=FALSE)
> >{
> >if($force or !file_exists($filepath) or !filesize($filepath)) //echo
> > filesize($filepath) shows '0'
> >   {
> >   $content=$func_name(); //echo $content shows it's all there
> >$fp=fopen($filepath,$mode);
> >fwrite($fp,$content);
> >rewind($fp); #temp test
> >   $read_back=fread($fp,10); #temp test
> >   echo "file content:\n $read_back"; #temp test, displays
> nothing
> >  fclose($fp);
> >   }
> >}
> >
> > I've tried putting echoes and "or die('Error on __LINE__')" on every line,
> > checked all the variable values, and found no answers from that.
> > Everything shows exactly as it should be except that the content that
> > echoes out so nicely *doesn't ever get written to the file*.  The function
> > runs to the end without error and the file's modification date is even
> > updated.  But the file remains empty. I'm probably missing something
> > ridiculously obvious, but would someone please be kind enough to point out
> > what it is?  Thank you!!

> What is this:
> 
> !filesize($filepath)

If filesize is zero (which it is ), then do the rest (which it 
does--except the content it fetches never makes it into the file it writes 
to.  How that can be, I dunno, but that apparently is what it's doing...)

> Add this above your if loop:
> 
> $filesize = filesize($filepath);
> echo $filesize;

Already tried echoing that and all the other values.  Filesize is 0.

> That might be causing your loop not to execute...if not, I'm not sure what's
> wrong.

I don't get it.  It should work.  It did work.  Suddenly it's not.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] dates

2001-04-16 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Alvin Tan") wrote:

> a little stuck here. trying to pull a bunch of unix timestamps out and show
> only those that show up today. problem is that when i hit the first match,
> the rest of the dates don't show. code follows:
> 
> ==
> 
> $sql = "SELECT * FROM dates";
> $result = mysql_query($sql) or mysql_die();
> 
> while ($a = mysql_fetch_array($result))
> 
> 
> $showsID = $a[showsID];
> $ts = $a[timestamp];
> $endTime=(spanDay ($ts)); // function that adds 24hrs to initial stamp to
> make the end of day time.
> $today = time();
> if (($endTime >= $today)&&($ts <= $today))
>   {
> $sq = "SELECT * FROM shows WHERE id=$showsID";
> $result = mysql_query($sq) or mysql_die();
> $b = mysql_fetch_array($result);
> print "$b[name]";
>   }
>   }

Which of the queries are you concerned with, 'cuz on that second query 
you're only fetching array $b once.  Wrap a while() loop around  it like 
you did with array $a if you want more rows.

BTW, you're missing an opening curly brace for the first while().

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] What does "url_rewriter.tags" do?

2001-04-16 Thread CC Zona

>From v4.0.4 change log
"Added url_rewriter.tags configuration directive (Sascha)"

The option shows up in my phpinfo with default settings 
"a=href,area=href,frame=src,form=fakeentry", but I can't find any info on 
what this setting does.  The change log entry seems to be the only 
reference to it in the PHP.net docs.  What does it do?

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] What does "url_rewriter.tags" do?

2001-04-16 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Emil Rasmussen) wrote:

> > Subject: [PHP] What does "url_rewriter.tags" do?
> 
> > What does it do?
> 
> 
> url_rewriter.tags is a list of HTML elements that will get the PHPSESSID
> added to them. Its all about sessions:
> http://www.php.net/manual/en/ref.session.php.

Thanks.  The url_rewriter.tags config option isn't mentioned on that page, 
but now that you relate it to sessions it does make more sense.  Though 
setting "form" to value "fakeentry" seems odd since PHPSESSID does also get 
added to forms as a hidden input.   Anyway, at least now I have a 
general idea of its purpose.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] fwrite not writing

2001-04-16 Thread CC Zona

In article <9bejks$gl6$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Plutarck") wrote:

> I'm not sure why it suddenly stopped working, but let's see if you actually
> need it to work.
> 
> First of all, I take it that you have content which you want to write into a
> file. Correct?
> 
> If so, why does it matter if the file you want to write it to has data
> anyway? If you are just going to add data into it, isn't it ok that it is a
> zerolength file?

It is needed.  I have a dynamically generated page.  Most of the content 
needs to be re-generated with every request.  But some of it needs to be 
re-generated far less often.  Rather than unnecessarily hit the db every 
time to get the exact same content, that content gets cached to an include 
file.  This function checks whether that file needs to get a content 
refresh, and if so rewrites that content.  (I'm not adding data to the 
file, I'm overwriting it.)

> Or is the problem that the file is _not_ actually zerolength, but PHP says
> it's zerolength anyway?

Nope, it's really zero length.  The filesystem agrees with PHP, and when I 
open it in a text editor the file is empty.

> Just try removing the !filesize() part, and then try executing the function.

I commented out the entire if() condition, it makes no difference.  Maybe I 
have not made this clear enough: the problem is not in getting inside the 
loop.  The function *is* executing the loop, and *is* reaching the fwite() 
line as well as continuing without error past that line.  The frustrating 
part is that fwrite() is writing an empty string to the file instead of 
using the $content variable (which, when echoed immediately before that 
line, is definitely not empty/null).

> But maybe I just don't understand what you are trying to write and why.
> Could you be a little more specific what data is being saved in the file,
> and what is in the file already?

Sometimes the file has data, sometimes it doesn't; sometimes the file 
exists, sometimes it does.  Right now, unfortunately, the file remains 
empty. I'm trying to fill it with a large block of dynamically generated 
HTML which will then be used as a static include file for current and 
subsequent requests.



> "CC Zona" <[EMAIL PROTECTED]> wrote in message
> 9bebi3$133$[EMAIL PROTECTED]">news:9bebi3$133$[EMAIL PROTECTED]...
> > > > This function suddenly stopped working, and I just can't seem to
> figure
> > > out
> > > > why.  The only change made recently is that now the value of $force at
> > > > calltime is sometimes true instead of being undefined or null.
> > > >
> > > > build_file("file_content","/path/to/file.inc","w",TRUE);
> > > >
> > > > function build_file($func_name,$filepath,$mode="w",$force=FALSE)
> > > >{
> > > >if($force or !file_exists($filepath) or !filesize($filepath))
> //echo
> > > > filesize($filepath) shows '0'
> > > >   {
> > > >   $content=$func_name(); //echo $content shows it's all there
> > > >$fp=fopen($filepath,$mode);
> > > >fwrite($fp,$content);
> > > >rewind($fp); #temp test
> > > >   $read_back=fread($fp,10); #temp test
> > > >   echo "file content:\n $read_back"; #temp test, displays
> > > nothing
> > > >  fclose($fp);
> > > >   }
> > > >}
> > > >
> > > > I've tried putting echoes and "or die('Error on __LINE__')" on every
> line,
> > > > checked all the variable values, and found no answers from that.
> > > > Everything shows exactly as it should be except that the content that
> > > > echoes out so nicely *doesn't ever get written to the file*.  The
> function
> > > > runs to the end without error and the file's modification date is even
> > > > updated.  But the file remains empty. I'm probably missing something
> > > > ridiculously obvious, but would someone please be kind enough to point
> out
> > > > what it is?  Thank you!!
> >
> > > What is this:
> > >
> > > !filesize($filepath)
> >
> > If filesize is zero (which it is ), then do the rest (which it
> > does--except the content it fetches never makes it into the file it writes
> > to.  How that can be, I dunno, but that apparently is what it's doing...)
> >
> > > Add this above your if loop:
> > >
> > > $filesize = filesize($filepath);
> > > echo $filesize;
> >
> > Already tried echoing that and all the other values.  Filesize is 0.
> >
> > > That might be causing your loop not to execute...if not, I'm not sure
> what's
> > > wrong.
> >
> > I don't get it.  It should work.  It did work.  Suddenly it's not.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] fwrite not writing (simpler example), PHP 4.0.4pl1, Apache/1.3.14

2001-04-16 Thread CC Zona

Suggestions so far have focused on parts of the function other than fwrite, 
so I'm trying again with a stripped-down example.  After spending many 
hours trying to make this very simple function work again, I'm beginning to 
think fwrite in broken--either in 4.0.4pl1 (?!) or in my build of it (it 
was working fine before...).  Before filing a bug report, would a few 
people test whether this fails to write on their system too? Thank you!


function build_file()
   {
   $fp=fopen("/path/to/directory/test.inc","w") or die("ERROR on fopen" . 
$php_errormsg); 
   fwrite($fp,"Hi, I'm some test content",1) or die("ERROR: 
fwrite " . $php_errormsg);
   fclose($fp) or die("ERROR: fclose" . $php_errormsg);
   }

build_file(); //no errors and file modification date is updated

echo "Begin include..."; //ok
include("/path/to/directory/test.inc"); //NOTHING!
echo "...End include"; //ok

(Checking from the commandline, the file is definitely being set to empty.  
It's writing an empty string to the file instead of writing the specified 
content.)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] include files with PHP 3.0.16

2001-04-16 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Tim Thorburn) wrote:

> Is there an equivalent to  in PHP?  And 
> will it work in version 3.0.16.  I've gone through the online manual but 
> found nothing that would help in this situation.

http://php.net/manual/en/function.virtual.php

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] fwrite not writing (simpler example), PHP 4.0.4pl1, Apache/1.3.14

2001-04-16 Thread CC Zona

In article <002b01c0c697$9628ee00$8b1412d1@null>,
 [EMAIL PROTECTED] ("Chris Anderson") wrote:

> Have you checked the following things:
> A) if the file is actually there?

Yes.  (And even when the file is not there,  fopen() correctly re-creates 
it.  And fwrite continued to write the wrong--empty--string to it.)

> B)Is it an include error

Checked, and no.  The file is being included.  It just doesn't have any 
content to display.

> C)Do you have the required permissions for write access and for including
> from that directory?

Permissions: yes (the file is updating, just with the wrong content)
Including: yes (it's in the include path too)

I've also checked that no other fuction is writing to the same file and 
that the function is not recursing (to, say, write the correct content on 
one pass then overwrite with empty string on the next pass).  No to those 
too. 


> - Original Message -
> From: "CC Zona" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, April 16, 2001 5:34 PM
> Subject: [PHP] fwrite not writing (simpler example), PHP 4.0.4pl1,
> Apache/1.3.14
> 
> 
> > Suggestions so far have focused on parts of the function other than
> fwrite,
> > so I'm trying again with a stripped-down example.  After spending many
> > hours trying to make this very simple function work again, I'm beginning
> to
> > think fwrite in broken--either in 4.0.4pl1 (?!) or in my build of it (it
> > was working fine before...).  Before filing a bug report, would a few
> > people test whether this fails to write on their system too? Thank you!
> >
> >
> > function build_file()
> >{
> >$fp=fopen("/path/to/directory/test.inc","w") or die("ERROR on fopen" .
> > $php_errormsg);
> >fwrite($fp,"Hi, I'm some test content",1) or die("ERROR:
> > fwrite " . $php_errormsg);
> >fclose($fp) or die("ERROR: fclose" . $php_errormsg);
> >}
> >
> > build_file(); //no errors and file modification date is updated
> >
> > echo "Begin include..."; //ok
> > include("/path/to/directory/test.inc"); //NOTHING!
> > echo "...End include"; //ok
> >
> > (Checking from the commandline, the file is definitely being set to empty.
> > It's writing an empty string to the file instead of writing the specified
> > content.)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] fwrite not writing (simpler example), PHP 4.0.4pl1, Apache/1.3.14

2001-04-16 Thread CC Zona

In article <006701c0c699$ad65cdc0$8b1412d1@null>,
 [EMAIL PROTECTED] ("Chris Anderson") wrote:

> come to think of it, why are you passing 3 arguements to fwrite()?

Whoops!  That's a typo left over from the last round of tests,  adding 
every optional argument just in case something wasn't really optional.  Of 
course the third argument actually belongs to fopen().  Though it shouldn't 
be needed there either.  (And yup, I just double-checked and it doesn't 
work without the typo either. )

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] fwrite not writing (simpler example), PHP 4.0.4pl1, Apache/1.3.14

2001-04-16 Thread CC Zona

In article <012101c0c69b$b01b8d00$8b1412d1@null>,
 [EMAIL PROTECTED] ("Chris Anderson") wrote:

> I tried it, even with the byte length identifer it worked perfectly for me.
> As a last ditch effort try changing the w to w+. If not then it sounds like
> a configuration issue for the webserver or php. Dunno what settings though,
> sorry couldn't be of more help.

Thanks for testing.  Was that with v4.0.4pl?  I'd sure like to know whether 
there's any possbility it's bug.  Seems unlikely, but then again so does 
the stubborness of frwite() in choosing its own content to write in place 
of mine.  I've pored over phpinfo and php.ini trying to find a config 
setting that might be causing this weirdness, but so far nothing seems 
obvious.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Is there such an array like $array[][]?

2001-04-17 Thread CC Zona

In article <9bhrri$sn9$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Plutarck") wrote:

> Just another option, but feel free to use multi-dimensional arrays. Just be
> aware that PHP supports only two dimensions (so $array[][][] will not work),
> and if you try and get fancy with sort() and count() you are going to give
> yourself a migraine.

Odd.  3+ dimensions works fine for me.  I pass two dimensional arrays in 
forms all the time, then reference them from $HTTP_*_VARS which adds 
another dimension.  No problem there.  It's true sort() and count() are 
sorting or counting the elements of the first dimension, but PHP does 
provide other functions which allow for effective handling of more 
dimensions (ex. array_multisort()).

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Dynamic Pages and Google ???

2001-04-17 Thread CC Zona

In article <9bho4e$r7p$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Plutarck") wrote:

> Also be extremely careful about the use of  and browser sniffing.
> So many sites do something classically stupid so that when someone sees
> their site in a search engine, the description is "Your browser does not
> support frames. Your browser must support frames to view this site."...I
> just want to slap the webmaster every time I see that.

I've been working on a mini-spider project that's been quite an eye-opener 
about another slap-worthy practice: an appalling number of splash pages 
consisting of nothing but a graphic (no alt tags, no title tag, no metas) 
and an "enter" link that must fetch its href from a javascript function.  
And these are sites that do want to be indexed!

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Last 10 rows

2001-04-17 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Randy Johnson") wrote:

> How do I get the last 10 rows in a table?

{select clause} order by {fieldname} desc limit 10

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Is it possible to parse a variable by character?

2001-04-17 Thread CC Zona

In article <9bjcj6$dg6$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Yasuo Ohgaki") wrote:

> I'm not sure if accessing string as array is going to be depreciated or not.
> (Or is it already depreciated???)

I made a note of this a while ago when it came up on the list, because 
initially it sounded to me too like it was being deprecated.  It's not.  
It's the current *method* for accessing string offsets that is expected to 
be deprecated in the near future.  So instead of using $string[offset], we 
just should get into the habit of using $string{offset} now to save 
ourselves the hassle of going back to fix it later.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] global sessions

2001-04-18 Thread CC Zona

In article <9bjvo1$irv$[EMAIL PROTECTED]>, [EMAIL PROTECTED] ("Ben") 
wrote:

> i'm trying to use sessions with my project, but it seems that registered
> variables in a session aren't global by default.

They should be.  Can you show an example of the code that leads you to 
believe they're not?

> It doesn't even seem like the session is global, because if I reference the
> sessionid (which only shows up if cookies are disabled)
> by using , it shows up within a function, if I reference it from
> within the function.

That's because SID is a constant (no dollar sign).  Only variables have to 
be declared as global before using the global version in a function.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] search results return by relevancy

2001-04-19 Thread CC Zona

However, note that MySQL does not include stopwords in the FULLTEXT index 
--and it currently considers any word of three characters or less to be a 
"stopword".  So if you really are searching for words as short as "cat", 
this isn't the solution (or else you're going to need to make some 
modifications to the MySQL source and re-compile).


In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Clarence) wrote:

> Try "MATCH (FULLTEXT index columns) AGAINST ('keyword')"
> 
> Check the MySQL manual at:  and search for "match 
> against" or "fulltext"
> You need to build FULLTEXT indexes on the columns you want to search 
> before you can use the above syntax.
> 
> However, it will search and sort by relevance.
> 
> 
> On Thursday, April 19, 2001, at 09:56 AM, Jen Hall wrote:
> 
> > Hi there
> > I have some scripts that do a search in a MySQL database
> > table.
> > I want to be able to return rows that match a query, in
> > order of relevancy.
> > For example, say I have a table that has the following data
> >
> > |row_id|  data
> > |--|-
> > |  1   |  cat
> > |  2   |  cat cat
> > |  3   |  cat cat cat
> > |  4   |  cat cat
> > |  5   |  cat cat cat cat cat cat cat
> > |  6   |  cat
> > |  7   |  cat cat cat cat
> > |  8   |  cat cat cat cat cat

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] SQL Select Unique() ?

2001-04-19 Thread CC Zona

In article <9bng4u$ftc$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("James, Yz") wrote:

> $sql = "SELECT * FROM table WHERE category LIKE 'Public House / Restaurant'
> OR description LIKE 'Public House / Restaurant'";
> 
> Surely that would bring the same row back twice

Surely not.  Have you tried it yet?  Unless there are duplicate rows in the 
table (which should *not* be the case), each row that is matched by that 
query should only be returned once per execution of the query.

>  Is there any way of
> selecting from the table just once, without having to restrict the search
> facility to something like:
> 
> "SELECT * FROM table WHERE category LIKE '%$searchtext%'";
> 
> as opposed to having the "OR" in as well?

I'm not sure what you're after.  If executing the top example is getting 
you unwanted rows, perhaps you could re-post with some sample data and 
pointing out which rows are being shown in duplicate.  (It might also be a 
good idea to re-check your data first if there's any possibility that there 
are duplicate rows existing in the db.  'Cuz that's the kind of thing 
that's gonna mis-lead you about how SQL queries normally work.)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Warnings w/ !$var!?

2001-04-20 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Nicholas Pappas) wrote:

>   When I check a variable (say, in a if() statement) via !$var, I get a 
> Warning message printed saying that it is not initialized (if that is 
> the case)... well, that's part of the reason why I bloody doing the test!



>I am aware of the isset($var) function, but this does work for my purposes.

It sure sounds like the right function for your purposes.  Or are you 
really trying to do an..

if(!isset($var) or empty($var))

...?  Because if you do it like that (isset check first), the warning won't 
come up, even on E_ALL.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Regular Expressions?

2001-04-20 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("yanto") wrote:

> (eregi("([0-9][a-z][A-Z]\.[0-9][a-z][A-Z]", $myArray[x]))
> 
> and don't use character '^' in front of the pattern.

(Note that since the parentheses are unbalanced, the above will thorw a 
parse error.)

Since it's eregi, you don't need both [a-z] and [A-Z].  And by putting the 
digits and letters in separate character classes, the pattern can only 
match strings with one digit followed by two letters, a dot, another digit, 
and more more letters.  IOW:

1ab.2Cd
3zY.9MX

(etc.)

Since the goal is to match like this...

> I want to match any of the following:
> 
> 1.1 or a.a
> 
> or . or .<-- any number of digits (0-9) or alpha (a-z)
> on either side of the dot.

...try something more like this..

eregi("[0-9a-z]+\.[0-9a-z]+", $myArray[x])

...which would match as shown in the samples, where a single matched 
character on either side of the decimal is repeating. (change the plus 
signs to asterisks if "any" number of letters/digits can include no 
letters/digits.)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] I'm a moron. So?

2001-04-20 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Dddogbruce \(@home.com\)") wrote:

> A friend told me something about
> "seeding" for random() but I didn't find anything on that.

Umm, where did you look?  'Cuz the manual page on rand()--the function 
which you are using to generate the random number--mentions it right at the 
outset, with a link, sample code...

http://php.net/manual/en/function.rand.php
http://php.net/manual/en/function.srand.php

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] bug, querk, or mistake?

2001-04-21 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Adam Charnock") wrote:

> The following if statement always claims to be false.
> However, I print out the variables in the if (which are strings) and they
> are identical. Here it is:
> 
>   if($reqcat["indexname"] == $row["maincat"])

It would help to know what the values of those variables are when the 
comparison seemingly fails.  With PHP's loose typing, it's possible for 
variables that a human reader would consider clearly same/different to get 
"unexpected" (though technically quite correct) results with a == 
comparison.  You might try testing with the === operator (meaning, "values 
*and* types equal") to eliminate a type casting issue as the culprit.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Buttons and such...

2001-04-21 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("PHPBeginner.com") wrote:

> See, that's for the website. You often don't want to look same as others, do
> you? Then you should be making the buttons yourself, perhaps on a sexy Mac
> OS X with some PhotoShop or Fireworks.
> 
> OK, nor even I make myself the buttons when I design a software interface
> for internal use. I go to sourseforge.net, look thought the software demos
> and use cut&paste technology.
> 
> Applications, generally, have some very interesting and usable graphics, my
> advise to you is : search there.

There's some very cool, cutting edge design to be seen on some of those 
sites.  However, it should be noted that since graphics are 
copywrite-protected materials, unless a site is explicitely offering up its 
graphics for free public use, you should also be getting permission before 
using the "borrowed" graphics within your own works.  (OTOH, downloading 
others' graphics in order to study them, master the techniques used to 
create them, etc. is a common and very helpful practice that AFAIK does not 
require permission.  So take advantage!)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] what's wrong with this?

2001-04-22 Thread CC Zona

In article <9btgks$fc6$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("McShen") wrote:

> $start is passed by the url. like http://mydomain.com/links.ph?start=0;
> $end =$start+15;
> 
> $query = "SELECT * FROM refer ORDER BY hits desc LIMIT $start,$end";
> 
> it didn't work. Please help.

Perhaps if you were more specific about what you were expecting to happen 
and what *actually happened when "it didn't work"...?  Meantime note that 
the 2nd parameter to LIMIT is not an end point but a count of total rows to 
be shown.  So "limit 0,15" translates to "show the first 15 rows" while 
"limit 15,15" and "limit 30,15" would be the correct way to get the next 
two groups of 15 rows each.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] is there something like get_time_limit() ?

2001-04-22 Thread CC Zona

In article <9bvs8e$g9p$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("almir") wrote:

> is it possible to get time limit of script on server ?

Since the "max_execution_time" can be set in php.ini, the current value 
should be displayable with a call to phpinfo().  I expect you can also 
check that value with get_cfg_var().  And of course you can also change the 
setting in a script simply by using set_time_limit().  Cheers!

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




  1   2   3   4   5   >