php-general Digest 13 Sep 2004 13:07:38 -0000 Issue 2993
Topics (messages 196461 through 196497):
Valid Chars....no fun!
196461 by: Jay
196466 by: John Holmes
Re: Class dependencies
196462 by: Curt Zirzow
Re: get_class_vars
196463 by: Curt Zirzow
gtk is working in php 5 ?
196464 by: Nicolae Serban
196479 by: zareef ahmed
safely using input for mail
196465 by: David T-G
196467 by: John Holmes
196471 by: David T-G
196472 by: Justin French
196473 by: John Holmes
How to change font attributes in dropdown?
196468 by: Jeff Swanberg
196469 by: Franklin van de Meent
196470 by: John Holmes
MS Outlook 2003 Mail listing
196474 by: Rajesh
196481 by: Ed Lazor
Re: Outputting HTML with PHP - Buffer Problem?
196475 by: Jason Davidson
Re: I don't understand why !!!!
196476 by: Mulley, Nikhil
Re: ftp_nlist()
196477 by: zareef ahmed
Re: Help With PEAR::DB Connection
196478 by: php-list.xenonsolutions.com
Re: Evaluating form posts
196480 by: zareef ahmed
196483 by: Chris Shiflett
196484 by: Chris Shiflett
Re: how to redirect ?
196482 by: Chris Shiflett
group queries result
196485 by: Barbara Picci
196486 by: Barbara Picci
196487 by: Barbara Picci
196488 by: Barbara Picci
196489 by: Burhan Khalid
Re: preg_replace question
196490 by: Burhan Khalid
Delete Line from File?
196491 by: Nick Wilson
196492 by: zareef ahmed
196497 by: John Holmes
use xml_set_character_data_handler outside of scope
196493 by: Dan Field
Re: php|works in Toronto - anyone going?
196494 by: Jay Blanchard
196495 by: Aaron Gould
php4 and php5 on the same apache server
196496 by: Jacob Friis Larsen
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Hi!
I got this code from here, i think it was "Ni Shurong" who gave it to
me. The code works pretty good. Except i found that sending "asdas."
into the function will return true...it should return false. What i am
trying to do is check for valid chars. Only alpha and numeric. Can
someone help me correct the code:
function isValid($strData, $bIncludeAlpha=false, $bIncludeNumber=false)
{
switch(true) {
case $bIncludeAlpha && !$bIncludeNumber:
$ptr = "/^[a-zA-Z]+/";
break;
case !$bIncludeAlpha && $bIncludeNumber:
$ptr = "/^[0-9]+/";
break;
case $bIncludeAlpha && $bIncludeNumber:
$ptr = "/^[a-zA-Z0-9]+/";
break;
default:
return false;
}
return preg_match($ptr, $strData);
}
Thanx In Advance
Jay
--- End Message ---
--- Begin Message ---
Jay wrote:
I got this code from here, i think it was "Ni Shurong" who gave it to
me. The code works pretty good. Except i found that sending "asdas."
into the function will return true...it should return false. What i am
trying to do is check for valid chars. Only alpha and numeric. Can
someone help me correct the code:
function isValid($strData, $bIncludeAlpha=false, $bIncludeNumber=false)
{
switch(true) {
case $bIncludeAlpha && !$bIncludeNumber:
$ptr = "/^[a-zA-Z]+/";
Match one or more letters at the beginning of the string: "asdas." passes.
break;
case !$bIncludeAlpha && $bIncludeNumber:
$ptr = "/^[0-9]+/";
match one or more letters at the beginning of the string: "asdas." fails
break;
case $bIncludeAlpha && $bIncludeNumber:
$ptr = "/^[a-zA-Z0-9]+/";
Match one or more letters or numbers at the beginning of the string:
"asdas." passes
break;
default:
return false;
}
return preg_match($ptr, $strData);
}
Your patterns are missing the $ for "end of string", if you're after
what I think you are.
/^[a-zA-Z]+$/ => ensures entire string is letters only (and not empty)
/^[0-9]+$/ => ensure entire string is numbers only (and not empty)
/^[a-zA-Z0-9]+$/ => ensures entire string is letters or numbers only
(and not empty)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
* Thus wrote Ed Lazor:
> > -----Original Message-----
> > What you can do is something like this:
> >
> >
> 1> function __autoload($class_name) {
> 2> static $_stack = array();
> 3>
>
> This didn't seem to work. The stack stuff just ends up dumping the value of
> $class_name. Also, why check to see if the class exists on line #8? Isn't
> PHP calling __autoload already confirming that the class doesn't exist?
Yeah, i didn't test the code, just throwing out some ideas :) The
class_exist() call is used to ensure that even though the was
successfully included, the class was actually defined in there as
well.
>
> I'll include copies of the two scripts below. Here's information on the
> scripts that might help explain things.
>
> The first script is being saved as Test.php. It includes a class called
> Test.
>
> The second script is being saved as test2.php. This script has a class
> called ClassDependent. It depends on the Test class.
>
> I'm trying to address two situations are being addressed here. What if the
> file Test.php is missing for some reason. And, even if the file is present,
> what happens if the file / class hasn't been loaded?
>
> In my opinion, if class Test is missing, it makes sense to know up front.
> It provides a sort of checks and balances. Otherwise, the class doesn't
> show as missing until there's an attempt to load it. I can easily see
> deploying an app without realizing there's a problem until someone happens
> to use some osbure feature that depends on the missing class.
I usually get around this solution by using require_once inside my
class definitions, for all the classes it relies on:
<?php
require_once('classes/Foo/Bar.php'); // Defines FooBar
class Qaz {
function doSomething() {
$foo_bar = new FooBar();
}
}
?>
This forces a compile error and forces you ensures that classes are
defined.
> I know that I could just create a list of files belonging to the app and
> check to make sure that they are all present when starting. It seems like
> there could be a lot of overhead in maintaining something like this. It
> also seems to make sense that you'd want classes to define their own
> dependencies for portability. What do you think?
>
> All of this kind of leads into why I'd like autoload (or some other tool) to
> indicate which class ran into a problem loading another class. In the
> examples below, it helps troubleshoot things if the error message tells me
> that ClassDependent was unable to load class Test. Hehe Having the error
> message tell me which line number would also be super cool, but maybe that's
> not possible.
If you want full control of the loading of your classes, then you
might want to use a Factory Class, that manages loading of your
objects:
<?php // Factory.php
class Factory {
static private $uses = array();
static public function newObject($obj) {
if (! class_exists($obj) ) {
Factory::$uses = array(); //reset
//include class file...
//require_once($obj);
// validate/load these classes...
var_dump(Factory::$uses);
if ($some_sort_of_error ) {
throw new Exception(Factory::errorString());
}
}
return new $obj;
}
static public function uses() {
Factory::$uses = func_get_args();
}
static public function errorString() {
// obtain proper file, line, function backtrace
// with debug_backtrace..
return $message;
}
}
?>
<?php // Test.php
Factory::uses('TestClass', 'OtherClass'):
class Test { ... }
?>
Then:
require('Factory.php');
try {
$obj = Factory::newObject('Test');
}
Of course all the above probably needs a lot of work :)
Curt
--
The above comments may offend you. flame at will.
--- End Message ---
--- Begin Message ---
* Thus wrote Sam Hobbs:
> Using the code shown below, I get nothing from get_class_vars but I do get
> very useful results from get_class_methods. I realize that this is how it is
> supposed to be, but it would be useful to be able to get the property
> members of the class. The reason I want to see the properties of DOMDocument
> is because they are not documented. There are some methods of the
> DOMDocument class that exist in other implemntations of the DOM but not the
> PHP 5 implemntation. Probably the equivalent is available using properties
> to get data instead of methods. Due to the absence of documentation of the
> properties, it would help to have a function that shows the properties. I
> will look for the source code and I assume I can find the answer there, so I
> assume I don't need help with that. Unless there is some other function that
> will show the properties of a class in the manner I am looking for.
I dont think there are any properties for a DOMDocument. You might
want to look at the Reflection Class, You can get a lot more info
from class definitions:
Reflection::export(new ReflectionClass('DOMDocument'));
See:
http://php.net/oop5.reflection
Curt
--
The above comments may offend you. flame at will.
--- End Message ---
--- Begin Message ---
i'm new with php 5 and i whant to know if gtk it is still working with php 5 !!
Thank you !
--- End Message ---
--- Begin Message ---
HI ,
--- Nicolae Serban <[EMAIL PROTECTED]> wrote:
> i'm new with php 5 and i whant to know if gtk it is
> still working with php 5 !!
>
> Thank you !
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
visit http://gtk.php.net ;)
zareef ahmed
=====
Zareef Ahmed :: A PHP Developer in Delhi ( India ).
Homepage :: http://www.zasaifi.com/zareef_ahmed.php
_______________________________
Do you Yahoo!?
Shop for Back-to-School deals on Yahoo! Shopping.
http://shopping.yahoo.com/backtoschool
--- End Message ---
--- Begin Message ---
Hi, all --
I'd like some sanity checks on safely using input for sending mail. I'm
developing a feature where one can click a 'mail this page' link, fill in
the sender's and the recipient[s]'s addresses, and add comments in the
body (eg "Hey, Bill, what do you think of this chair?") and then generate
the email. I want to watch out for gotchas.
At the moment, I am running escapeshellcmd() on the From:, To:, Subject:,
url, and body fields, and limiting the recipient field to 255 chars
(enough for about half a dozen addresses, I figure) to prevent being used
for massmailing (though I haven't yet figured out how to keep from being
called repeatedly, but at least that's just as hard for the spammer as
his own bandwidth limits). Unfortunately, escapeshellcmd() also escapes
the ? and &s in the URL and breaks it; I think it will have to go away.
I'm also ready to believe that I've overlooked half a dozen other things.
How would you guys tackle this?
TIA & HAND
:-D
--
David T-G
[EMAIL PROTECTED]
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
pgp9n3XsZv5jg.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
David T-G wrote:
I'd like some sanity checks on safely using input for sending mail. I'm
developing a feature where one can click a 'mail this page' link, fill in
the sender's and the recipient[s]'s addresses, and add comments in the
body (eg "Hey, Bill, what do you think of this chair?") and then generate
the email. I want to watch out for gotchas.
At the moment, I am running escapeshellcmd() on the From:, To:, Subject:,
url, and body fields, and limiting the recipient field to 255 chars
(enough for about half a dozen addresses, I figure) to prevent being used
for massmailing (though I haven't yet figured out how to keep from being
called repeatedly, but at least that's just as hard for the spammer as
his own bandwidth limits). Unfortunately, escapeshellcmd() also escapes
the ? and &s in the URL and breaks it; I think it will have to go away.
I'm also ready to believe that I've overlooked half a dozen other things.
How would you guys tackle this?
This isn't what escapeshellcmd() is for; not sure why you chose that one.
Are you sending this as an HTML or Text email? Either way, you control
the body of the email (the page that's being sent), so you don't really
have to worry about that.
If you're sending an HTML mail, then use htmlentities() on the text
before putting it in the email. If you're sending a text email, then you
can strip_tags() from it.
The biggest thing to look our for is mail header injection. If you're
taking any user input and putting it into the headers (from, to,
subject, etc), then newlines need to be stripped. You're allowing the
user to set the To: address, I assume (the recipients). If you're
sticking that $to varable from the user directly into mail(), you could
be vulnerable (same if you create a From: header or use user input in
the subject).
For example, say you're collecting my email address for the From: header.
$headers .= "From: {$_POST['email']}\r\n";
You're probably using a regular text input for this, so you're thinking
$_POST['email'] can only be one line, but that's not the case. I can
duplicate your form and make it a textarea or just do a direct
connection to your server and supply any data I want. So, I send the
following value for my "email":
[EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
Subject: My Own Subject
Content-Type: text/html
This is my own body with malicious intent??
<!--
All of that now get's shoved into the "From" header, but since there are
newlines, you're allowing me to create more headers than just From:. I
can set any other header, including To:, Cc:, etc. I can even include
the body if I include two newlines and then put a comment or a ton of
newlines at the end to hide the actual content you'll put in later.
So strip newlines from user input or reject input if it contains newlines.
str_replace(array("\r","\n",'',$text)
Is one way to do it.
If I left anything out, I'm sure Chris will jump on it. :)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
John, et al --
[Been a while! How ya been?]
...and then John Holmes said...
%
% David T-G wrote:
%
% >I'd like some sanity checks on safely using input for sending mail. I'm
...
% >At the moment, I am running escapeshellcmd() on the From:, To:, Subject:,
...
% >his own bandwidth limits). Unfortunately, escapeshellcmd() also escapes
% >the ? and &s in the URL and breaks it; I think it will have to go away.
% >I'm also ready to believe that I've overlooked half a dozen other things.
% >
% >How would you guys tackle this?
%
% This isn't what escapeshellcmd() is for; not sure why you chose that one.
Noobness, I suppose :-) I wanted to avoid having problematic commands
fed in to break my script; perhaps that's only a DB-type exploit (though
an answer that simple doesn't seem likely).
%
% Are you sending this as an HTML or Text email? Either way, you control
% the body of the email (the page that's being sent), so you don't really
% have to worry about that.
Just text.
%
% If you're sending an HTML mail, then use htmlentities() on the text
% before putting it in the email. If you're sending a text email, then you
% can strip_tags() from it.
Ah; OK.
%
% The biggest thing to look our for is mail header injection. If you're
Indeed. I figured as much, but escapeshellcmd() is as far as I got.
% taking any user input and putting it into the headers (from, to,
% subject, etc), then newlines need to be stripped. You're allowing the
Ahhhhhh... That makes sense. Thanks.
% user to set the To: address, I assume (the recipients). If you're
% sticking that $to varable from the user directly into mail(), you could
% be vulnerable (same if you create a From: header or use user input in
% the subject).
Yep.
%
% For example, say you're collecting my email address for the From: header.
%
% $headers .= "From: {$_POST['email']}\r\n";
...
% So strip newlines from user input or reject input if it contains newlines.
%
% str_replace(array("\r","\n",'',$text)
For the archives, you need ^^^^ here a closing ) on your array :-)
%
% Is one way to do it.
%
% If I left anything out, I'm sure Chris will jump on it. :)
Good; thanks to all in advance!
%
% --
%
% ---John Holmes...
HAND
:-D
--
David T-G
[EMAIL PROTECTED]
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
pgpOxNnHjKDfF.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
On 13/09/2004, at 12:45 PM, John Holmes wrote:
str_replace(array("\r","\n",'',$text)
Is one way to do it.
Typo John:
str_replace(array("\r","\n"),'',$text);
:)
---
Justin French
http://indent.com.au
--- End Message ---
--- Begin Message ---
Justin French wrote:
On 13/09/2004, at 12:45 PM, John Holmes wrote:
str_replace(array("\r","\n",'',$text)
Is one way to do it.
Typo John:
str_replace(array("\r","\n"),'',$text);
Yeah, that's why I said it was "one way" to do it and not the "correct
way" to do it... come on people!! ;)
Anyway, I uhmm... did that on purpose. Yeah, it was a test to see if
David was paying attention. Since he caught it, also, I guess my, uh,
test worked. Yeah... that's the ticket!
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
I've tried many locations but can't figure out how to change the font
attributes for just my dropdown list on my page. The dropdown box populates
its data perfectly but I'd like to change the font to Arial Bold 10pt on the
items.
Here's my code:
?>
<div style="position:absolute; top:100px; left:440px;">
<form name=Event method=post action="<? echo $PHP_SELF ?>"
enctype=multipart/form-data>
<input type=hidden name=UID value=<? echo $UID ?> >
<?
echo "<SELECT class=dropdown name=Event
onchange=\"document.forms['Event'].submit()\">";
echo "<option value=\"\"> Choose Event </option>";
mysql_connect("$DBHost","$DBUser","$DBPass");
$result=mysql("$DBName","SELECT * FROM Category WHERE Category = 'Ordering'
ORDER BY Event");
while ($row = mysql_fetch_row($result)) {
echo "<option value=\"$row[0]\"> $row[0] </option>";
}
echo "</select>";
?>
</FORM>
</div>
<?
--- End Message ---
--- Begin Message ---
Hello Jeff,
You can use the style attribute in <option> like you have done in the <div>
So this:
echo "<option value=\"$row[0]\"> $row[0] </option>";
Could look like this:
echo "<option value=\"$row[0]\" style=\"font-family:arial;
font-size:10pt; font-weight:bold;\"> $row[0] </option>";
--
Franklin van de Meent
[EMAIL PROTECTED]
On Sun, 12 Sep 2004 19:46:51 -0700, Jeff Swanberg
<[EMAIL PROTECTED]> wrote:
> I've tried many locations but can't figure out how to change the font
> attributes for just my dropdown list on my page. The dropdown box populates
> its data perfectly but I'd like to change the font to Arial Bold 10pt on the
> items.
>
> Here's my code:
>
> ?>
> <div style="position:absolute; top:100px; left:440px;">
> <form name=Event method=post action="<? echo $PHP_SELF ?>"
> enctype=multipart/form-data>
> <input type=hidden name=UID value=<? echo $UID ?> >
> <?
>
> echo "<SELECT class=dropdown name=Event
> onchange=\"document.forms['Event'].submit()\">";
> echo "<option value=\"\"> Choose Event </option>";
> mysql_connect("$DBHost","$DBUser","$DBPass");
> $result=mysql("$DBName","SELECT * FROM Category WHERE Category = 'Ordering'
> ORDER BY Event");
> while ($row = mysql_fetch_row($result)) {
> echo "<option value=\"$row[0]\"> $row[0] </option>";
> }
> echo "</select>";
> ?>
>
> </FORM>
> </div>
> <?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Jeff Swanberg wrote:
I've tried many locations but can't figure out how to change the font
attributes for just my dropdown list on my page. The dropdown box populates
its data perfectly but I'd like to change the font to Arial Bold 10pt on the
items.
Google -> CSS Tutorial
(not a PHP issue)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Hai all
i just saw MS Outlook 2003
in this applicatioin the mail are sorted in date and given names like
Today
Yesterday
Last Week
Two Weeks Ago ...
Can anybody give me algorithm to get date in this string version .
Thank you,
Rajesh
--- End Message ---
--- Begin Message ---
Check out the manual on the date function. It allows you to get names from
dates. The PEAR date stuff will allow you to do date math.
> -----Original Message-----
> From: Rajesh [mailto:[EMAIL PROTECTED]
> Sent: Sunday, September 12, 2004 10:04 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] MS Outlook 2003 Mail listing
>
> Hai all
>
> i just saw MS Outlook 2003
>
> in this applicatioin the mail are sorted in date and given names like
> Today
> Yesterday
> Last Week
> Two Weeks Ago ...
>
> Can anybody give me algorithm to get date in this string version .
>
> Thank you,
> Rajesh
>
>
--- End Message ---
--- Begin Message ---
yup, you took the words from my mouth...
[EMAIL PROTECTED] wrote:
>
> dirk wrote:
>
> >The first function you need to call using <? echo header(); ?> to see the
> output
> >THe second function is not a real function because it has no return
> >statement. In german you call this "Prozedur". Don't know if it's the
> >same as procedure in english. But you will call this piece <?
> >header(); ?> to see some output.
> >
> >
> The english word you are looking for is procedure. It is true that in
> some programming languages 'functions that do not return values' are
> called procedure but I don't think that practice is wide spread among
> PHP programmers.
>
> --
> Raditha Dissanayake.
> ------------------------------------------------------------------------
> http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
> Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
> Graphical User Inteface. Just 128 KB | with progress bar.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Yeah It was the same problem with me too,When I tried to Google,I found that PHP 5 is
not an upgrade of PHP 4 ,but a complete rewrite,
So,I thought of switching to php 4,which works quiet relevantly,
You need to configure php4.3 wit MYSQL and apache before they are used and the thing
is that in PHP 4 ,the the support is inbuilt ,U need not configure the DLLS
so,In php 5.0 everything comes under a differrent package
If U need any assistance during configuration
try a site search at google
by
PHP Apache Mysql site:devsite.net
Thanks,
Nikhil.
-----Original Message-----
From: Nicolae Serban [mailto:[EMAIL PROTECTED]
Sent: Monday, September 13, 2004 4:30 AM
To: [EMAIL PROTECTED]
Subject: [PHP] I don't understand why !!!!
---------- Forwarded message ----------
From: Nicolae Serban <[EMAIL PROTECTED]>
Date: Mon, 13 Sep 2004 01:58:38 +0300
Subject: [PHP] I don't understand why !!!!
To: [EMAIL PROTECTED]
I just install the PHP 5 !
This is the code
<?php
$link=mysql_connect("localhost","root","1234");
mysql_close($link);
?>
and this is the error messege WHY !!!????
Fatal error: Call to undefined function mysql_connect() in
C:\Apache\Apache2\htdocs\ttt.php on line 3
Thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi,
--- Jason Wong <[EMAIL PROTECTED]> wrote:
> Not sure why you would want to chdir first. Why not
> just:
>
ftp_chdir is usefull on windows specially if directory
name has a space in it.
zareef ahmed
=====
Zareef Ahmed :: A PHP Developer in Delhi ( India ).
Homepage :: http://www.zasaifi.com/zareef_ahmed.php
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
--- End Message ---
--- Begin Message ---
Jim,
Thank you. Problem solved thanks to you. The moment you said that PEAR::DB
is not finding the MySQL extention I realized that the extension in php.ini
hasn't been commented out and the extension folder had not been recognized
by PHP. I forgot we had to do that in PHP5. Everything is working like a
charm now. I really appreciate your time and concern.
Nilaab
P.S. -- And sorry, I'm using Windows XP as the development environment and
Linux as the server. The Windows OS is where I was having the problem.
Thanks again...
-----Original Message-----
From: James Kaufman [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 11, 2004 7:50 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Help With PEAR::DB Connection
On Sat, Sep 11, 2004 at 01:48:43AM -0500, [EMAIL PROTECTED] wrote:
> Hello everyone,
>
> I have a problem connecting to the Database. When I execute the code at
the
> bottom, it gives me this message: "DB Error: extension not found". It sees
> the DB file and the parameters are correct. I checked the include path and
> it was correct. Did I do something wrong? Any help would be greatly
> appreciated. Thank you.
>
>
> require_once 'DB.php';
> $user = 'foo';
> $pass = 'bar';
> $host = 'localhost';
> $db_name = 'clients_db';
> $dsn = "mysql://$user:[EMAIL PROTECTED]/$db_name";
> $db = DB::connect($dsn);
> if (DB::isError($db)) {
> die ($db->getMessage());
> }
>
> -- Nilaab
>
The message 'extension not found' means that PEAR couldn't find the mysql db
extension. Hmm. In cases like this, create a phpinfo.php file as documented
on
this list and see what shows up. Or, you can type at the command prompt: php
-i, then look for the MySQL extension in the output.
Also, you neglected to tell us what OS you are running, etc.
--
Jim Kaufman
Linux Evangelist
public key 0x6D802619
---
A dog teaches a boy fidelity, perseverance, and to turn around three
times before lying down.
-- Robert Benchley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
HI,
A good article about magic quotes
http://www.webmasterstop.com/tutorials/magic-quotes.shtml
zareef ahmed
--- Alexander Kleshchevnikov <[EMAIL PROTECTED]>
wrote:
> You should chech for configuration of magic quotes
> gpc.
> Use get_magic_quotes_gpc() function:
>
> $foo = get_magic_quotes_gpc() ?
> stripslashes($_POST["foo"]) : $_POST["foo"])
> ;
>
> Do it with all GET and POST variables.
>
> --
> Alexander.
>
> "Php Mailing List Account"
> <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hello everyone,
> >
> > I had an apache server running with php 5. Now I
> installed unix on that pc
> and apache and php 5.
> > I am using some forms on web pages and get their
> values by writing
> > $foo = $_POST["foo"];
> > Since I 'upgraded' to unix i am getting a double
> backslash for each
> backslash entered on the form
> > and '\"' for every '"'.
> > Could someone please tell me what's going on? Did
> I miss a part of the
> FAQ?
> > (The form looks like
> > <form method="post">
> > <input type="text" />
> > <input type="submit" name="action" value="submit"
> />
> > </form>
> > )
> >
> > Thank you in advance
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
=====
Zareef Ahmed :: A PHP Developer in Delhi ( India ).
Homepage :: http://www.zasaifi.com/zareef_ahmed.php
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
--- End Message ---
--- Begin Message ---
--- Alexander Kleshchevnikov <[EMAIL PROTECTED]> wrote:
> You should chech for configuration of magic quotes gpc.
> Use get_magic_quotes_gpc() function:
>
> $foo = get_magic_quotes_gpc() ? stripslashes($_POST["foo"]) :
> $_POST["foo"]);
I agree. However, stripslashes() doesn't necessarily undo addslashes(). If
you want to know why or see more discussion on that, search the PHP
internals archive. I think it was within the last 3 months or so that this
was discussed.
The best option is to turn that stuff off, but if you can't, I bet the
fix_magic_quotes() function will be helpful. It can be found here:
http://education.nyphp.org/phundamentals/PH_storingretrieving.php
That page also describes why it's best to not use magic_quotes.
Hope that helps.
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming December 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/
--- End Message ---
--- Begin Message ---
--- zareef ahmed <[EMAIL PROTECTED]> wrote:
> A good article about magic quotes
>
> http://www.webmasterstop.com/tutorials/magic-quotes.shtml
That's a nice article, and boy is Harry funny:
Magic Quotes are Evil!
While you sleep, they whisper in your dreams -
\'Use magic quotes. You know you want to. Go on. It\\'s just so
easy\\\'.
Brilliant. :-)
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming December 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/
--- End Message ---
--- Begin Message ---
--- Paul Waring <[EMAIL PROTECTED]> wrote:
> > I think you used header() after put out some data or php installed on
> > server as CGI. Because send header possible only if php installed as
> > apache module.
>
> Not so - I've used header('Location: http://www.xyz.com/'); with PHP
> as a CGI binary under both Apache 1 and Apahce 2 without problems.
Yeah, I think he might have been thinking of this:
"Note: In PHP 3, this only works when PHP is compiled as an Apache
module. You can achieve the same effect using the Status header."
Aside from only being an issue a long time ago, it's also talking about
the ability to change the response status code, not just a regular HTTP
header.
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming December 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/
--- End Message ---
--- Begin Message ---
Hi all,
I've to extract data from a mysql db using two different queries and
I must have an unique output sorting them alphabetically.
For istance,
query1: select * from ads where guest='PK';
count the number of results, make the difference between a given
number and the number of results (variable $num).
query2: select from ads where guest='PK' limit $num;
now I have to export all results together sorting them.
How can I do that?
Can anyone help me?
Thanks in advance
Barbara
--
--- End Message ---
--- Begin Message ---
Hi all,
I've to extract data from a mysql db using two different queries and
I must have an unique output sorting them alphabetically.
For istance,
query1: select * from ads where guest='PK';
count the number of results, make the difference between a given
number and the number of results (variable $num).
query2: select from ads where guest='PK' limit $num;
now I have to export all results together sorting them.
How can I do that?
Can anyone help me?
Thanks in advance
Barbara
--
--- End Message ---
--- Begin Message ---
Hi all,
I've to extract data from a mysql db using two different queries and
I must have an unique output sorting them alphabetically.
For istance,
query1: select * from ads where guest='PK';
count the number of results, make the difference between a given
number and the number of results (variable $num).
query2: select from ads where guest='PK' limit $num;
now I have to export all results together sorting them.
How can I do that?
Can anyone help me?
Thanks in advance
Barbara
--
--- End Message ---
--- Begin Message ---
Hi all,
I've to extract data from a mysql db using two different queries and
I must have an unique output sorting them alphabetically.
For istance,
query1: select * from ads where guest='PK';
count the number of results, make the difference between a given
number and the number of results (variable $num).
query2: select from ads where guest='PK' limit $num;
now I have to export all results together sorting them.
How can I do that?
Can anyone help me?
Thanks in advance
Barbara
--
--- End Message ---
--- Begin Message ---
Barbara Picci wrote:
I've to extract data from a mysql db using two different queries and I
must have an unique output sorting them alphabetically.
For istance,
query1: select * from ads where guest='PK';
count the number of results, make the difference between a given number
and the number of results (variable $num).
query2: select from ads where guest='PK' limit $num;
now I have to export all results together sorting them.
Why not do SELECT FROM `ads` WHERE `guest`='PK' ORDER BY `sortfield` ASC
LIMIT $num ?
That would get you a sorted list. I don't understand why you are using
$num, other than pagination.
You also didn't mention how this is related to PHP, it seems to be a SQL
issue.
--- End Message ---
--- Begin Message ---
Zoran Lorkovic wrote:
Btw, where I can find patterns that are valid?
(something like (\w+), (\d+)+i etc.
http://www.php.net/manual/en/reference.pcre.pattern.syntax.php
http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
--- End Message ---
--- Begin Message ---
Whats the easiest/best way to do that with php?
just replace the line with ''?
--
Nick W
--- End Message ---
--- Begin Message ---
Hi,
some function with whihc you can do this
file();
foreach();
zareef ahmed
--- Nick Wilson <[EMAIL PROTECTED]> wrote:
> Whats the easiest/best way to do that with php?
> just replace the line with ''?
> --
> Nick W
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
=====
Zareef Ahmed :: A PHP Developer in Delhi ( India ).
Homepage :: http://www.zasaifi.com/zareef_ahmed.php
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
--- End Message ---
--- Begin Message ---
From: "Nick Wilson" <[EMAIL PROTECTED]>
Whats the easiest/best way to do that with php?
just replace the line with ''?
Yes, basically. You have to read the file, replace the part you don't want
with an empty string and then re-write the file. If the file is small and
you're using file() to read it, you can just unset() the element you don't
want, then join the array back together and write it.
---John Holmes...
--- End Message ---
--- Begin Message ---
I've tried a couple of different ways to use this function to set a
variable outside of the usual scope of my characterData function but I'm
not having much luck. Heres some sample code:
<?php
$xml_repository = "/var/www/html/mets/sample/";
$depth = array();
$searchable_tags = array("MODS:TITLE");
$current_data = "";
$dir_array = array();
$hits = 0;
$MAXHITS = 100;
$search_term;
$flag = false;
function startElement($parser, $name, $attrs) {
global $depth, $searchable_tags, $current_data, $hits, $colour,
$flag;
if (in_array($name,$searchable_tags)) {
if (preg_match("/".$search_term."/i",$current_data)) {
$flag = true;
echo "<div
bgcolor=\"#$colour\">$current_data</div><br />";
$hits++;
}
}
$depth[$parser]++;
}
function characterData($parser, $data) {
global $current_data;
$current_data = $data;
}
function endElement($parser, $name) {
global $depth, $flag;
$depth[$parser]--;
if ($flag) { $flag = false; }
}
function search_data($term,$data) {
if (preg_match($term,$data)) { return true; } else { return false; }
}
// read all the xml files and parse through search engine
if ($handle = opendir($xml_repository)) {
$i = 0;
while (false !== ($file = readdir($handle))) {
$dir_array[$i] = $file;
$i ++;
}
closedir($handle);
}
for ($i = 2; $i < count($dir_array); $i++) {
$xml_parser = xml_parser_create("UTF-8");
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($xml_repository.$dir_array[$i], "r"))) {
die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
if ($hits >= $MAXHITS) { echo "<p><b>over 100
hits!\n</b> Stopping here.</p>"; exit; }
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
}
?>
If I use $current_data = $data; I get nothing back at all,
If I use $current_data .= $data; I get the concatenated response as
expected but is not what I am after.
All I want is the value of $data at that particular point in the parse.
Any help much appreciated.
--
Dan Field <[EMAIL PROTECTED]>
Support Programmer: Cymru ar y we / Wales on the Web
cy_GB: http://www.cymruarywe.org
en_GB: http://www.walesontheweb.org
--- End Message ---
--- Begin Message ---
[snip]
I'm giving a talk on PHP session security, so I'll be there.
If anyone from the list is coming, please drop by and say hi.
[/snip]
I'd love to be there for that, but the company wouldn't help with
expenses. Seems a lot of companies are dropping or eliminating their
'training' budgets
--- End Message ---
--- Begin Message ---
Chris Shiflett wrote:
I'm giving a talk on PHP session security, so I'll be there.
If anyone from the list is coming, please drop by and say hi.
I've already got your session picked for that time slot.
It'll be interesting to finally see some faces to go along with the
names I've only seen on the net these last few years!
It's too bad I'm one of the few on the list that's able to attend...
--
Aaron Gould
Parts Canada - Web Developer
--- End Message ---
--- Begin Message ---
How can I run both php4 and php5 on the same apache server?
Could I do it like this:
AddType application/x-httpd-php .php
AddType application/x-httpd-php5 .php5
And somehow tell php5 to use application/x-httpd-php5
--
Best regards, Jacob Friis Larsen
www.webcom.dk | www.journster.com
--- End Message ---