[PHP] Re: Problems with PHP5 RC1
On 19 Mar 2004 at 19:23, Lester Caine wrote: [EMAIL PROTECTED] wrote: I'm trying to run PHP5 RC1 on a Windows 2000 test server with Apache 2.0.47. Mines 2.0.48, but no problem. Upon installation, when I first started Apache again, I got an error message to the effect that php4ts.dll could not be found in the c:\winnt\system32 directory. This is curious for two reasons: first and foremost, if anything is missing, it should be php5ts.dll, not php4ts.dll; second, php4ts.dll never used to be in the system32 directory and that never caused any problems. But it's no use cursing PHP5, so I copied php4ts.dll to the system32 directory and stopped getting the error message. Not a pretty solution, though. First - you did change httpd.conf to point at the new module? Second option, is there something 'extra' in your setup that is from PHP4? Yes, certainly, to the first question, and no to the second. I went over httpd.conf very carefully a couple of times to make sure nothing else in the file refers to PHP 4 or to an old directory. On 19 Mar 2004 at 20:28, Red Wingate wrote: I'm running RC1 on Win2k 2.0.47 without any problems. Make sure u updated your PATH settings as some folders got renamed or moved. Add /path/to/php and /path/to/php/dlls to your PATH setup. Switch 'extensions' to 'ext' in your php.ini as well if you still have an old version from an old PHP5 beta or PHP4 release. I simply copy all needed DLLs to my system32 directory, so there's no need to add anything to my system paths. Also, I went over php.ini with ExamDiff to make sure I wouldn't miss any changes; the extensions directory is properly set. Otherwise consult the updated install.txt for more information As I said, the installation instructions haven't changed much. Mostly, it seems that PHP5 was simply substituted for PHP4 in the text. There's even a bit about it not being safe to use PHP as a module because it's new, which is later contradicted by the statement Now that version 4.1 introduces a safer sapi module, we recommend that you configure PHP as a module in Apache. I'm not complaining because of course these instructions are provided free of charge etc, but you can't really rely on them as being accurate for the latest release of PHP. Thanks anyway, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with PHP5 RC1
I'm writing this message in the hope that some of the people responsible for PHP5 will eventually read it. I have just downloaded and installed PHP5 RC1 according to the instructions found in the package (which are basically the same as for previous releases of PHP). Before relating the problems I've had, I should say that I've been using PHP for about four years now and have successfully performed dozens of installations, under Windows, Linux and FreeBSD, so I'm not exactly a newbie having a go at his first install. I'm trying to run PHP5 RC1 on a Windows 2000 test server with Apache 2.0.47. Upon installation, when I first started Apache again, I got an error message to the effect that php4ts.dll could not be found in the c:\winnt\system32 directory. This is curious for two reasons: first and foremost, if anything is missing, it should be php5ts.dll, not php4ts.dll; second, php4ts.dll never used to be in the system32 directory and that never caused any problems. But it's no use cursing PHP5, so I copied php4ts.dll to the system32 directory and stopped getting the error message. Not a pretty solution, though. I then edited php.ini to load the extensions I need, and noticed that the php_domxml extension is no longer an option, so I assumed that DOM XML is now bundled with PHP. As a matter of course, phpinfo() tells me that DOM/XML is enabled and that the libxml version is 2.5.11. However, when trying to use domxml_version(), domxml_new_doc(), domxml_open_mem() or any other DOM XML function, I get a call to undefined function error. If these functions now have new names, they're not listed in the online documentation. Am I doing something seriously wrong or are these problems with PHP5 RC1? Thanks, Erik
[PHP] Regular expression checker
Hello all, For a while I tried in vain to find a decent regular expression tester. The closest I found was RegExpEditor, by the same people who produce PHPEdit, but I found it to be slow and didn't like its constant bitching about invalid delimiters or some such thing. Anyway, I ended up writing a little tester for Perl-compatible regular expressions and thought I'd share it with you. Maybe it'll come in handy to people who often need to use regular expressions in their projects. Just copy the code below the dotted line (which has Unix line breaks) and save it to a file. Cheers, Erik html head meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 titleRegular Expression Tester/title ?php( isset($_POST['text']) isset($_POST['regexp']) ) { $error = false; if($_POST['mode'] == 'one') { if( @preg_match('/'.$_POST['regexp'].'/', $_POST['text'], $matches) === false ) { $error = true; } } else { if( @preg_match_all('/'.$_POST['regexp'].'/', $_POST['text'], $matches) === false ) { $error = true; } } } ? /head body style=font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; form action=?php print $_SERVER['PHP_SELF']; ? method=post enctype=multipart/form-data table width=750 tr td width=135div align=rightRegular expression:/div/td td width=591 input name=regexp type=text size=87 ?php if( isset($_POST['regexp']) ) {print 'value='.$_POST['regexp'].'';} ? / /td /tr tr td width=135div align=rightText:/div/td td width=591 textarea name=text rows=6 cols=65 ?php if( isset($_POST['text']) ) {print $_POST['text'];} ? /textarea /td /tr tr td width=135div align=rightMode:/div/td td width=591 select name=mode option value=one ?php( isset($_POST['mode']) $_POST['mode'] == 'one' ) { print 'selected'; } ? First match/option option value=all ?php( isset($_POST['mode']) $_POST['mode'] == 'all' ) { print 'selected'; } ? All matches/option /select /td /tr tr td width=135nbsp;/td tdinput type=submit value=RUN TEST/ nbsp;nbsp;nbsp; input type=reset value=CLEAR FORM//td /tr /table /form p/ div style=background-color:#00; color:#FF; table width=750 border=10 bordercolor=#00 ?php($error) { exit('trtdspan style=color: lime; font-weight: bold;'. 'Invalid regular expression!/span/td/tr'); } ( isset($matches) !empty($matches[0]) ) { print 'trtd colspan=2 style=font-weight:bold;Full match(es):/td/tr'. 'trtd colspan=2nbsp;/td/tr'; if( !is_array($matches[0]) ) { print 'tr'. 'td width=25 style=font-weight: bold;1/td'.\n. 'td'.htmlentities($matches[0]).'/td'. 'tr/'; } else { foreach($matches[0] as $key = $val) { print 'td width=25 style=font-weight: bold;'.($key+1). '/td'.\n.'td'.htmlentities($val).'/td'.\n. '/tr'; } } } { print 'trtdspan style=color: lime; font-weight: bold;'. 'No matches found./span/td/tr'; } ( isset($matches[1]) !empty($matches[1]) ) { print 'tr width=100%td colspan=2nbsp;/td/tr'. 'tr width=100%td colspan=2hr//td/tr'. 'tr width=100%td colspan=2nbsp;/td/tr'. 'tr width=100%td colspan=2 style=font-weight:bold;'. 'Sub-pattern match(es):/td/tr'. 'tr width=100%td colspan=2nbsp;/td/tr'; for($i = 1; $i count($matches); $i++) { if( !is_array($matches[$i]) ) { print 'tr width=100%'. 'td width=25 style=font-weight: bold;'.$i.'/td'.\n. 'td'.htmlentities($matches[$i]).'/td'. '/tr'; } else { foreach($matches[$i] as $key = $val) { print 'tr width=100%'. 'td width=25 style=font-weight: bold;'.$i.'.'.($key+1). '/td'.\n.'td'.htmlentities($val).'/td'.\n. '/tr'; } } if( isset($matches[$i+1]) ) { print 'tr
[PHP] Re: PHP Sessions - One Server, Many Terminals
Damon, Sessions have to do with requests being sent by browsers to the web server. Each time you close all the windows of your browser on your computer and start the browser again, a new session is started. I suspect that since all your users are essentially using the same web browser (since their monitors and keyboards are not really separate computers, but peripherals on the same machine), a browser window open on one terminal is keeping alive a session started by another user on another terminal when she or he first started the browser. Does that make sense? Anyway, if that's your case, then I don't believe there's anything that can be done. Erik On 16 Mar 2004 at 13:04, Damon Abilock wrote: I'm having a problem related to PHP sessions in a school computer lab environment. I have a script that uses sessions to keep track of a user and their work on the system. It is being used by a school in a computer lab in which the students just have terminals -- they all access the same server computer to run programs and do not have hard drives of their own. They are running software called ClassLink (see www.classlink2000.com) in this lab (I'm not sure if that is really an important detail or not). The problem is that everyone that students accessing the script on these different terminals start seeing eachother's work, which implies that the session information is not unique to each terminal (I expect that if I printed out the session ID on all of these different terminals, they would all be the same). Is there anything that I can do about this? How do I get my script to recognize that it is being accessed by different terminals, even though it is really only one physical computer (the server that all of these terminals have a view into)? Is there any other solution? Cheers, Damon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with arrays
Hello Elliot, On 11 Mar 2004 at 23:55, Elliot J. Balanza wrote: I need to make a query to a MySQL database that only has two fields, name value. That I can do. Then I need to store the values i receive in an array in the form of: $variable['name'] = value; But haven't been able to do it neither with a foreach nor with a do while... Can anyone please assist me? Assuming you've read the introductory sections of the PHP manual and are not trying to get other people to spend their time on your project so that you won't need to spend yours, please show us your code so that we can help you spot the problem. Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Loosing redirect in if...else
Hello Alex, On 11 Mar 2004 at 10:15, Alex Hogan wrote: if(empty($_SESSION['sellocation'])){ $_SESSION['selloction'] = '0'; Have a close look at the array member above. It's spelled differently from the others (an A is missing). } $_SESSION['sellocation'] = $_POST['sellocation']; if($_SESSION['sellocation'] == '0'){ $errormsg = true; ? script redirect('cf_survey.php?cf=0'); /script ? } [snip] a href=cf_survey.php?cf=1q1=1 This seems to be where I run into trouble. When the user selects the main question choice and the page reloads I get an error that the index 'sellocation' is not set. If I change the expression to something like this; if(empty($_SESSION['sellocation'])){ $_SESSION['selloction'] = '0'; } else{ $_SESSION['sellocation'] = $_POST['sellocation']; if($_SESSION['sellocation'] == '0'){ $errormsg = true; ? script redirect('cf_survey.php?cf=0'); /script ? } I loose the redirect on the drop down. What am I missing? I'm having trouble understanding how your application works. For starters, I don't see where $POST['sellocation'] is being set, because you didn't provide us with that part of the code. It's true that, as it didn't make immediate sense to me, I didn't bother reading the code again because I don't have much time. A couple of things off the top of my head that may or may not be related to your problem: (a) if you're using any values sent via the URL string (e.g. cf=0), you need to use $_GET, not $_POST; (b) empty() will also evaluate to true if the value of the variable is zero. Good luck, Erik
[PHP] Re: PHP class for XSL transformations?
On 20 Feb 2004 at 16:25, Juan Torres wrote: you try with XMLDOM Functions. You look this function: DomXsltStylesheet-process -- Applies the XSLT-Transformation on a DomDocument Object Thanks Juan, but I'm actually looking for a class that I can upload to a site rather than an extension that has to be compiled into PHP. The reason is that some of the hosts on which I need to run my code do not have either the XSLT or the DOM XML extensions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHPSESSID and URL rewriting
On 19 Feb 2004 at 17:15, seba wrote: Unfortunately I do can not oblige users which will use those pages to accept cookies . The pages are for an e-commerce web site. If I use the directive session.use_trans_sid = 0 is not possible to MANTAIN THE SAME phpsessid value among differents pages, isn t it? Well, in this case you cannot have your cake and eat it too. Either you expect your users to accept cookies or you propagate the session ID via the URL string, the former being safer and more convenient. Frankly, in this day and age people being afraid of cookies is like girls being afraid that they'll get pregnant if they kiss a guy. Furthermore, someone who doesn't accept cookies is shut out from millions of web sites out there, so I shouldn't think you'll find that many no-cookie activists. It is true, however, that some e-commerce sites like Amazon.com propagate session IDs via the URL string, so you won't be alone if you choose to accommodate users who won't accept cookies. Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem handling files.
What are the contents of your file? You do realize, I hope, that whatever is in the file is going to be output to the browser, so any HTML tags in the file will be processed before anything is displayed in the browser. Have a look at the resulting page's source code. On 20 Feb 2004 at 10:15, php wrote: I have a bit problem with following script in php: ?php $fichero = /var/www/php/fichero/fichero1.txt; if ($fp=fopen($fichero,r)) { print ( El fichero ha podido abrirse. ); fpassthru($fp); } else { print (El fichero no ha podido abrirse.); } ? fpassthru doesn't work. I can see: El fichero ha podido abrirse. on the navigator, but I can't see the content of: /var/www/php/fichero/fichero1.txt I have php 4.1.2 on debian-woody. Could you help me with this problem? Thank you in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP class for XSL transformations?
Hello all, I'm looking for an alternative to PHP's XSLT extension. Does anyone know of a good PHP class capable of performing XSL transformations? Thanks for your time, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XSL-FO
Hello Juan, On 18 Feb 2004 at 13:51, Juan Torres wrote: Does PHP allow parser a XML with a XSL-FO and create a PDF? Your English is kind of difficult to understand, but I guess you want to know if you can perform XSL-FO transformations with PHP. If this is your question, the answer is 'no': PHP does have an extension to perform XSLT transformations, but not XSL-FO. Maybe someone out there has developed a class to do this? Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHPSESSID and URL rewriting
Hello Seba, Check your php.ini file: you'll probably find that session.use_trans_sid is set to 1, which is actually a security hazard. If you set session.use_trans_sid to 0, session IDs will no longer be automatically sent as GET variables. Cheers, Erik On 19 Feb 2004 at 13:15, Seba wrote: Hi everyone, I have this situation: I use some regular expressions to rewrite the URL of a web site, in particular: http://www.mysite.com/lingua-ita/colore-rosso/pagina.html that becames http://www.mysite.com/pagina.php?lingua=itacolore=rosso. Is all ok until I use some session variables. It happens that the string ?PHPSESSID=[valore] is merge to the link and this will cause a damage in the URL rewriting. Note that the string comes merged by the browser (Explorer, opera) to the link I wrote before. (http://www.mysite.com/lingua-ita/colore-rosso/pagina.html?PHPSESSID=f4s6f5d4fs65df4s65fd4). Since the links first come in this format, then are rewroted by the rule in the file htaccess and finally parsed by the webserver (apache , IIS), How can I avoid it? I tried with: RewriteRule (.*)?PHPSESSID=(.*) /PHPSESSID-$2/$1 as last rule, but it didn't work. Can you help me? thanks in advance Seba -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Mimetypes and image uploads
On 19 Feb 2004 at 15:53, [EMAIL PROTECTED] wrote: I just discovered something totally bizarre with file uploads and mime types, if i have the document open i am trying to upload say a word file application/octet-stream and if i close the document application/msword , why is this ? My guess: MS Word locks a file while it's open, so it's being copied before it's uploaded. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to deal with http and https directory structures?
Hello Chris, On 17 Feb 2004 at 15:39, Chris W. Parker wrote: anyone have any thoughts on this? am i making this more complicated than it is? ;) Well, yes and no. You're trying to organize your files so that each set is only accessed via one protocol (http or https), which makes pretty good sense from an administrative point of view. On the other hand, you're not necessarily *required* to do that: unless your web server somehow directs all https traffic to a separate branch of your web directory structure, users can access any file on the server via either http or https (provided, of course, that your web server is properly configured). What this means is that you can have a user access a certain page via https by simply providing a link containing https://; as the prefix. The down side of this solution is that users will be free to *not* use https by typing the path to the page directly into the browser without the https://; prefix. Am I making this even more confusing? :o) Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP (and optionally MySQL) textbook
On 17 Feb 2004 at 21:24, Chris wrote: I am looking for suggestions for a textbook for an undergraduate class introducing PHP and MySQL (using PHP, not MySQL administration). Right now I am using the McCarty book PHP 4 A Beginner's Guide but there might be new and/or better books out there? The text is critical because these students will be taking a self-paced, independent learning course using the text, web site, in consultation with a distant faculty member... so it is a bit different than a text I would use in a face-to-face class... and these are true beginners! Any recommendations would be helpful. Thanks! You can't go wrong with Luke Welling and Laura Thomson's PHP and MySQL Web Development. Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problem with resultset
Hello Angelo, On 17 Feb 2004 at 11:21, Angelo Zanetti wrote: I am querying a db and getting the resultset, then to get out each individual field of the resultset (which is a single unique line all the time) as mysql_result($result2, 0, p_company). the problem is that if the actual field has a space in it say Sun microsystems, I only get sun and it doesnt give me anything after the first space. Weird, weird, weird. I'm afraid I don't have a solution to this specific problem, but may I ask why you're using mysql_result() instead of mysql_fetch_object() or mysql_fetch_array()? I've been coding in PHP for over four years and can't remember using mysql_result() on a single occasion. (Granted, it could very well be that I'm dumb, but at least you have something to think about.) Cheers, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Opening a popup window?
Hello Shaun, On 16 Feb 2004 at 22:23, Shaun wrote: I have a form on a page. If certain options are selected on that page I need a popup window with a select option on there to appear. How can I make this happen with PHP, or do I need to use some JavaScript? PHP is a server side scripting language, which means it is parsed by software on the server before anything is sent to the client. That's why you don't see any PHP code if you look at the source of a web page on a client machine. The opening and closing of windows, on the other hand, is something that happens on the client side and depend on the client's browser, among other things. PHP has *nothing* to do with the client's browser other than the fact that it receives some identification information from the browser. In order to pop open windows or do anything else on the client's computer, you'll need a client-side scripting language, i.e. one that is processed on the client's computer. One such language is JavaScript, which will take care of all your window-opening needs. Hope this helps, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: General Function usage question (simple)
Hello Dave, You'll find all this information and much more in the PHP manual ( http://www.php.net/docs.php ). Look for the chapter on functions. Have fun, Erik On 14 Feb 2004 at 7:31, Dave Carrera wrote: Hi List, Here is an easy one for you :-) --- Example1 Function --- Function MyTestFunction(){ // do something here } --- Example2 Function --- Function MyTestFunction($var1,$var2){ // do something here } My question is what do or where do or why are the $var1 and or $var2 included inside the brackets of a function. What do they do ? Why are they in there ? And how are they used within an application ? I am very sorry for the basic question but I am new to the world of functions. Thank you in advance for any explanations, help or explanatory urls that you may impart. Dave C -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Session, loging users in.
Hello Philip, On 14 Feb 2004 at 18:48, Philip J. Newman wrote: Whats the best information to add to a session to say a user is logged in? I currently have $siteUserLogIn=true; anything else that I could add to beef up security? You'll find an in-depth answer to your question in an article by Chris Shiflett recently published in the Jan. 2004 issue of PHP Magazine, which you can download for free from http://www.phpmag.net . Cheers, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Browser Detection another page
Hello Joel, Before you read my comments below, let me say that I'm not trying to prove you *wrong* or even express disagreement with the points you made; I'm just interested in your reasons. On 12 Feb 2004 at 20:11, joel boonstra wrote: Hopefully you're aware that $HTTP_USER_AGENT is an unreliable variable, in that it is sent by the client, and can contain virtually anything. Sure, but why would a user want to fake their browser signature? The worst that could happen is that the offending user would be redirected to a page that wouldn't look good in her/his browser. Or am I missing something here? I saw a response letting you know how to do this, but I would recommend not sending people to different pages based on which browser/OS they're using. Why not? Isn't that what most of the big web sites do? It should be possible to use CSS/(X)HTML to present your content in a way that is accessible to whichever browser accesses your site. IMHO, browser-sniffing to serve different content is a bad idea. What about obsolete browsers that don't handle CSS too well (or not at all)? We developers would love to have all our visitors use the most recent browsers, preferably ones with a good implementation of the JavaScript DOM and XSLT transformations, but that's unfortunately not what happens in the real world. Could you throw in another 2 cents? :o) Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Mp3 with php?
Hello Carlos, On 12 Feb 2004 at 18:52, carlos castillo wrote: does anyone know how to reproduce a mp3 file with php? If my Spanish serves me right, what you want to do is play an MP3 file. Well, that's something that would happen on the user's computer and would depend on the presence of a sound card, loudspeakers, appropriate plug-in etc. PHP is a server-side scripting language and has nothing whatsoever to do with the user's computer. What PHP can do, of course, is handle the storage of MP3 files on the server and send HTML embed tags (for instance) to the user's browser. Hope this helps, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: weird header() (bug may be)
On 12 Feb 2004 at 17:20, adwinwijaya wrote: Hello php-generaler's , I have a script like this : if($foo == 'something'){ header('Location:to_another_page.php') ; }else { do another thing in here } header('Location:to_previous_page.php'); I got a problem ... when $foo == 'something' .. it wont redirect me to to_another_page.php but if I put die(); after calling header(); .. it will work ... is this the bug ? You're joking, right? Your second header statement is outside the if/else loop, so it's executed every time, obviously. This in turn means that your script will always redirect to previous_page.php, unless, of course, you kill it before it gets to the second header statement. Suggestion: read up on control structures (chapter 11 in the PHP manual). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: form array
On 12 Feb 2004 at 0:29, Matthew Oatham wrote: I have a form on page1 that i want to submit to another php page - page2 the form has the fields input type=hidden name=image[one] value=one input type=hidden name=image[two] value=two input type=hidden name=image[three] value=three Basically I want to have these form field values as an array of values I can loop through on page 2 but what do I put on page 2 too get the array and loop through ? On page two you'll have $_POST['image'] as an array containing elements 'one', 'two' and 'three' ($_POST['image']['one'] etc). This is *pretty* basic, so I'm guessing you'll have to learn some more PHP before you can actually do anything with this array. If you have some experience with other programming languages, you'll probably find that the first few chapters of the official PHP manual (http://www.php.net/manual/en/ ) will get you up and running in no time flat. Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHp Books
Hello Rajani, On 10 Feb 2004 at 12:36, Rajani Anand Iyer wrote: Can someone recommend some good books on PHP Advanced topics. Well, I can advise you on what not to buy, which should help, too. Don't spend your money on Professional PHP4 (Argerich, Choi, Coggeshall, Egervari, Geisler, Greant, Hill, Hubbard, Moore, O'Dell, Parise, Rawat, Sani, Scollo, Thomas Ullman): it's mostly badly written and the really relevant stuff is not clearly explained; you get the feeling (probably pretty accurate) that the book was banged out by a bunch of programmers who cannot write good English and have no experience teaching or explaining things to others or even building a logical argument, for that matter. Don't go near XML and PHP (Vaswani), either. Also badly written and already outdated. In addition, the book doesn't give you any information that you could not easily find on the web. If you already know the basics about manipulating XML with PHP, you won't learn anything new from this book, either. I recently bought Secure PHP Development (Kabir) and it seems to be interesting, but I haven't yet found the time to get past the introduction and a first browse, so I can't really recommend it. But you might want to have a look at its table of contents and a few reviews. Cheers, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Sessions on Win2k
Hello Don, On 11 Feb 2004 at 11:19, Donpro wrote: I've searched the archives and note that many have probelms using session on a Win2K server. I am getting a Undefined index: sessions in D:\inetpub\mydomain\www\forms\formmail\formmail.php on line 768 error. Line 768 is: session_start(); It works Ok on Linux; is there any special Windows configuration? Are you perchance running your script on a machine with an active firewall? I had all sorts of session-related problems and spent ages trying to figure out what was wrong with my code until eventually I read somewhere that ZoneAlarm might interfere with sessions. I shut down ZA and guess what? there wasn't anything wrong with my code after all. Now whenever I need to test scripts involving sessions I disconnect from the Internet and shut down ZoneAlarm. Hope this helps, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: array data
Hello Imran, On 12 Feb 2004 at 1:17, Imran Asghar wrote: Hi, Is not working, is it correct way File1.php ? $colors = array('red','blue','green','yellow'); ? form action=file2.php method=post input type=hidden type name=colors value=?=$colors? /fomr File2.php ? echo $colors[0]; echo $colors[1]; echo $colors[2]; echo $colors[4]; ? imee I'm afraid you'll have to start learning PHP from scratch. The freely-available PHP manual has a fairly good introductory section and you'll also find tons of tutorials for beginners on the web. Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: file downloads using header problem
Hello Joshua, On 9 Feb 2004 at 15:45, Joshua Minnie wrote: Does anybody have any idea to allow for multiple downloads while another one was going on. Maybe some additional headers? I have tried adding headers before and after where I open the file for HTTP/1.1 200 OK and the corresponding headers. I have also tried using a simple meta refresh, but that doesn't work because it won't refresh until the page is entirely loaded. I am at a loss, I can't seem to find answer when I google it either. Maybe I'm just missing something. I don't know. The same script can only send headers to the browser once each time it's loaded. In other words, after a script has been parsed and the page has been loaded, it cannot send more headers to the browser unless you reload it. Since in your case the same script (i.e. same page) does everything, it can only handle one download at a time; that's basically what I think you're missing. A simple solution is to have each download link call a *separate* script (i.e. another page) whose sole purpose is to take care of generating the download, i.e. sending the headers and the file to the user's browser. Think about how ZDNet or Tucows, for example, work: first you choose the file you want to download from a menu (the main download page, which doesn't actually generate the downloads), and then when you click on the download link you're taken to a new page (the one that actually takes care of the download) that tells you to wait a few seconds until the download starts. If you're concerned about security (i.e. unauthorized users downloading files by accessing the actual download script directly without going through the page where they see the file list etc.), you can use some kind of random authorization code that is sent by the main download script via a GET string to the actual download page. That way, if the right authorization code is not received by the script on the page that generates the headers and sends the file to the browser, the download will fail. (Note that I suggested a GET string because you cannot normally start sessions before sending headers to the browser, as session_start() will itself send headers. But you can always play with output buffering if you like.) Hope this helps, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] starting a session
Hello Angelo, On 3 Feb 2004 at 9:36, Angelo Zanetti wrote: is there ever a certain situation where you would have something at the top of your page before session_start();? If so why would it be before session_start();? The closest thing to a certain situation that I can think of is when want to set session variables only if certain conditions are met (e.g. only if the password submitted by a user matches the one in the database). In this case, for obvious reasons, you'll need PHP code before the session_start() statement. Does this help at all? Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Document Management and publishing
Hello Jon, On 30 Jan 2004 at 10:57, Jon Shoberg wrote: Might anyone be able to recomend a PHP based (or Java/Perl/Python) based document management system? I'm looking to being a LARGE collection of PDF documetns online. The focus of this application isn't necessarily publishing articles but equally managing files and assiciating certain informaiton. Looking at PHP-nuke and the like it didn't quite fit the bill. Any suggestions? I developed a file library application a while ago for my previous employer and it's been in use for a couple of years now, so it's pretty stable. It uses a MySQL backend and stores all files in the database, which I thought was brilliant at the time but now know not to be the best solution if the use is intensive. At the time I was getting started on OOP, so the code is not the most elegant (sometimes far from it), but it works. If you want, you can have the code for free (I retained the rights over it). You'll probably need to edit a few things here and there to suit your specific needs, but it may save you a lot of time. Cheers, Erik P.S. If you need to e-mail me privately about this, include the list's e-mail address in the FROM field of your message, or else it'll be automatically expunged by my spam filters. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] The PHP Problem
Hello Ashley, On 30 Jan 2004 at 18:51, Ash wrote: Hi, I am totally new to PHP and dont know a thing. I tried looking through the articles but they were of no use. My Question is: How can I just write php in a text editor, save it as a .php, and view it in internet explorer, offline? I have tried everything and it just wont work. I tried the code: ?php echo Hi, I'm a PHP script!; ? in a .php file and nothing happened. Nothing will work, help! I dont have a website, I just want to write and use the code. I'm afraid things are not quite that simple. A PHP script requires a processor to interpret the code and do whatever needs to be done, so you'll need to have the processor on your computer. If you don't really know what you're going to be doing with PHP and just want to play around with a scripting language without having to install a web server and a PHP interpreter, try JavaScript. One of a million sources of introductory info on JavaScript: http://www.w3schools.com/js/js_intro.asp More info on obtaining and installing PHP here: http://www.php.net/manual/en/installation.php Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP PLEASE PHP
Hello Patrick, I have good news and even better news for you. The good news is that you can make all your form-related woes disappear in less than a day. The even better news is that everything you need to know in order to solve your problem can be found in one convenient location: http://www.php.net/manual/en/index.php You'll probably be able to fix your form just by reading sections I and II. By the way, punctuation was invented for a reason, you know. You might want to consider using it. Good luck, Erik On 29 Jan 2004 at 1:56, Patrick wrote: Hi, I have an situation on my hands I have a form that I am stuck using PHP for thanks to my friends choice of hosting company, I have no idea on how to setup a form in PHP other than HTML or in Flash, I need some one any one to give me some advice on this Posted layout it seems to work but not really, I managed to get it set up but for some reason when you hit Submit and an error message goes off at the top the form is Reset. Other than that I am not sure I wrote all the code correctly. Sorry About the long post Any advice would be great. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] eregi_replace help needed
Hi Nico, On 29 Jan 2004 at 17:52, [EMAIL PROTECTED] wrote: I want to locate patterns such as 12345678 1 23 45 67 89 1 2 34 567 890 and replace the pattern string with a new string. I tried $filter['message'] = eregi_replace([0-9\s]{4,},'string replaced', $filter['message']); Use preg_replace() with the i pattern modifier instead of eregi_replace(), e.g. preg_replace('/[\d\s]{4,}/i', 'string replaced', $string) Works like a charm. Cheers, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Encoding for uploaded files
On 29 Jan 2004 at 10:47, craig wrote: specifally, you want: $_FILES['userfile']['type'] = The mime type of the file, if the browser provided this information. An example would be image/gif. That's basically it and will work for common file types. However, it's the user's browser, not PHP, that identifies the MIME type of the file and sends this information along with the file. This means, first, that some browsers will send you the information (or the *correct*) information while others may not, and, second, that some file types will not be recognized by the user's browser and the file type available to PHP will be an empty string. So, as you can see, you can't really rely on this kind of information for anything critical to your application. Cheers, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deleting cookies won't work
Hello Andrew, On 29 Jan 2004 at 21:05, Andrew Wood wrote: I'm calling it with the same arguments as I used to set it originally, but with a null string value an expiry time in the past but the cookie persistently remains in the browser. From the PHP manual: Cookies must be deleted with the same parameters as they were set with. If the value argument is an empty string (), and ALL OTHER ARGUMENTS match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client. Also from the PHP manual: Cookies will not become visible until the next loading of a page that the cookie should be visible for. Don't know if the second snippet bears on your problem, but it might be worth considering. Do you specifically need to use cookies for some reason? If you don't, consider using session variables. (Session variables involve cookies, but they're all set and removed automatically by PHP without your having to worry about it.) Lastly, do you have some kind of firewall running on the machine on which you're testing your scripts? ZoneAlarm, for example, does all sorts of weird things to PHP sessions, and since sessions often depend on cookies, who knows? I really don't understand very well how firewalls interact with Apache/PHP, but this is definitely something else worth considering. Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] addslashes stripslashes
Hello Will, On 28 Jan 2004 at 12:31, Will wrote: However recently I encrypted some data which I stored in the database. The string contained a \ which I added slashes to when entered in to the database. But as the database appears to strips the first slash off the double slash automatically. Upon retrieving the data and strip the slashes off it, my data is now corrupt as there werent double slashes it was just a single (like it was supposed to be) and that got removed by the function instead of the extra one. Just adding to Marek's response in an attempt to make things clearer for you. I think what's bothering you is the fact that you don't see the backslashes added by addslashes in the strings stored in the database. Well, that's because they are *not* actually added to the strings; they simply tell the database to treat whatever character comes after them (them = the backslashes) as regular text, not as symbols with special meanings (such as quotes, which MySQL would normally sees as string delimiters, not actual quotes in a string of text). Since no backslashes have actually been added to the strings stored in the database, you don't need to (or, rather, should not) use stripslashes when retrieving the strings from the db. By the way, consider using mysql_escape_string or mysql_real_escape_string instead of addslashes; consult the PHP manual for more info on these functions. Cheers, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP EDITORS
Hello John, On 28 Jan 2004 at 0:10, John Jensen wrote: Hello everyone. I am new to PhP and MySQL. I was wondering what a good (Or Free) Php Editor is? If you want something nice and simple to start with, try WinSyntax (http://www.winsyntax.com). If you want a very nice and configurable editor that has loads of great plugins for other technologies (such as XML/XSLT), go straight to jEdit (http://www.jedit.org). If you want a nice IDE with lots of menus and helpers, try either PHPEdit (http://www.phpedit.org) or Maguma Studio (http://www.maguma.com/products.php?article=free). My suggestion is that you download them all, have a go at each one and keep the one you find more intuitive and feel most comfortable with. Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Remove Dynamic String between StringA and StringB
On 27 Jan 2004 at 13:25, Jack Bauer wrote: i tried your code zu replace some parts of a string, the problem is that this method only replaces when there is only 1 word between stringA and stringB. Of course. \w* will match alphanumeric characters, but not whitespace, and word boundaries are typically whitespace. i really tried to use the php manual and google to find some help for this, but i got no luck with that :( It's not a question of luck; it's a question of investing a little of your time in reading and learning. You don't want to spend your time doing that but expect other people to spend theirs providing you with all the answers you need. You've been given a few pointers (such as the online introductory guide to regular expressions, which will tell you everything about matching word characters, non-word characters etc etc) but don't seem to have taken any interest in them, because of course that would mean you'd have to actually spend an hour or so of your valuable time doing some reading. Bear in mind that other people's time is *also* valuable. i think it have to do something with the \w in the pattern, is there a parameter to resolve my problem too? Go to http://msdn.microsoft.com/library/en- us/script56/html/js56reconIntroductionToRegularExpressions.asp and read it, especially the Regular Expression Syntax section. After doing that, read the relevant part of the PHP manual. Things will start to make sense soon enough. Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Script timeout?
Hello Ben, On 27 Jan 2004 at 9:27, Ben Ramsey wrote: I'm trying to run a query against a database with a PHP script that cycles through each record (about 4,000+) and sends and e-mail to them if they have an e-mail address present. The problem is that everytime I do this, it processes about 430 records and stops. There is no error message generated. Could this be due to a script timeout? If so, how do I raise the timeout value? Look up set_time_limit in the PHP manual. Also, consider retrieving all the records first with a single db query, storing all e-mails in an array, and then sending out the e-mails in a separate operation. Why query your db 4000+ times when you can query it only once? Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random questions from database
Hello Alex, On 27 Jan 2004 at 9:25, Alex Hogan wrote: while($row = mssql_fetch_array($result)) { $id[] = $row['id']; $ques[] = $row['question']; } To keep question and id together even after shuffling the array, why don't you build an array of arrays like this: $i = 0; $questions = array(); while( $row = mssql_fetch_array($result) ) { $questions[$i]['ques'] = $row['question']; $questions[$i]['id'] = $row['id']; $i++; } srand((float)microtime()*100); You don't need to seed the random number generator if you're using PHP 4.2.0 or above. shuffle($ques); (...) What I'm wanting to do now is to add the id for each of the questions so that I can track which one is the correct answer and which are the distractors. I will have something that looks like this. Foreach($ques as $ranQues){ echo trtda href=\$id\$ranQues/a/td/tr\n; } My problem is keeping the $id with the $ranQues after I do the shuffle. That's not a problem if you follow my previous suggestion. All you need to do is: foreach($questions as $ranQues) { echo trtda href=\$ranQues['id']\$ranQues['ques']/a/td/tr\n; } Hope this helps. Erik
Re: [PHP] sending mail with attachment problems
Hello Tony, On 27 Jan 2004 at 16:47, tony wrote: Hi, i'm trying to send emails with attachment but i get an error (...) I haven't even had a look at your code, but sending e-mails with attachments can be quite tricky, so I suggest that instead of trying to re-invent the wheel you use Richard Heyes's excellent (and free) HTML Mime Mail class available at http://www.phpguru.org/mime.mail.html . Cheers, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] drop down list not populating
Hello Dan, On 27 Jan 2004 at 14:31, Montagna, Dan wrote: echo OPTION VALUE=.$row['community']./OPTION; Uh-oh, this won't work: you have an unclosed tag here. Try this: echo 'option value='.$row['community'].''.$row['community'].'/option'; Good luck, Erik
Re: [PHP] odbc functions - not binary safe?
Hello CC, On 26 Jan 2004 at 12:47, C C wrote: Hi, I'm trying to insert binary data into a MS SQL Server database. Text files are added fine, but binary files with null bytes are not. The field I'm adding the binary data to is image type. I get an error about unclosed quotation marks at the null byte, but I've replaced ' with ''. I tried escaping the null byte with a backslach, but it just changes it to the string \0 when I download it. Anyone have any ideas about this? I don't have any experience with MS SQL, but imagine that escaping the input properly is crucial. Have you tried using mysql_escape_string? Contrary to what the name of the function suggests, it can be used to escape strings (even strings of binary data) for insertion in databases other than MySQL. The prototype of the function is: STRING mysql_escape_string ( STRING unescaped_string ) My suggestion is that you try running your input through mysql_escape_string *only* and see if it does the trick. If you do that, please let me (us) know the results; I'm curious. Cheers, Erik
Re: [PHP] Xml documents to html
Hi John, On 26 Jan 2004 at 21:42, John wrote: How can I show xml files which have been created in MS Word, in a browser as ie Html. Is this posible and what would it take. The short answer to your question is Yes, it's possible. As for what it would take, the answer is a little longer. First of all, you need to decide whether or not you'll expect your target audience to have latest-generation browsers (Netscape 7.x, IE 6, Mozilla 1.4 etc). If you go with the latest-generation-browser-only alternative, all you need is a suitable XSLT stylesheet attached to your XML file; to attach a stylesheet to an XML file you simply open it (manually or with PHP), insert a suitable processing instruction and re-save the file. For more information on XSLT, start here: http://www.dpawson.co.uk/xsl/sect1/intro.html . If you opt for the old-browsers-welcome alternative, PHP will come in really handy. You'll still need an XSLT stylesheet to transform your XML files and output whatever you like, but as most old (and not so old) browsers do not have a built-in XSLT processor (aka engine), you'll *also* need an external XSLT processor, a role that PHP can fill very well. Look up XSLT functions in the PHP manual (chapter CXIII in the function reference section) for more information on utilizing PHP as an XSLT processing engine. Either way, you'll need to learn some XSLT; how much will depend on your needs. Good luck, Erik
Re: [PHP] odbc functions - not binary safe?
Check out the message below, which a user added to the online version of the PHP manual. Could this have anything to do with your problem? ** FROM http://br2.php.net/manual/en/function.mysql-escape-string.php ** sp4m_only at hotmail dot com 02-Apr-2003 10:07 I found out another very curious thing about both AddSlashes() and mysql_escape_string(). It seems that for mysql, the string '##' has some special meaning. Someone told me it might be the beginning of a comment line in the SQL statement. In any case, there is only ONE #-char inserted into the database, instead of two. The two escape functions DO NOT escape this two-char-sequence. So if you want to insert an image in the database and be SURE the image is not f#ck#d up, then do the escaping yourself: $filedata = str_replace('##', '\#\#', mysql_escape_string($filedata)); $query = insert into IMAGES (IMAGE) values ($filedata); $result = mysql_query($query); I hope this will save you guys the ours that I spent by searching for the bug in my own code... On 26 Jan 2004 at 13:29, C C wrote: (...) My suggestion is that you try running your input through mysql_escape_string *only* and see if it does the trick. If you do that, please let me (us) know the results; I'm curious. No, mysql_escape_string didn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: variable container?
Hello Jake, On 26 Jan 2004 at 17:55, Jake McHenry wrote: I want a list of all variables used. I tried just putting var_dump() but got an error. I'd like to see a list of all variables being used in the script, then I can start cleaning original code and what I have added. Some strange results lead me to believe I'm declaring the variables more than once with different values, and I'd like to know if there is a way that I can just get a dump of ALL the variables in use. Unless I'm using the function wrong. Please advise. I don't think you can print out *all* the variables in *all* scopes and their values, but you can certainly get a list of all the variables in the global scope (i.e. all variables except the ones created inside functions and classes). print_r ($GLOBALS) will give you all the super-global arrays ($_POST, $_GET, $_SERVER etc) as well as all user variables created in the global scope. Look for *RECURSION* in the output; that's where you'll find the user variables. Hope this helps, Erik
Re: [PHP] Re: variable container?
On 26 Jan 2004 at 18:21, Jake McHenry wrote: yes, but they're not converted into those yet. all of the variables are with register_globals = on and they're all global vars. I'm converting them all over to session vars, this is why I need to know the list. Just an additional note to my previous post: my suggestion (print_r($GLOBALS)) will work irrespective of whether register_globals is on or off. The variables you create in the global scope (not the ones created from form fields or GET strings) are always global, even if register_globals is off. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Remove Dynamic String between StringA and StringB
Hello 24 fan, On 27 Jan 2004 at 0:56, Jack Bauer wrote: i'm looking for a function to remove multiple dynamic parts of a string, there are only the start and end strings given (remove all between string A and string B) got somebody a working procedure for that? I'm not sure I understand you correctly, but it seems to me that you need to use regular expressions. You haven't provided us with an example or with strings A and B, so it's kinda difficult to give you any specific help. Suggestion: read up on Regular Expression Functions (Perl-Compatible) in the PHP manual (chapter XC in the Function Reference section). If you're not familiar with regular expressions and find the PHP manual too difficult as a starting point, you'll find a pretty good introductory guide, courtesy of the Dark Side of the Force, at http://msdn.microsoft.com/library/en-us/script56/html/js56reconIntroducti onToRegularExpressions.asp Have fun, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trying again: Random(?) blank pages when using sessions
Matt, You're not by any chance using an Apache server on a machine that also has a firewall, are you? I've had all sorts of mysterious session-related problems when running scripts on my test server (Apache on Win2k with a ZoneAlarm firewall). Took me *ages* to zero in on the source of the problem. Now whenever I need to test a script that involves sessions, I simply disconnect from the internet and shut down my firewall. Cheers, Erik On 16 Jan 2004 at 16:32, Matt Grimm wrote: Can anyone think of ways I can troubleshoot this problem? I still haven't found a solution. I'm using non-cookie-based sessions for authentication on a page. The session is set like so, which works (these values, along with the SID, are always retrievable): $_SESSION['user'] = $_POST['UserName']; $_SESSION['time'] = time(); My problem is when I get to the protected site area, in which a header script calls session_start() at the top (first line). Seemingly randomly, while navigating links within this area, I get blank white pages. If I comment out the session_start() line, it doesn't happen. If I spit out the session variables in the resulting page, they are echoed, but that's it -- it's a blank white page otherwise. The apache error log is silent, and the access log is normal. No php errors are displayed or written to the log. Here's the real kicker -- if I refresh the page, it loads correctly. What is going on? Thank you, -- Matt Grimm Web Developer The Health TV Channel, Inc. (a non - profit organization) 3820 Lake Otis Parkway Anchorage, AK 99508 907.770.6200 ext. 686 907.336.6205 (fax) E-mail: [EMAIL PROTECTED] Web: www.healthtvchannel.org -- 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 bought SAMS PHP mySQL WEB DEVELOPMENT:)
Hi there, On 17 Jan 2004 at 21:28, SASSINC Internet Solutions - wrote: Now I have SAMS book for PHP and mySQL but in Arabic.. so now at the moment I only want to learn things which will help me in my project.. so which lessons must I see.. and which PHP Actions will I use for that? What do you mean which actions? I want to make a PHP page that reads from a mySQL Database.. This page displays two fields for the user : 1- Username. 2- Password. Now in the database there are many columns.. each one has many fields : Username, Password, Serial, Phone No., Address..Etc.. Now I want the PHP file to take the Username and Password after the user enter them in the fields and compare them with the ones inside the database.. if they are the same.. the serial field inside the database will send its value to the PHP page.. which will echo it as a variable ($var) there.. Whatever do you want to do that for? What do you need (or want) to accomplish? What kind of project is this? Give us the big picture! So every user has a column that has.. That has...?? Your unfinished sentences presume telepathic powers that few of us have. :-) So which actions must I use.. and which lessons are important for me at the moment? because my project must be finnished in the comming week. What exactly do you expect the people on this list to do for you? Help you with your project because you're running out of time? Most of us are very busy too, so take it nice and easy. Have you opened the book that you've bought and had a look at its table of contents? Have you read the introduction? Authors usually tell you in the introduction which parts you absolutely must read to get up and running. Assuming that your book has a section on PHP, a section on MySQL and a section on PHP interacting with MySQL, you'll probably want to read the first few chapters in each section. When you have a better idea of what it is that you want to accomplish and stumble on a problem that you can't solve, then by all means post a question to this list preferably with a title that reflects the issue you're addressing, not the urgency of your personal needs. Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] random html +(hi)
Hello Angela, On 16 Jan 2004 at 11:30, Angela K Hilton wrote: I'm trying to dynamically randomise a chunk of HTML that is used on a page, aka random image, so that each time a client opens the page [or refreshes] a part of the page changes. The chunks of HTML are saved in their own directory as .htm files. I was hoping to adapt the following code I have managed to cobble together to display random images: ?php // images in folder $total = 5; If the value of $total is not going to change, why even use a variable? // file type $file_type = .htm, .gif, .jpg; What's this $file_type for? // dir location $image_folder = dir/dir; $start = 1; Again, if the value of $start is not going to change, why use a variable? $random = mt_rand($start, $total); $image_name = $random . $file_type; This won't work. You'll end up with something like $image_name = 2.htm, .gif, .jpg;, which is clearly not what you want (or need). // print file name // echo $image_name; // display image // echo img src=\$image_folder/$image_name\ alt=\$image_name\ /; ? I'd like the code to take the HTML and place it in a div/div, probably using a ?php require (); ? (I think I'm OK with this once the code is sorted). Suggestion: have your PHP script open the image folder, read it's contents and load all file names it finds onto an array; then user array_rand() to randomly pick a key. You'll need to get the PHP manual (in case you still don't have it) from http://www.php.net/download-docs.php and read up on opendir(), readdir() and array_rand(). Good luck, Erik
Re: [PHP] UTF-8 and HTTP headers
Hello Jiri, I'm not sure I understand your problem (I had some trouble with your English), but have you tried PHP's utf8_encode() and utf8_decode() functions? Check out the PHP manual in your native language for more information on these functions. Cheers, Erik On 15 Jan 2004 at 12:52, Ji ¡ N mec wrote: Hello, I have problem with encoding UTF-8 and PHP scripts. Scripts send information about encoding and this disallow send HTTP headers. Is possibility to solve this problem? Jiri Nemec -- 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] addslashes
Hello João, On 15 Jan 2004 at 17:07, João Cândido de Souza Neto wrote: I'm using str_replace(\r\n,\\r\\n,addslashes($campo)) to add \ in mysql data to send to javascript variable. Running in my machine with win xp + iis it's all ok, but in server with linux + apache, the javascript variable no have \ causing error in my script. Anybody know how do i do ? (a) Have you tried mysql_escape_string() instead of addslashes() to escape your string? It will automatically escape line breaks and carriage returns as well as single and double quotes and backslashes. Mind you, mysql_escape_string() can be used even if your database is not MySQL. (b) Have you considered that when you use double-quotes around a string (rather than single-quotes) \r and \n get parsed and when you use single-quotes they don't? This may have nothing to do with the problem you're experiencing and I may be saying something stupid, but it might be worth looking into this issue. Good luck, Erik
Re: [PHP] Security issues
Hi Chris, First of all, thanks a lot for sharing your modus operandi with us. On 14 Jan 2004 at 7:32, Chris W wrote: I then verify that every character in the string is with in the ascii range of a space to the ~ which is basically all the characters on the key board. How exactly are you performing this check? Regular expression matching? If so, what regular expression are you using? Thanks, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] nested tags
Gregor, On 14 Jan 2004 at 16:02, Gregor Jaksa wrote: Can anyone provide me with some link or code on how to deal with nested tags. Could you please tell us a bit more about what you want or need? Are you talking about HTML or XML? What do you want to be able to do with your nested tags? You asked a very vague question and are unlikely to get any useful responses unless you explain yourself a little better. Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Week calculating
A quick idea that can probably be perfected: ?php function calc_weekday_dates ($weekday, $year) { $weekday_options = array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'); // Check argument $weekday if( !in_array( strtolower($weekday), $weekday_options) ) { return false; } // Check argument $year. if( $year 1900 || $year 2050 ) { return false; } $ini_date = mktime(0, 0, 0, 1, 1, $year); // Jan. 1 $end_date = mktime(0, 0, 0, 12, 31, $year); // Dec. 31 // The array to be returned. $weekday_dates = array(); // There are 86400 seconds in a day. for( $i = $ini_date; $i = $end_date; $i += 86400 ) { if( strtolower( date('D', $i) ) == strtolower($weekday) ) { // Format the wanted dates. $weekday_dates[] = date('y-m-d', $i); } } return $weekday_dates; } $test = calc_weekday_dates ('Tue', 2004); print 'pre'; print_r($test); print '/pre'; ? Seems to work. Now you can improve on it. Cheers, Erik Fleischer On 13 Jan 2004 at 15:07, nabil wrote: Greetings; I need a help here ... I want to make function that return the dates of Tuesdays in a given year Example:: Calc_Tuesdays (2004); //and it should return or echo 2004-01-06 2004-01-13 2004-01-20 2004-01-27 2004-02-03 . . etc ofcourse it should echo 5 Tuesdays in March by example so it should depends on the year not only current day+7 any help please !! Nabil -- 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] problem with preg_replace
Hello Gregor, On 13 Jan 2004 at 15:08, Gregor Jaksa wrote: hello, i need to replace some words in file with [tag]word[/tag] and other words with [sample]word[/sample]. i have a list of words which i need to replace with [sample] tags declared like $words = 'word1|word2|word3|word4'; replacing those words is easy i just use preg_replace('/\b( ' . $words . ')\b/i', '[sample]$1[/sample]', $file); but how to replace all other words that are not in $words array with [tag] tag ? thx in advance! Let me see if I understood you correctly: you want to surround all the words in the string $file that are not also contained in the $words array with [tag] and [/tag]? Here's an idea: ?php $file = 'this is my test string and I just want to use it for a quick test'; $words = 'test|string'; $new_file = preg_replace('/\b('.$words.')\b/', ' [sample]$1[/sample] ', $file); $new_file = preg_replace('/\b(?!\[sample\]|\[)(\w+)(?!\[\/sample\]|\])\b/', ' [tag]$1[/tag] ', $new_file); print $new_file; ? Very important: you *must not* forget the spaces before and after the opening and closing brackets in the replacement string. Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I write to an XML file
Hello Tim, On 12 Jan 2004 at 17:50, Tim Burgan wrote: I'm wondering if anyone can help me or point me in the right direction regarding how I can write to an XML file. Writing to an XML file works the same way as writing to any other file: you need to open the file with fopen(), append to or overwrite the file contents with fwrite(), and close the file with fclose(). However, In order to do something useful with the XML in your files, you'll also want to read the file right after opening it (i.e. before writing anything to it), parse the XML, insert new elements/attributes/text nodes into the XML, and then write that to the file. The XML parsing and manipulating can be accomplished with the DOM XML functions (see chapter XXIV of the function reference section of the PHP manual) or the XML Parser (Expat) functions (see chapter CXI of the function reference section of the PHP manual). Both sets of functions are PHP extensions, which means they are not enabled by default; on *nix systems, you need to compile these extensions when installing PHP, and on Windows systems you need to enable the extensions in the php.ini file. Alternatively, if you cannot or don't want to install/reinstall PHP on the web server you're going to use, you can use PHP classes that emulate the DOM XML extension. The best ones I know of are miniXML (http://minixml.psychogenic.com) and Domit! (http://www.engageinteractive.com/domit/); both are free and come with fairly good documentation that will explain how to use them. There probably are a couple of classes out there to do Expat-style (chunk by chunk) parsing, but in your case you'll probably want to stick with DOM-style parsing. Good luck, Erik
[PHP] Re: Hiding files away from /public_html/
Hi Philip, On 10 Jan 2004 at 12:42, Philip J. Newman wrote: I want to store some images outside the /public_html/ how ever my isp has decided that i'm not aloud to write files in that area. Would the next best solution that wold be as secure to maybe put them in a folder with a .htaccess file in it? You could use an htaccess file, but: (a) the Apache web server must be configured to allow htaccess to over-ride authentication settings (which, from what you've told us, is something you'll have no control over); (b) you'd need to upload an htpasswd file containing username and passwords pairs to the webserver, but wouldn't be able to save it to an off-web directory; and (c) the htaccess file would prevent your own scripts from accessing the image files, which would mean that the user viewing a page with a protected image would need to type a username and password in order for the image to be displayed. Doesn't sound like the best solution to me. Do you have access to a database? One solution would be to store all images on a database and have the image files generated dinamically via PHP. That would imply in some overhead, but it would be fairly secure. If you like the idea, let me know and I'll tell you how I've implemented it in the past. Another much more complicated solution would be to rename your image files with a PHP extension (thus protecting their contents) and create a script to read these files, extract their contents and create temporary PNG/JPG/GIF files on the fly. Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Please help with mail function
Hello Rolf, On 9 Jan 2004 at 0:51, Rolf Berkenbosch wrote: I have a big problem with the mail function in a php script. If I run this script with root access, the mail function is working. If I try to run it like http://www.i-s-u.nl/test.php it won't work. What is happening, what can I do??? The link you supplied is useless, because of course all PHP code is processed at the server and nothing reachers the browser. It's difficult to say what could be going wrong without knowing more about your server setup. My suggestion is that you try using a good socket-based mailing script to circumvent your web server's sendmail shortcomings. You'll find an excellent (free) socket-based mailing script at http://www.phpguru.org/mime.mail.html . Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Please check this program (its working)
On 9 Jan 2004 at 8:20, Ryan A wrote: I dont know if this is the right way to do this, so please have a looksee and tell me. Its working perfectly well...but will I have problems if I try it on a large email list or will it hog resourcesetc? ANY advice appreciated. One step at a time, Ryan. You can't get any serious or useful advice if you don't explain what it is that you're trying to accomplish with your script, i.e., what purpose(s) it serves. One thing I can tell you right now is that SELECT * is rarely a good idea, unless you really are going to use every column in the table you're querying. Consider using SELECT column1, columnx instead. Cheers, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XML?
Hi there, Jake, On 9 Jan 2004 at 2:30, Jake McHenry wrote: Can someone point me in the right direction towards creating and implementing XML with php? I've heard it can make things much easier on me, and would like more info on it. Also, if anyone has any storys from using it, might give me an idea of what I'm getting into. Is it easy to implement? Does it make things easier on me in the future? Etc.etc. First of all, please tell us what use you think you might have for XML. XML can be used in several different ways for several different things, but of course it's completely useless for several other things. Your question about whether or not XML is easy to implement cannot be answered if we don't know what you might be trying to implement. XML is a fairly complex technology that takes some studying; that much I can tell you right now. Cheers, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XML/HTML encoding?
Hello Vincent, On 9 Jan 2004 at 16:23, Vincent Jansen wrote: After xslt I end up with a html document with a souce that looks something like ?xml version=1.0 encoding=UTF-8 standalone=yes? !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN http://www.w3.org/TR/REC-html40/loose.dtd; html head titledotted e (ë) works/title /head body Etc. This is what I want But my browser displays dotted e () works Because I don't want yes or no: Please tell me what (maybe obvious thing) I'm doing wrong I don't think you're doing anything wrong, except perhaps for using an outdated browser. The ë (e-umlaut, which you called a dotted e) displays just fine in both IE 6 and Netscape 7.1 on my computer. Make sure your browser is configured to use Western European (ISO-8859-1) encoding, because even latest-generation browsers have poor support for UTF-8. To change your browser's encoding settings, do: In IE 6: View Encoding In Netscape: View Character Coding Any other browser: figure it out yourself ;-) Take care, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with while loop
Hello Richard, On 7 Jan 2004 at 21:02, Richard Kurth wrote: I can't seam to get this while loop to work properly. It should create a message that has the first two lines and then it will list all the domain that meat the criteria. $lines = The following are web sites that are at 95% usage or more of there web space\n; $lines = Site Name Used(MB) Free(MB) Allowed(MB) \n; Hmm, this has nothing to do with your question, but don't you need a concatenation operator (.) before the equal sign in the second line of code above? $result=mysql_query(SELECT * FROM domplans); while($row = mysql_fetch_array($result)){ $dom=$row[domname]; $total=$row[quota]; $result1=mysql_query(SELECT * FROM datasubused where domname = '$dom'); $proccess = mysql_fetch_array($result1); $totalused=$proccess[quotaused]; $totalfree=$total - $totalused; $percent = ceil(100*$totalused/$total); If($percent=95){ Why is if capitalized? Well, it doesn't affect the execution of the code, but it's bad practice. More importantly, why is the number 95 between quotes? You're comparing numbers, not strings. Granted, PHP will convert the string into a number for you, but that's bad practice again. $lines = $dom $totalused $totalfree $total \n; for( $i=0;$icount($lines);$i++) { Aha! Count lines?! What lines do you want counted? $lines is a string, not an array, so how can you possibly count the number of array elements contained in $lines? $message .=$lines[$i]; } } echo $message; } Perhaps what you really want is to create an array $lines with all the strings that you need and print them at the end. I'm not sure I understand your needs exactly, but wouldn't something like the code below work better for you? /*** CODE START ***/ $dbh = mysql_connect('host', 'username', 'password'); mysql_select_db('db', $dbh); $lines = The following are web sites that are at 95% usage or more of there web space\n; $lines .= Site Name Used(MB) Free(MB) Allowed(MB) \n; $result = mysql_query(SELECT * FROM domplans, $dbh); while( $row = mysql_fetch_array($result) ) { $dom=$row[domname]; $total=$row[quota]; $result1=mysql_query(SELECT * FROM datasubused where domname = '$dom'); $proccess = mysql_fetch_array($result1); $totalused=$proccess[quotaused]; $totalfree=$total - $totalused; $percent = ceil(100*$totalused/$total); $lines = array(); if($percent = 95) { $lines[] = $dom $totalused $totalfree $total \n; } } for( $i=0;$icount($lines);$i++) { $message .=$lines[$i]; } echo $message; /*** CODE END ***/ Hope this helps. Cheers, Erik
[PHP] Re: php on linux..
Hello Khoa, On 8 Jan 2004 at 0:13, khoa vo wrote: index.html-- form action=action.php method=POST Your name: input type=text name=name / input type=submit /form That's fine, but that's not what you have up on your web space. Your form is pointing to action.html, not action.php. action.php-- #!/lusr/bin/php Hi ?php echo $_POST[name]; ?. Ok, you don't need the first line (#!/lusr/bin/php), because this is a script for the web and will be processed by the web server. But you do need to save the file action.php with the .php suffix. I've just checked your online pages and your form is being sent to action.html, not action.php, so the PHP code is not being processed, because your web server doesn't look for PHP code in HTML files. I had a look at the source of your action.html file and it's like this: html Hi. Your name is ?php phpinfo(); echo $_POST[name]; ?. /html The phpinfo() function is going to print a long list of information about PHP on the server, so you might want to remove that. So, to recap, you need to change the action attribute in your index.html file to action.php, and then rename the file action.html to action.php (and maybe remove the phpinfo() function while you're at it). That should do the trick. Good luck, Erik
[PHP] Re: (OT?) form question
Hello Craig, On 7 Jan 2004 at 9:50, craig wrote: This may be more of an HTML question - can't find anything in the php manual, but I may not know where to look. Is it possible to put the cursor into a form element when a page loads without using javascript? PHP does everything it has to do (and can do) on the server, which means it has no control whatsoever over your, or any other user's, browser. It cannot place cursors anywhere. PHP can send to the browser JavaScript code capable of doing what you want, but it's the JavaScript code that would be performing cursor tricks in the browser, not PHP. Take care, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php