[PHP] Re: Very OT [PHP] CSS not picked up
On Sat, 2004-09-11 at 22:36, Jeff Swanberg wrote: > Nope, I have them all. Any other ideas??? Do I need to load the style.css > on every sub-page or just on the main page? Perhaps the style sheet is > cached so, after I upload a new one, I need to do something to flush the > cache? > > js > Hi Jeff, This is totally OT for a PHP list but I'll give you an answer. CSS has rules of precedence. When a browser is looking at a html page for styles it first looks for external style sheets, just like you said you have, then it looks for style tags in the ... section of the page, finally the browser looks at individual tags, 's 's whatever. The browser will then use the style rules which are closest to the tag, therefore external rules are overridden by style tags in the section of a page which are overridden by style rules embedded into actual tags. e.g. . Hope that clarifies. David
Re: [PHP] ftp_nlist()
On Sunday 12 September 2004 10:08, Karol Krizka wrote: > function get_files($dir="/") { > ftp_chdir($this->connection,$dir); > $array=ftp_nlist($this->connection,ftp_pwd($this->connection)); > var_dump($array); > } > When I connect to ftp server for my website at > ftp://kkrizka.mybesthost.com and try to use nlist function, it returns > false. But when I used ftp_rawlist, it returned a list of files no > problem. I tried to connect to a ftp server on my computer, and it > worked normally. I am not sure what is wrong... Looks OK and works for me. Not sure why you would want to chdir first. Why not just: function get_files($dir="/") { $array=ftp_nlist($this->connection,$dir); var_dump($array); } Works just as well AFAICS. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* The plot was designed in a light vein that somehow became varicose. -- David Lardner */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Very OT [PHP] CSS not picked up
php guy wrote: On Sat, 2004-09-11 at 22:36, Jeff Swanberg wrote: Nope, I have them all. Any other ideas??? Do I need to load the style.css on every sub-page or just on the main page? Perhaps the style sheet is cached so, after I upload a new one, I need to do something to flush the cache? js Hi Jeff, This is totally OT for a PHP list but I'll give you an answer. if it's off topic please don't answer. Lot's of off topic messages add to the traffic in the list and make it harder to keep track of on topic posts. Not the mention the waste of bandwidth. -- 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
[PHP] JDBC Driver for MySQL
I'm sorry if this is off-topic, but i figured this was the best place to ask: I've begun using the Eclipse IDE, and has downloaded the Quantum DB plugin. It says that i need a JDBC driver in order to connect to a remote MySQL database - where do i get that? I've looked at mysql.com, but i couldn't find anything (i might just be stupid ;)). Hope some of you know :) PS. And thanks to the guy that recommended Eclipse in this list - it rocks! Daniel Schierbeck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JDBC Driver for MySQL
see this link http://dev.mysql.com/downloads/connector/j/3.0.html official mysql jdbc driver. PS. Give google a chance. On Sun, 12 Sep 2004 15:52:12 +0200, Daniel Schierbeck <[EMAIL PROTECTED]> wrote: > I'm sorry if this is off-topic, but i figured this was the best place to > ask: > > I've begun using the Eclipse IDE, and has downloaded the Quantum DB > plugin. It says that i need a JDBC driver in order to connect to a > remote MySQL database - where do i get that? I've looked at mysql.com, > but i couldn't find anything (i might just be stupid ;)). > > Hope some of you know :) > > PS. And thanks to the guy that recommended Eclipse in this list - it rocks! > > Daniel Schierbeck > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: create and read array
Yeah, thanks. Good idea! It is good to code that: $authors = array(); while ($authors[] = mysql_fetch_assoc($news)); "Chris Martin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Alexander Kleshchevnikov wrote: > > Maybe you want this: > > > > while ($data = mysql_fetch_assoc($news)) { > > $sql += "INSERT INTO newtable VALUES ($data['AUS'], $data['id']);\r\n"; > > } > > > > If you nevertheless want save the data in array you can use a > > two-dimensional array $authors: > > > > $authors = array(); > > while ($data = mysql_fetch_assoc($news)) { > > $authors[] = array('AUS' => $data['AUS'], 'id' => $data[id]); > > } > > > > .. > > > > foreach ($author in $authors) { > > $sql += "INSERT INTO newtable VALUES ($author['AUS'], > > $author['id']);\r\n"; > > } > > > > -- > > Seigo > > www.geocities.com/seigo_ua/ > > > Just a note to help the learning process. Either mysql_fetch_assoc() and > mysql_fetch_array() will return your result in an array, so you don't > need to actually create one. > > -- > Chris Martin > Web Developer > Open Source & Web Standards Advocate > http://www.chriscodes.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Outputting HTML with PHP - Buffer Problem?
Hi all, Say i have a php script like this: How come I dont see the html header (it's just a function that returns a string with the html up till ) before the entire script has run? This goes against my understanding, why might this be and what might i use to get some output before the script has finished executing? Much thanks... -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Outputting HTML with PHP - Buffer Problem?
Nick Wilson wrote: Say i have a php script like this: How come I dont see the html header (it's just a function that returns a string with the html up till ) before the entire script has run? This goes against my understanding, why might this be and what might i use to get some output before the script has finished executing? Could be your web server buffering the output until the script finishes or something else on your connection doing the same. Some web browsers will not show content until everything is received. You could try using flush() to see if that helps. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Outputting HTML with PHP - Buffer Problem?
There is nothing wrong with what your doing, i use this sort of thing for all the big sites i make, i use a page class and use methods to create the header and footer, so your concept is good. I would investigate your html_head() function, to make sure its actually returning something. Sinse your 'print'ing it, it must return some text. example function html_head() { $html = " } then i call it with $page->header(); hope that helps? Jason Nick Wilson <[EMAIL PROTECTED]> wrote: > > Hi all, > > Say i have a php script like this: > >print(html_head()); > // do loads of time taking stuff > print(html_footer()); > ?> > > How come I dont see the html header (it's just a function that returns a > string with the html up till ) before the entire script has run? > > This goes against my understanding, why might this be and what might i > use to get some output before the script has finished executing? > > Much thanks... > -- > Nick W > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JDBC Driver for MySQL
Manoj Nahar wrote: see this link http://dev.mysql.com/downloads/connector/j/3.0.html official mysql jdbc driver. PS. Give google a chance. On Sun, 12 Sep 2004 15:52:12 +0200, Daniel Schierbeck <[EMAIL PROTECTED]> wrote: I'm sorry if this is off-topic, but i figured this was the best place to ask: I've begun using the Eclipse IDE, and has downloaded the Quantum DB plugin. It says that i need a JDBC driver in order to connect to a remote MySQL database - where do i get that? I've looked at mysql.com, but i couldn't find anything (i might just be stupid ;)). Hope some of you know :) PS. And thanks to the guy that recommended Eclipse in this list - it rocks! Daniel Schierbeck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You're my savior! Daniel Schierbeck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Outputting HTML with PHP - Buffer Problem?
Well, there is a difference between > function html_head() { > $html = " > return $html; > } and > function header() { > ?> > } The first function you need to call using 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 to see some output. Dirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Outputting HTML with PHP - Buffer Problem?
Nick Wilson wrote: Hi all, Say i have a php script like this: How come I dont see the html header (it's just a function that returns a string with the html up till ) before the entire script has run? This goes against my understanding, why might this be and what might i use to get some output before the script has finished executing? Much thanks... that's because it's all sent as 1 single big chunk of data. To get around this, you should set implicit_flush to 1 (it's in php.ini). Otherwise, you can also use the PHP ob_implicit_flush() to do this. Setting it to 1 will flush the output buffer everytime it's written to, if set to 0 it will do as normal, and buffer it all to send it together. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Outputting HTML with PHP - Buffer Problem?
dirk wrote: The first function you need to call using 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
Re: [PHP] Outputting HTML with PHP - Buffer Problem?
* and then Jason Davidson declared > i prefer to escape from php inside my header fucntion, and just not > print it.. > eg. > function header() { >?> > } Yes, i remember now, thanks ;-) I've been using Smarty (smarty.php.net) for so long now that i've forgotten how this stuff works without it hehe... This is a script for a few mates that dont have php knowledge, just raw html output Thanks.. -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Outputting HTML with PHP - Buffer Problem?
* and then John Holmes declared > >How come I dont see the html header (it's just a function that returns a > >string with the html up till ) before the entire script has run? > > > >This goes against my understanding, why might this be and what might i > >use to get some output before the script has finished executing? > > Could be your web server buffering the output until the script finishes > or something else on your connection doing the same. Some web browsers > will not show content until everything is received. You could try using > flush() to see if that helps. Ok, that makes sense, i was fairly certain that i wasnt mistaken in thinking it should woek the way i expected... Cheers John,.. -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Outputting HTML with PHP - Buffer Problem?
* and then M. Sokolewicz declared > >How come I dont see the html header (it's just a function that returns a > >string with the html up till ) before the entire script has run? > > > >This goes against my understanding, why might this be and what might i > >use to get some output before the script has finished executing? > > > >Much thanks... > that's because it's all sent as 1 single big chunk of data. To get > around this, you should set implicit_flush to 1 (it's in php.ini). > Otherwise, you can also use the PHP ob_implicit_flush() to do this. > Setting it to 1 will flush the output buffer everytime it's written to, > if set to 0 it will do as normal, and buffer it all to send it together. ah... now that makes a lot of sense, ill check that out, much thx... -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Evaluating form posts
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 > > > > > ) > > Thank you in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getting number of unique values out of array
Hi there, I am wondering how to count the number of unique values inside an array. For example, there is an array named country and it containes 3 country names, where Germany is doubled. So I would like to know that there are 2 unique country names in the array. Has anybody an idea how to achive that? Thanx for any help on that, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: getting number of unique values out of array
Merlin wrote: Hi there, I am wondering how to count the number of unique values inside an array. For example, there is an array named country and it containes 3 country names, where Germany is doubled. So I would like to know that there are 2 unique country names in the array. Has anybody an idea how to achive that? Thanx for any help on that, Merlin just use count(array_unique($array)); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to load extensions outside the extension_dir
Hello, You can't, It's a security thing. this doesn't make sense. When PHP is running as CGI, everyone can put it's own php.ini in the same directory as the PHP-script. This will overwrite all settings of the main php.ini. This works as described, but I don't want to put my own php.ini for that, because changes in the master php.ini will not affect my local one, and the changes in the master file might be important. Regards Marten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] I don't understand why !!!!
I just install the PHP 5 ! This is the code 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
[PHP] move_uploaded_file() access error
hi, there! I have a script that basically tries to upload a file to the server. But when the move_uploaded_function is called, it returns these errors: Warning: move_uploaded_file(../Main/ImgStiri/ceva.jpg): failed to open stream: Permission denied in /home/gotech/public_html/Nou/functii.php on line 81 Warning: move_uploaded_file(): Unable to move '/tmp/phpQdW26l' to '../Main/ImgStiri/ceva.jpg' in /home/gotech/public_html/Nou/functii.php on line 81 (Quick note: I'm a newbie to linux and apache, the sever that my host is running. I know I'm an idiot for using Windows and IIS locally fot testing, I'll switch as soon as possible. But the important thing is that it works on IIS). The code is as follows: function HandleImage($name, $caleDest) { if((isset($_FILES[$name]['tmp_name'])) && ($_FILES[$name]['tmp_name'] != '')) { $caletmp = $_FILES[$name]['tmp_name']; $numeFis = basename($_FILES[$name]['name']); return MutaFisier($caletmp, $caleDest, $numeFis); } else return ''; } function MutaFisier($caletmp, $calenoua, $numeFis) { chmod($caletmp,0777); //tried to grant full access to the temporary folder, but it proved useless - i also tried the same on the destination folder, and php issued an error $fisiernou = $calenoua.$numeFis; if(!file_exists($fisiernou)) move_uploaded_file($caletmp, $fisiernou); //the error occurs here // other stuff } So, if you could tell me what the difference is between IIS and apache concerning file uploads, i'd be grateful. Or tell me what I'm doing wrong - because i'm kind of stuck... Thanks a million. Mike
[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 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
Re: [PHP] I don't understand why !!!!
http://www.php.net/manual/ru/faq.databases.php#faq.databases.mysql.php5 --- Alexander Kleshchevnikov, DirectEDI Developer email:[EMAIL PROTECTED] icq: 153617972 --- "Nicolae Serban" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I just install the PHP 5 ! > > This is the code > > $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
Re: [PHP] move_uploaded_file() access error
Mike wrote: hi, there! I have a script that basically tries to upload a file to the server. But when the move_uploaded_function is called, it returns these errors: Warning: move_uploaded_file(../Main/ImgStiri/ceva.jpg): failed to open stream: Permission denied in /home/gotech/public_html/Nou/functii.php on line 81 The webserver user does not have permission to writeo to this directory. before you execute this script use your ftp client to set the correct permissions on the folder. You can start with 777 and go to a more restrictive permission later on if when things are going on smoothly. -- 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
[PHP] Valid Chars....no fun!
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class dependencies
* 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: 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: 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] get_class_vars
* 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] gtk is working in php 5 ?
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
[PHP] safely using input for mail
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! pgp952nCnHrGX.pgp Description: PGP signature
Re: [PHP] Valid Chars....no fun!
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] safely using input for mail
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??
[PHP] How to change font attributes in dropdown?
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: ?> > "; echo " Choose Event "; mysql_connect("$DBHost","$DBUser","$DBPass"); $result=mysql("$DBName","SELECT * FROM Category WHERE Category = 'Ordering' ORDER BY Event"); while ($row = mysql_fetch_row($result)) { echo " $row[0] "; } echo ""; ?> http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to change font attributes in dropdown?
Hello Jeff, You can use the style attribute in like you have done in the So this: echo " $row[0] "; Could look like this: echo " $row[0] "; -- 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: > > ?> > > enctype=multipart/form-data> > > > > echo " onchange=\"document.forms['Event'].submit()\">"; > echo " Choose Event "; > mysql_connect("$DBHost","$DBUser","$DBPass"); > $result=mysql("$DBName","SELECT * FROM Category WHERE Category = 'Ordering' > ORDER BY Event"); > while ($row = mysql_fetch_row($result)) { > echo " $row[0] "; > } > echo ""; > ?> > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to change font attributes in dropdown?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] safely using input for mail
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 Ahh... 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! pgpKH5GWtNSzL.pgp Description: PGP signature
Re: [PHP] safely using input for mail
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] safely using input for mail
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[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
Re: [PHP] Outputting HTML with PHP - Buffer Problem?
yup, you took the words from my mouth... [EMAIL PROTECTED] wrote: > > dirk wrote: > > >The first function you need to call using 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I don't understand why !!!!
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 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp_nlist()
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help With PEAR::DB Connection
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gtk is working in php 5 ?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Evaluating form posts
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 > > > > > > /> > > > > ) > > > > 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MS Outlook 2003 Mail listing
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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to redirect ?
--- 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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Evaluating form posts
--- 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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php