Re: [PHP] My Project
Paul Waring wrote: On Tue, Jul 19, 2005 at 09:50:06AM -0700, George B wrote: My money is being stored in a database. And I want everythign to be in PHP, no java script. And the BUY!! Button is a input button from a form. :) Well in that case you probably want something like this (after you've checked to see whether the user is logged in etc): $sql = "UPDATE users SET money = money - 10 WHERE id = " . $_SESSION['user_id']; this does not check if the user has enough money. This query does: UPDATE users SET money = money - 10 WHERE id = $_SESSION['user_id'] and money >= 10 Then check affected rows to see if the money was actually subtructed from the account. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session has new id on 'some' pages.
Andy Pieters wrote: Ok found the solution, seems like one page is on http://server.org.uk and the other on www.server.org.uk even though its the same server it generates a different session id! set the domain of the cookie to 'server.org.uk', it's the fifth parameter of setcookie() -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Error
Holografix wrote: print_r($stmt) prints nothing. print($stmt) print nothing too. I checked errorCode() and it prints . Then it seems $stmt is false. var_dump() is more verbose about it. "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] Holografix wrote: Hi Marek It's print_r($row), not print_r($stmt) ;) That's what I'm asking - If you put print_r($stmt) in that line, what does it print? "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] Holografix wrote: Hi. When using this example from http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I have this error: Fatal error: Call to a member function fetchAll() on a non-object in /www/home/testes/pdo_my1.php on line 17 $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); $stmt = $dbh->query("SELECT * FROM foo"); what does print_r($stmt); print here? $rows = $stmt->fetchAll(); $count = count($rows); foreach ($rows as $row) { print_r($row); } $stmt = null; Wht's wrong with the example? Greetings holografix -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Error
Holografix wrote: Hi Marek It's print_r($row), not print_r($stmt) ;) That's what I'm asking - If you put print_r($stmt) in that line, what does it print? "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] Holografix wrote: Hi. When using this example from http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I have this error: Fatal error: Call to a member function fetchAll() on a non-object in /www/home/testes/pdo_my1.php on line 17 $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); $stmt = $dbh->query("SELECT * FROM foo"); what does print_r($stmt); print here? $rows = $stmt->fetchAll(); $count = count($rows); foreach ($rows as $row) { print_r($row); } $stmt = null; Wht's wrong with the example? Greetings holografix -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Error
Holografix wrote: Hi. When using this example from http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I have this error: Fatal error: Call to a member function fetchAll() on a non-object in /www/home/testes/pdo_my1.php on line 17 $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); $stmt = $dbh->query("SELECT * FROM foo"); what does print_r($stmt); print here? $rows = $stmt->fetchAll(); $count = count($rows); foreach ($rows as $row) { print_r($row); } $stmt = null; Wht's wrong with the example? Greetings holografix -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing special characters
Computer Programmer wrote: Is there a PHP built-in function to retrieve only the alphanumeric characters from a given string? I know that I can check for alphanumeric characters using the function ctype_alphanum () but it won't retrieve the alphanum characters. I also know that I can use str_replace to replace an array of special characters such as the example below: $str = "I*m using with special/chars like | how to get rid of it???"; $removeChars = array ('*','?','|','>','<','/','\\'); $str = str_replace ($removeChars, "", $str); However, could there be a specific function for just retrieving alphanumeric characters? or a specific function for just stripping special characters? Or maybe a better way to do those things from the example given above? $str = preg_replace('/[^a-z0-9]/i', '', $str); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT - Fonts
Richard Lynch wrote: On Tue, July 12, 2005 1:30 pm, timothy johnson said: I am trying to use a font on my webpage that I have on my system only after a friend sent it to me. But its a neat little font that I want to use in a couple place on my site, like some of the headers. So I have two options I think one is to find a way to have the font download and work on the persons browser, this is the one I would like No. I'm not letting you install your stupid font on my computer. Actualy it's not a problem to use downloadable fonts using CSS2: http://www.w3.org/TR/CSS2/fonts.html#font-descriptions It won't install it thought :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IBM's Learning PHP Part 1 tutorial.
Richard Davey wrote: Hello André, Wednesday, July 6, 2005, 3:25:37 PM, you wrote: AM> Depending on the sittuation, IMHO, COUNT(*) wouldn't be the way to AM> go. If you need the user's id or somesuch, you have to run an AM> additional query to get the info. But they're returning absolutely nothing in this case - which (providing username was indexed) would make count() a far quicker and less expensive query than selecting and bring back data and then doing absolutely nothing with it (somewhat pointless imho) You can select just the id, and provided that the query returns just zero or one row, you can spare one function call. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear the page and continue
Fred wrote: Outstanding James! A different approach to get a more flexible result. Fred. or document.getElementById("blah").style.display = 'none'; innerHTML is not supported by many browsers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: constant() - php5
Jason Barnett wrote: Actually, thanks for pointing out this function to me because I never even knew that it existed. You learn something new every day. I have to admit that a warning seems a little unusual given that an undefined variable would result in only an E_NOTICE. Especially since the default behavior for an undefined constant (anywhere except for this function) is an E_NOTICE. Seems like you may have found a bug to report. The above is wrong, use: echo constant('UNDEFINED_CONSTANT'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about HTTP 301 permanent redirects
Jasper Bryant-Greene wrote: Jochem Maas wrote: header('HTTP/1.1 301 Moved Permanently'); also consider that using 'Status' may be better or possibly both to cover you bases, e.g.: Waste of time. Go read the HTTP spec. Apologies for missing the typos, I was rather in a hurry. The point is, it wasn't a 301 redirect. It's not really a waste of time. Some apache/php configurations accept only the first form, some only the second. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange is_dir() behavior
Marcos Mendonça wrote: Hello I'm using PHP 4.3.9, under Windows XP with Apache. I have the following directory structure on a given app, i'm working on. photos/ > folder1 > folder2 > folder3 > ... and so on I'm trying the following code to make a list of folder under photos: $d = dir('photos/'); while (false !== ($entry = $d->read())) { if (is_dir($entry) && $entry != '.' && $entry != '..') echo $entry . ""; } For some strange reason, that echoes nothing. is_dir is returning false on every folder (dir) under photos, except for '.' and '..' dirs. Can someone explain this? is_dir() is checking for 'folder1', 'folder2' etc. You want it to check 'photos/folder1', 'photos/folder2' Use: if (is_dir('photos/' . $entry) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SAFEMODE w/ PEAR
Ashley M. Kirchner wrote: I'm having a small problem with SAFE MODE and PEAR that I'm unsure how to solve: [error] PHP Warning: raiseerror(): SAFE MODE Restriction in effect. The script whose uid is 524 is not allowed to access /usr/lib/php/PEAR.php owned by uid 0 in /path/to/script/Lite.php on line 470 How should that get solved? Everything in /usr/lib/php is owned by root.root and just about everyone wants access to the PEAR library, but SAFE MODE won't allow it? Administrator should put this to php.ini: safe_mode_include_dir = /usr/lib/php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking requested range
Neil Doody wrote: Is there anything in PHP which would allow me to check the requested range of bytes by an client? Basically one of the download scripts I made some time ago got hit by a load of requests for a file, but the server was giving back "416 Requested Range Not Satisfiable". I assume that the user is trying to use a download agent of some kind, but this was killing my server by soaking up all the memory with all these requests. What I wanted to do was check this request and then drop the connection straight away, if it seems suspect, is this possible? Try http://pear.php.net/package/HTTP_Download -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Predictable-random array
Dotan Cohen wrote: I've got an array $items which has about 200 entires. I want to print them out in random order, but as usual, I have a catch! I need to add a 'key' so that if need be, I can always return to the same 'random' order, like so: $items=predicatable_random($items, "qwerty"); so for each place that I need the items rearranged, I will replace qwerty with a different string, and get a different 'random' order. I haven't played around with it much as I stumbled into a brick wall fairly early and can't get much going. Any ideas? I tried to play with usort, uksort, ksort, and various combinations with shuffle. The 'randomization' can be based on qualities of each string, such as 'sort alphebetically by the 7th character', so I thought that I'd try that, but I got lost in explodes and such. Seed the generator with some integer using srand(): srand(384884); $a = range(0, 100); shuffle($a); print_r($a); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pcntl_fork and reading from childs stdout
Tom Fishwick wrote: Hi All, I have a script that spawns off a bunch of children with pcntl_fork(), but I can't figure out how to connect up a pipe from the parent to each childs stdout and stdin. In c I would use pipe,close and dup... any ideas would be appreciated. (that don't involve using proc_open() :-) Tom http://www.php.net/popen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making a page loop with header('Location: ...
Joe Harman wrote: On 6/9/05, Richard Davey <[EMAIL PROTECTED]> wrote: Hello Joe, Friday, June 10, 2005, 12:36:13 AM, you wrote: JH> is it possible to make a page loop with header('Location : JH> page.php')??? JH> I've ran into a little bit of a snag with php execution time... JH> so, i need to execute the page a few times so that I can split the JH> operation up into multiple parts... my other option would be to JH> make a javascript reload Why not just increase the PHP script timeout value to something that works better for your current situation? You can do this from the code itself, not just the php.ini Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services "I do not fear computers. I fear the lack of them." - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hey Richard, I was going to do that... also, I do have access to my php.ini... I was just thinking it wasn't a good thing to do hmmm... would it okay to make it like 5 minutes??? or is that unadvisable... i may be running into apache limits then and also browser limits. if you make the timeout 5 minutes, send some output and flush() every few iterations. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making a page loop with header('Location: ...
Joe Harman wrote: is it possible to make a page loop with header('Location : page.php')??? I've ran into a little bit of a snag with php execution time... so, i need to execute the page a few times so that I can split the operation up into multiple parts... my other option would be to make a javascript reload Location header is once ony redirect. Look at Refresh header. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beautiful HTML Invoice -> Prints like crap! I need somesuggestions!
Jason Barnett wrote: Marek Kilimajer wrote: Matt Babineau wrote: Hi all - I've got a great html invoice that prints like crap because of my user of background images and foreground images. Does anyone have any good suggestions other than turn on images in IE to get this thing to print the graphics? Is there a good way I could convert the HTML view to a JPG? I'm on a linux box and have php 4.3.10. make css for print media: @media print { /* style sheet for print goes here */ } http://www.w3.org/TR/REC-CSS2/media.html ^^^ This is a good suggestion. But if you only need to print just this one invoice then you can also take a full screen shot, paste that into your favorite image program and then print from there. (Usually this is Print Screen on your keyboard). And if it does not fit on one screen, take more screenshots and glue them together in the favorite image program :) The OP's problem is that images are printed, so this crazy solution would not work -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Beautiful HTML Invoice -> Prints like crap! I need some suggestions!
Matt Babineau wrote: Hi all - I've got a great html invoice that prints like crap because of my user of background images and foreground images. Does anyone have any good suggestions other than turn on images in IE to get this thing to print the graphics? Is there a good way I could convert the HTML view to a JPG? I'm on a linux box and have php 4.3.10. make css for print media: @media print { /* style sheet for print goes here */ } http://www.w3.org/TR/REC-CSS2/media.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] linux php editor
Clive Zagno wrote: the truth is Ive been developing on windows, because of some .net developments. Ive been starting most new projects as web applications and using php/mysql. On windows I used ultredit, then I found a product called phpedit, which I liked, now Im trying to move to linux. what I really want is a app that can do that predictive text thing, you know when it start showing me the possible php syntax as Im typing it in. Two reasons for this is it help with debugging as I get the syntax correct the first time and secondly I think its cool. In ~/.vimrc: " autocompletion for php functions set dictionary-=/path/to/funclist.txt dictionary+=/path/to/funclist.txt set complete-=k complete+=k " check syntax of current php file map :w !php -l % -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is faster?
Mark Cain wrote: I see your point about including the timing code in the calculation itself and while it does add time to the process, he is not just timing this code -- he is timing this code against another. Meaning we don't want to know "How fast is this code?" per se -- we want to know "Which is faster?" You want to also know which one parses faster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing wml files as php
Dotan Cohen wrote: On 6/5/05, Marek Kilimajer <[EMAIL PROTECTED]> wrote: Dotan Cohen wrote: I have gone over and over through google and various archives, but cannot come up with a solution even though I am convinced that this is a FAQ: I want to parse my .wml files. So in .htaccess I have: AddType application/x-httpd-php .wml AddType text/vnd.wap.wml .wml But it does not parse! If I remove the second line, it parses but, of course, the headers are wrong. What can I do? output the right header: header('Content-Type: text/'); replace with whatever is right. Also, you can use php extension too, as long as the header is right. Yes, I tried sending the correct headers with the header function. For whatever reason, I can only send the correct headers with .htaccess, but that makes it so that the file is not parsed as php! What did you tried with the header function? Exactly. Did you send Content-Type header? Put in .htaccess: AddType application/x-httpd-php .wml and start php scripts with: header('Content-Type: text/vnd.wap.wml'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing wml files as php
Dotan Cohen wrote: I have gone over and over through google and various archives, but cannot come up with a solution even though I am convinced that this is a FAQ: I want to parse my .wml files. So in .htaccess I have: AddType application/x-httpd-php .wml AddType text/vnd.wap.wml .wml But it does not parse! If I remove the second line, it parses but, of course, the headers are wrong. What can I do? output the right header: header('Content-Type: text/'); replace with whatever is right. Also, you can use php extension too, as long as the header is right. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stripping html tags
Dotan Cohen wrote: I took this example from php.net, but can't figure out where I went wrong. Why does this: $text = preg_replace("/(.|\s)*?<\/head>/i" , "" , $text); throw this error: syntax error at line 265, column 39: $text = preg_replace("/(.|\s)*?<\/head>/i" , "" , $text); ==^ It seems to be pointing to the 'e' is 'head'. Why? Thanks. Since what time does php gives the column of the error? It seems more like javascript error. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deerpark (aka Firefox 1.1 alpha) URI's and PHP
Richard Lynch wrote: On Sat, June 4, 2005 3:53 am, Chris Drozdowski said: Will PHP scripts that work properly with the current version (1.0.4) of Firefox need to be modified for the feature detailed below in Firefox 1.1? See: http://www.mozilla.org/projects/deerpark/new-web-dev-features.html "URIs always sent as UTF8 URIs are now always sent to the server as UTF8, regardless of the linking page's encoding. This fixes images and links on sites with non-ASCII filenames." AIUI, UTF-8 is a super-set of ASCII. So if your filenames are all ASCII, you're fine. filenames... but what about query strings? I use get method for search pages. I wonder if the "funky" characters will make it through. If you've been using funky characters like umlauts and they've been magically working, you could be in trouble... At least, that's my best guess. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mozilla & urlencode
John Taylor-Johnston wrote: This works: "District of St. Francis" http://www.glquebec.org/tezt.php#District+of+St.+Francis This does not: "Montréal District #2" http://www.glquebec.org/tezt.php#Montr%E9al+District+%232 I'm beginning to see the problem lies with the French character "é". I don't see it being #. In any case, I cannot change existing fields. How can I get this working? replace unsafe characters with safe ones -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Frames or iframes? (Basically "The devil or deap sea" or "A rock and a hard place" etc) - - - -> (0T)
Ryan A wrote: Hey, Thanks for replying. Since its a forum and she is not doing any advertising its important the search engines index the site properly or shes going to have a big forum with no visitors. Then I read that the search engines dont like frames muchso I was thinking of using iframes and then I read about the "evils" of iframes...so I thought I'll ask you guys for your opinions/suggestions as I'm dead outa ideas and a bit confused...any alternate ideas too would be appreciated. As a compromise solution, you could greet visitors to the forum with a welcoming 'splash' page that displays your flash animation etc (please, please put a 'skip intro' link for the sake of repeat visitors) and then pass to your forum page(s). Hehe, not too many people here who like flash eh? Have a look at the flash file and tell me what you think...it will be on the top part of the page: http://a2ztips.com/a2ztips/forum/test/test1.swf as you can see I cant really make that as an intro file and then skip to the forum You could even put a static jpg at the top of the forum of the final image (ie once all that funky animation has played out) of your flash file, if you want to carry it over for a consistent look / feel. Thats a good idea, problem is the links for the navigation is on the flash file (http://a2ztips.com/a2ztips/forum/test/test1.swf - not yet linked) weird, I see only white screen. certainly, iframe will not help you. iframe is loaded each time together with the main page, so the flash will play anyway. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Frames or iframes? (Basically "The devil or deap sea" or "A rock and a hard place" etc) - - - -> (0T)
Ryan A wrote: On 6/4/2005 5:30:14 PM, Marek Kilimajer ([EMAIL PROTECTED]) wrote: Ryan A wrote: I had a real good flash header which she too liked, so I modified the header and she really liked it, problem is, its around 230kb to load, so I thought I'll put it in a frame (top frame -> header, bottom frame-> content and forum) so the flash part won't reload on each page request. .swf files are not cached by the browsers? Seems they are, so you don't need to care about frames. Simply output the html needed to load the flash file each time, the flash will be downloaded only once. Hey, Thanks for replying. Yep, but the animation and the intro music will play each time...which I am guessing can be quite irritating. It's very irritating everytime, even the first time. And it might very well be the reason why it's also the last time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Frames or iframes? (Basically "The devil or deap sea" or "A rock and a hard place" etc) - - - -> (0T)
Ryan A wrote: I had a real good flash header which she too liked, so I modified the header and she really liked it, problem is, its around 230kb to load, so I thought I'll put it in a frame (top frame -> header, bottom frame-> content and forum) so the flash part won't reload on each page request. .swf files are not cached by the browsers? Seems they are, so you don't need to care about frames. Simply output the html needed to load the flash file each time, the flash will be downloaded only once. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ampersands in href's
Jack Jackson wrote: Murray @ PlanetThoughtful wrote: If I want to make a link to a URL which includes some GETs can I just do: Depends very much on the document type of your page. Valid XHTML (transitional, at least), for example, doesn't like single ampersands in href=> links. For XHTML, you need to replace "&"s with "&"s. So the following link: Something ...should be changed to: Something Thank you Murray. The page is in xhtml 1.0/transitional. That was precisely what I was worried about. The & will be converted as part of the URL right? I mean, the printed URL resulting from clicking on that link won't say & it'll just say & is this correct? Combined with Rory's post this is really, really useful stuff and I thank you ! You should use & for all document types, not only xhtml -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mozilla & urlencode
John Taylor-Johnston wrote: I seem to have a problem with Mozilla or with IE? echo "district)."\">"; http://foo.org/_private/directory.php#Montr%E9al+District+%234 works in IE6, but Mozilla will not accept it. Mozilla does not work. Am I approaching this wrong? Should I create my HTML this way? echo "district."\">"; If I do, Mozilla prferes this: http://foo.org/_private/directory.php#Montr%E9al%20District%20#4 or http://foo.org/_private/directory.php#Montr%E9al%20District%20%234 IE refuses it and prefers: http://foo.org/_private/directory.php#Montr%E9al+District+%234 What's my work around? Complain to Mozilla? Same for Firefox BTW. I cannot change my field. name attribute if type CDATA, so it should not be urlencoded, but htmlspecialchars used instead. But this is not necessery because of other restrictions for name and id attributes: http://www.w3.org/TR/REC-html40/types.html#type-cdata -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to find random records in a subset?
Brian Dunning wrote: On Jun 3, 2005, at 6:48 AM, Marek Kilimajer wrote: Brian Dunning wrote: I am using a routine to find 50 random records in a large MySQL database (about a million records) where I generate a list of 50 random unique ID's, why can't you use the where condition in the above query? Because I wouldn't get all 50 records that I need - I'd only get the few out of the 50 that happened to be in the needed subset. I don't think you get me or I don't get you. Currently you are doing: 1. select id from table order by rand() limit 50 2. select * from table where id in($random_set) right? I meant why not use the where condition in the first query. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to find random records in a subset?
Brian Dunning wrote: I am using a routine to find 50 random records in a large MySQL database (about a million records) where I generate a list of 50 random unique ID's, why can't you use the where condition in the above query? and then use MySQL's "in" command to find them. I can't use "order by rand()" due to its performance hit. But I have to take it one more step: I want to first limit my found set to those matching a different search criteria, and then find 50 of those. Anyone? Can this be done all within MySQL, or is it going to require some humongo PHP arrays? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sanitizing get vars
Sebastian wrote: what is a safe way to clean a post/get before echoing it. example. input form, user enters some text, hits enter. .. next page i echo what they entered. right now i just run the variables passed by htmlentities() which preseves any html. is that acceptable? You might also want to use stripslashes() if magic_quotes_gpc is on, so the data is not double escaped. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what is -- $this variable -> $this other variable -- means?
Richard Davey wrote: Hello Marek, Wednesday, June 1, 2005, 9:48:36 PM, you wrote: What does $this variable -> $this other variable Means? MK> read about variable variables Wouldn't that be $$variable? :) It looks like an object method request to me. I thought this was covered in that section too :) I didn't find where it's fully documented, but it's similar: class A { var $variable = "I'm objects's variable\n"; function method() { echo "I'm object's method\n"; } } $a = new A; $var = 'variable'; echo $a->$var; $meth = 'method'; echo $a->$meth(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what is -- $this variable -> $this other variable -- means?
...helmut wrote: What does $this variable -> $this other variable Means? I have seen it and i have "used" but I am not sure what exactly it means in regular English or Spanish wording that is. read about variable variables -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if(($mydata->address
John Taylor-Johnston wrote: This should be easy, but refuses to work: if( ($mydata->address != "") and ($mydata->addresspublic == "yes") ) { } But in other combinations, they work? if($mydata->address != ""){} or if($mydata->addresspublic == "yes"){} So what new lesson am I to learn now? :) in both cases it does nothing... how do you consider one working and the other one not? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Same sessions / different domains
mbneto wrote: Hi Richard, The setcookie manual and the cookie specification tells otherwise. bool setcookie ( string name [, string value [, int expire [, string path [, string domain [, bool secure] ) the domain parameter is restricted to third level domains (or 4 for top level domains like .co.uk). From domain.net, you can set domain to secure.domain.net, but not to anotherdomain.com. In fact one of the tricks people use is to create a cookie with the right values in order to bypass the site's security. They use curl or edit the browser's cookie file On 5/14/05, Richard Lynch <[EMAIL PROTECTED]> wrote: On Sat, May 14, 2005 4:45 am, mbneto said: They are in the same machine. My major concern is with security and the hability to make sure if a user logs in, or adds something to a "shopping cart" in one domain it will be available to the other domain. Can I set call setCookie twice with the same variable name but different domain ? I could set the sessionid and call session_start with the propagated id when/if a user crosses from one domain to another. No, you can't call setcookie with a domain name AT ALL. If you could, what would stop you from setting Cookies for *my* site? Or msn.com? Or Sothebys.com? Then you could just take all their customers' money, and not need to worry about your own shopping cart. If you want to transfer Cookies from two domains you control, it's up to you to do that with your own hack. It would make a lot more sense to just put all the shopping on one domain, or have different carts for two domains. It's more than a little odd to have the same cart on two sites from a user perspective... Something that's likely to confuse customers, and make them think your site is insecure if you can't even keep your shopping cart confined to one site. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] novice: how to run .sql script from php?
tony yau wrote: I realised that there is a fundamental problem with using mysql_query( ...) to run a .sql script to setup a database, and that was the database needs to be there in the first place for php to connect to! also there was a lot of comment lines in the script that was causing problem. ... so I gave up trying to parse the file. instead I did this 1) create the database with phpmyadmin etc so you have phpmyadmin installed. good. now while you have the database selected, 2) click the SQL (it's in the toolbar in the right frame) 3) click "Browse..." button, find the .sql file, click OK 4) click the bottom "Go" button, wait and relax -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Recursion: Ugh!
Chris W. Parker wrote: Hi everyone, I've been working on a problem for a few days now and I'm not making any headway so I think it's time I come to the list for some help (though this really disappoints me since it appears I'm not capable of solving this problem on my own!). Anyway, I'm using the Modified Preorder Tree Traversal method to store my category hierarchy. Using recursion I can build an array that accurately depicts the layout of the categories. So far so good. What I have not been able to do thus far is turn that array into a list that looks like this: Food:Fruit:Red Food:Fruit:Green Food:Fruit:Yellow Food:Vegetables:Long Food:Vegetables:Round Food:Vegetables:Round:Spikey Food:Vegetables:Round:Smooth My array is included at the end of this email. (And yes I typed it by hand so hopefully there aren't any errors in it.) I've searched the web but haven't found anything that's helped. Anyone have a solution? untested: function display($array, $prefix = '') { echo $prefix ':' . $array['name'] . "\n"; if(is_array($array['children']) && $array['children']) { foreach($array['children'] as $child) { display($child, $prefix ':' . $array['name']); } } } 0 => Array ( [name] => Food [children] => Array ( 0 => Array ( [name] => Fruit [children] => Array ( 0 => Array ( [name] => Red [children] => ) 1 => Array ( [name] => Green [children] => ) 2 => Array ( [name] => Yello [children] => ) ) ) 1 => Array ( [name] => Vegetables [children] => Array ( 0 => Array ( [name] => Long [children] => ) 1 => Array ( [name] => Round [children] => Array ( 0 => Array ( [name] => Spikey [children] => ) 1 => Array ( [name] => Smooth [children] => ) ) ) ) ) ) ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Very long delay posting to php-general (might be OT)
Richard Lynch wrote: On Tue, May 24, 2005 3:32 pm, Marek Kilimajer said: Andy Pieters wrote: Hi all I was wondering if it is normal that when posting to the php-general list there is always a very long delay before messages are shown. It's not like with snail mail. Sending mail messages is instant so where is the delay? I think John Nichel took over the job of filtering the list of spam :) I don't know WHY posts take hours to get through, but I'm not honestly seeing it as a "problem" personally. I see one problem, some questions get the same answer from several people. This increases the list traffic without any benefit. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Very long delay posting to php-general (might be OT)
Andy Pieters wrote: Hi all I was wondering if it is normal that when posting to the php-general list there is always a very long delay before messages are shown. It's not like with snail mail. Sending mail messages is instant so where is the delay? I think John Nichel took over the job of filtering the list of spam :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [Fwd: Re: Re: [PHP] Re: Re: Re: __get() not reentrant?]
Christophe Chisogne wrote: Jochem Maas a écrit : if someone with access to the webserver hosting jnsolutions.co.uk could do a quick rm -rf /home/jnsoluti/.autorespond that would be great :-) To that someone, here's the admin URL (cPanel 9) if you forgot it :) http://jnsolutions.co.uk:2082/ Ch. I would prefer https://jnsolutions.co.uk:2083/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Requiring stuff question
Robert wrote: I have the following in a config file: // Define and require the Smarty library define('SMARTY_DIR', 'Smarty/'); require(SMARTY_DIR . 'Smarty.class.php'); // Define the pager stuff define('PAGER_DIR', 'Pager/'); require(PAGER_DIR . 'Pager.php'); require(PAGER_DIR . 'Pager_Wrapper.php'); // Define the DB package define('PEAR_DB', 'DB/'); require(PEAR_DB . 'DB.php'); The Smarty stuff works no problem. The DB and Pager stuff do not. Since I am new to PHP I may be just misunderstanding how to do it. PEAR requires that its path is in include_path. Use: ini_set('include_path', '/where/is/your/PEAR/:' . ini_get('include_path')); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: __get() not reentrant?
Christopher J. Bottaro wrote: Jochem Maas wrote: Christopher J. Bottaro wrote: Maybe I'm using "reentrant" incorrectly, but here is what I mean... class Test { function __get($nm) { if ($nm == 'x') return $this->func(); elseif ($nm == 'y') return 'y'; elseif ($nm == 'xx') return 'x'; } function func() { return $this->xx; } } $t = new Test(); print $t->y . "\n"; print $t->xx . "\n"; print $t->x . "\n"; print $t->func() . "\n"; I would expect the following code to output: y x x x But instead, it outputs: y x x Is this a bug? This limitation is not documented (maybe it should be?). its not a bug, I believe its documented somewhere how this works. bottom line __get() does not work from 'inside' the class/object, so do something like instead: function func() { return $this->__get('xx'); } which may not please the soul, but does work ;-) Hehe, my soul is hard to please...=P Actually, __get() does work from inside the class. In the sample code I posted, func() does indeed return 'x' when called from main. It does not work when called from within a call to __get(). In other words, $this->attribute does not work if __get() appears anywhere in the call stack. Its just a small annoyance. I think it would be more annoying if __get() would be recursively called to infinity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Verification - Problems in Safari, Mac OS X
Richard Lynch wrote: On Thu, May 19, 2005 6:05 am, Rahul S. Johari said: I did actually remove the Header which declared it as a Image/PNG and everything seemed to work in both the browsers. Great. Now it works in 2 browsers, and breaks in 237. You MUST separate the two. Actualy he always did: ImagePNG($im, "verify.png"); This saved the image, not output. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update blues
Jim & Sara Feldman wrote: Hi: I have a partially finished app using PHP and MySQL that runs on Mac G4 running System 10.3.9. Undoubtedly, I upgraded too many things all at the same time. Something broke. PHP and MySQL are both running. I can use the latest phpMyADMIN and everything is there in the database, so that should check both PHP and MySQL. Here are the changes in hardware and software: NewOld MacG5G4 SystemTiger (10.4)10.3.9 PHP4.3.104.3.4 MySQL4.1.114.0.17 myAdmin2.6.22.5.4 When I run the app, I get the login page with no difficulty, but that takes me back to the page member.php which attempts to start a session and then from there to check the validity of the login by comparing the login variables to those stored in the database. The attempt to use session_start(); now gets me the the following two warnings: Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /Library/WebServer/Documents/testit/Logsafe_project/db_fns.php:212) in /Library/WebServer/Documents/testit/Logsafe_project/member.php on line 14 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /Library/WebServer/Documents/testit/Logsafe_project/db_fns.php:212) in /Library/WebServer/Documents/testit/Logsafe_project/member.php on line 14 No cookie is created, so it is not obvious why it is complaining. I suspect something in the apache script for starting php. Can anyone suggest a good place to look? It seems php configuration changed with the upgrade. Your old one had output_buffering turned on in php.ini. Instead of turning it back on you should fix your app, open /Library/WebServer/Documents/testit/Logsafe_project/db_fns.php, go to line 212, something's outputting there something (echo, print, anything outside ), maybe even a whitespace character. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese Fonts in php
Mark Sargent wrote: Hi All, how would one get them to display in php pages..? Is it like ASP where you have to set a codepage number..? I've set this at the top of my pages, and this for the font $product_data_output I don't claim to know much about HTML either. I'm just building a little dynamic site for my company, minus any bells and whistles interface wise. Do I have to set something in php/apache for this.? Thanx. To specify a codepage in html, put correct meta tag in section: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Verification - Problems in Safari, Mac OS X
Rahul S. Johari wrote: On 5/18/05 6:23 PM, "Marek Kilimajer" <[EMAIL PROTECTED]> wrote: BTW, you might not be concerned about it much, but you have a race condition in your script. Ave, What do you mean by "race condition" ? If more then one user is accesing the page, you might overwrite the first one's verify.png image. Simple and sufficient solution is to append a random string to the filename: $image_filename= 'verify_' . md5(rand()) . '.png'; ImagePNG($im, $image_filename); ?> Just remember to add some way to remove old images. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image Verification - Problems in Safari, Mac OS X
Rahul S. Johari wrote: Ave, A simple Image Verification script is working perfect in IE on Windows... But isn¹t working in Safari on Mac OS X! It displays a blank page instead of the image with the form. Here¹ s the Script: Because only Safari gets it right. With the above line you are saing this html page is a PNG image. The png file is saved, not output. Remove the line. BTW, you might not be concerned about it much, but you have a race condition in your script. session_start(); $new_string; session_register('new_string'); ?> "http://www.w3.org/TR/html4/loose.dtd";> Verification : IMSAFM $im = ImageCreate(200, 40); $white = ImageColorAllocate($im, 255, 255, 255); $black = ImageColorAllocate($im, 0, 0, 0); srand((double)microtime()*100); $string = md5(rand(0,)); $new_string = substr($string, 17, 5); ImageFill($im, 0, 0, $black); ImageString($im, 4, 96, 19, $new_string, $white); ImagePNG($im, "verify.png"); ImageDestroy($im); ?> Type the code you see in the image in the box below. (case sensitive) Any tips to make it work in Safari as well? Thanks, Rahul S. Johari Coordinator, Internet & Administration Informed Marketing Services Inc. 251 River Street Troy, NY 12180 Tel: (518) 266-0909 x154 Fax: (518) 266-0909 Email: [EMAIL PROTECTED] http://www.informed-sources.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Refresh (F5) adds another SQL record.
Robert Meyer wrote: "Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Robert Meyer wrote: Hello, Scenario: 1) User is presented a blank form. 2) User fills in form. 3) User submits form. 4) Record is added to database. 5) Back to 1). Go really back to 1) - use redirect. After the record is added to the database, use something like: header('Location: http://yourserver.com/form.php'); exit; Does this work for all browsers? yes. All is fine to here. 6) User clicks refresh. 7) Another record is added, same data except auto-increment field. How do I prevent these last two steps, or at least prevent a record from being added when refresh is clicked? You should see a message from your browser that data is being reposted. I looked for such a message and the only thing I can find is as follows: 1) _SERVER['HTTP_ACCEPT'] and _ENV['HTTP_ACCEPT'] and change to "*/*", but I don't know if that is the case for all browsers, do you know? 2) _SERVER['REDIRECT_UNIQUE_ID'] and _ENV['REDIRECT_UNIQUE_ID'], _SERVER['REMOTE_PORT'] and _ENV['REMOTE_PORT'], _SERVER['UNIQUE_ID'] and _ENV['UNIQUE_ID'] change, but I don't think the values are predictable, especially between browsers. Do you know of a specific message to look for and is that message the same for all browsers? that's a message the user (using the browser) gets from the browser. Unless you use GET method, but you should really use POST method for forms that change state on the server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Refresh (F5) adds another SQL record.
Robert Meyer wrote: Hello, Scenario: 1) User is presented a blank form. 2) User fills in form. 3) User submits form. 4) Record is added to database. 5) Back to 1). Go really back to 1) - use redirect. After the record is added to the database, use something like: header('Location: http://yourserver.com/form.php'); exit; All is fine to here. 6) User clicks refresh. 7) Another record is added, same data except auto-increment field. How do I prevent these last two steps, or at least prevent a record from being added when refresh is clicked? You should see a message from your browser that data is being reposted. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Add to array problem
mayo wrote: I'm having a little problem adding to an array. Each time I add to an array it wipes what was previously added. I'm using array_push(). $items=array(); $items=array_push($items, $_POST["whatever"]); I'm missing something easy. thx array_push() returns the number of elements in the array, not the array itself. You want just: array_push($items, $_POST["whatever"]); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: I have some upload questions.
Lee Chen wrote: Thanks for all of your helping. I think now maybe it's not the serve's problem because I CAN post forms and even I can upload some smaller size files. Then the following is my problem: This is the script of " justtest.php" : justtest.php I can upload a file of size 7KB, but when I want to upload a file of 20 or 30MB, it says : Fatal error: Maximum execution time of 30 seconds exceeded in justtest.php on line 2 That means it took too long time to upload? But when I add some function to this script something like this: I add "two" set_time_limit(0)but when I want to upload a file of 20or 30MB, it still shows: Fatal error: Maximum execution time of 30 seconds exceeded in justtest.php on line 2 Is safe_mode on? set_time_limit() has no effect when PHP is running in safe mode. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re-initiating an autostarted session
Ville Mattila wrote: Marek Kilimajer wrote: the cookie variable still persists. you need to uset($_REQUEST[session_name()], $_COOKIES[session_name()] ...); Thanks Marek for a reply. I'm not sure but I have been thinking that unset($_COOKIES) does not destroy the cookie from the client side but just unsets the cookie variable from the script? My target is to destroy the cookie from the client or send a new session id there. You are right, unset($_COOKIES) does not remove cookie from the client. You need to unset() it so that your next call to session_start() does not use the same $_COOKIES[session_name()]. session_start will generate new session id if there is not one set in the request variables. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re-initiating an autostarted session
Ville Mattila wrote: Leif Gregory wrote: session_destroy(); session_start(); session_write_close(); Header("Location: ..."); exit; I never tried regenerate. Just started a new session again. Hi Leif! Thanks for your reply. For some strange reason, this works not for me. The session cookie will not be overwritten and the user won't get a new session id - even all the session data from the server is destroyed. I tried to unset the session cookie manually (setcookie( session_name() ,"",0,"/");) but without results. the cookie variable still persists. you need to uset($_REQUEST[session_name()], $_COOKIES[session_name()] ...); Thanks also Mr. Jason Barrett for your reply, but I couldn't manage to get the session regeneration work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I have some upload questions.
Lee Chen wrote: If the server uses hub ( to make more computer connect online), can' I upload files to that server?? if you can post forms, you can upload files. I face a problem like this , and I think that's the hub causing this problem. Did it? what is "like this"? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am I missing..interpolation?
blackwater dev wrote: Hello, this works fine: $name="fido"; $string="my dog's name is $name"; echo $string;//prints my dog's name is fido but when I store the string "my dog's name is $name" in the db and pull it out: //do the query $row=$datab->fetch(); $name="fido"; $string=$name['db_column']; echo $string//prints my dog's name is $name How can I get it to work with the db? eval is an answer, but str_replace is much more secure: $string = str_replace('$name', $name, $string); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding current PHP sessions
Bogdan Stancescu wrote: Ok, I went with the solution you recommended, by the way of a "thank you" to the list, here's the resulting function: /** * This function returns the IDs of the current PHP sessions. * At this time, it only works with * [EMAIL PROTECTED] http://www.php.net/manual/en/ref.session.php#AEN129461} * PHP session.save_handler='files' * * @author Bogdan Stancescu * @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License * * @return mixed false on error or the indexed array of the session IDs; * please note that the session IDs are 16-bit values represented as 16-bit. That's not very secure ;) Should be 256-bit * 32-character long hexadecimal strings; letters are in lower caps. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySql injections (related question)
Richard Lynch wrote: On Fri, May 13, 2005 12:51 am, Marek Kilimajer said: Richard Lynch wrote: On Thu, May 12, 2005 4:43 pm, Chris Shiflett said: From me: The fact that it uses the character set of your current connection to MySQL means that what your escaping function considers to be a single quote is exactly what your database considers to be a single quote. If these things don't match, your escaping function can miss something that your database interprets, opening you up to an SQL injection attack. Under the following pre-conditions: 1. C Locale / English in MySQL data 2. No intention to ever switch natural language, nor database. is there any real benefit to spending man hours I really can't afford for legacy code to switch from Magic Quotes to mysql_real_escape_string -- and make no mistake, it would be a TON of man hours. It will take less than five minutes to write a recursive function that will stripslashes() all incoming variables and use mysql_real_escape_string() instead. Except that for integer data, I just type-cast to (int) and check the range, but for some string data, which should not have had any characters that need escaping, I'm doing a regex, and for the string data where characters that needed escaping, I'm already doing stripslashes(), then a regex, then an addslashes(), so applying stripslashes() to all incoming data will break all of those last ones pretty badly. Are we all on the same page now? :-) If this is how your application works now then it's really only search and replace s/addslashes/mysql_real_escape_string/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Same sessions / different domains
Richard Lynch wrote: On Fri, May 13, 2005 1:06 am, Marek Kilimajer said: Richard Lynch wrote: On Thu, May 12, 2005 6:58 am, Shaun said: $_SERVER['HTTP_HOST'] "Mbneto" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, I need to access a website (written in php) using two different domains (www.foo.com and www.bar.com). I must see the same content. Since the site uses session and cookie variables I was wondering if (and how) it's possible to create a session id that is valid for the domains I'll be using... There is no built-in way to just tell the browser that it's okay for cookie X to work for both foo.com and bar.com You will have to write some code that passes the cookie name/value between foo.com and bar.com You might have a special script like 'propogate_cookie.php' something like: Put this on both servers, and then when somebody surfs to foo.com you do: http://bar.com/propogate_cookie.php?var=PHPSESSID&value="; . session_id()); ?> The above will deadlock. session_start() locks the session file, then you try to read from http://bar.com/propogate_cookie.php, this script will try to use the same session file, but it will be never unlocked. Propagating session id in url when linking across domains and having common session storage is completely sufficient. If you are concerned user might browse to the other domain by other means than using a link from the first domain, you can use a 1x1 pixel image linking to the other domain with session id in url. I was actually thinking of foo and bar as totally separate machines when I typed that, mostly. But I'm not quite convinced that doing a setcookie on bar.com is going to deadlock the session from foo.com, even if they use the same file-system. Now I see what you wrote :) Well, it aint gonna work, you send cookie to php's file() function, not to the browser. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strpos with array?
Burhan Khalid wrote: Merlin wrote: Burhan Khalid wrote: Merlin wrote: Hi there, I am wondering if there is a function (I could not find) which does the same thing like strpos does, but with an array. For example: $replace = array("picture", "pics"); $pos = strpos ($term, $replace); //if ($pos !== false) { if (in_array($term,$replace)) { $term = str_replace($replace, "", $term); echo 'term without the word:'.$term; } http://www.php.net/in_array Actually this did not solve the problem, since this function is searching for the exact phrase, but not within a string. I solved it that way: // try pictures $replace = array("pictures", "picture", "bilder", "bild", "pic", "pics", "pix"); foreach($replace AS $try){ $pos = strpos ($term, $try); if ($pos !== false) { $term = str_replace($try, "", $term); #echo 'yes'.$term.$pos; exit; HEADER("Location:/index.php?search_for=".$term.""); exit; 1. All functions in PHP are lowercase. Do not UPPERCASE your functions. Its Just Not Right. Case in function names does not matter. It does matter in variable names. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding current PHP sessions
Bogdan Stancescu wrote: Hello all, I guess this comes up once in a while, does anybody know how I can find the current PHP sessions' IDs? I don't mind if some have passed away, and the PHP gc hasn't run yet, because I'm doing a garbage collection of my own, for data identified by session ID -- it doesn't really matter if I keep a few obsolete files for a while, it only matters that I delete them at some point in the future. I know I could read the session files themselves, but I'd very much rather use a "proper" way to retrieve the active sessions, which would work with alternate methods of storing session data, if there is any such proper way to do this. I read the PHP documentation regarding sessions, and I checked out Google, with no luck. If you guys don't have a solution, it means that there is none -- in other words, you're my last hope, help! :-) Depends on where and how you store your session data. Default file storage simply reads all files in session.save_path (opendir() and readdir()), check if they match the pattern /sess_[0-9a-f]{32}/ and the modification time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Same sessions / different domains
Richard Lynch wrote: On Thu, May 12, 2005 6:58 am, Shaun said: $_SERVER['HTTP_HOST'] "Mbneto" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, I need to access a website (written in php) using two different domains (www.foo.com and www.bar.com). I must see the same content. Since the site uses session and cookie variables I was wondering if (and how) it's possible to create a session id that is valid for the domains I'll be using... There is no built-in way to just tell the browser that it's okay for cookie X to work for both foo.com and bar.com You will have to write some code that passes the cookie name/value between foo.com and bar.com You might have a special script like 'propogate_cookie.php' something like: Put this on both servers, and then when somebody surfs to foo.com you do: http://bar.com/propogate_cookie.php?var=PHPSESSID&value="; . session_id()); ?> The above will deadlock. session_start() locks the session file, then you try to read from http://bar.com/propogate_cookie.php, this script will try to use the same session file, but it will be never unlocked. Propagating session id in url when linking across domains and having common session storage is completely sufficient. If you are concerned user might browse to the other domain by other means than using a link from the first domain, you can use a 1x1 pixel image linking to the other domain with session id in url. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySql injections (related question)
Richard Lynch wrote: On Thu, May 12, 2005 4:43 pm, Chris Shiflett said: From me: The fact that it uses the character set of your current connection to MySQL means that what your escaping function considers to be a single quote is exactly what your database considers to be a single quote. If these things don't match, your escaping function can miss something that your database interprets, opening you up to an SQL injection attack. Under the following pre-conditions: 1. C Locale / English in MySQL data 2. No intention to ever switch natural language, nor database. is there any real benefit to spending man hours I really can't afford for legacy code to switch from Magic Quotes to mysql_real_escape_string -- and make no mistake, it would be a TON of man hours. It will take less than five minutes to write a recursive function that will stripslashes() all incoming variables and use mysql_real_escape_string() instead. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Passing variable number of parameters by reference
I believe it's mentioned somewhere in the manual you can't do that. func_get_arg() always return a copy. You can workaround this using an array. Robert Meyer wrote: Hello, Using: PHP Version 5.0.3 I build the following function: function Set4HTMLOut() { $C = func_num_args(); for ($I = 0; $I < $C; $I++) { $A = func_get_arg($I); echo 'I['.$I.']('.strlen($A).'): '.$A.''; $A = htmlspecialchars($A); echo 'I['.$I.']('.strlen($A).'): '.$A.''; } } And called it like this: Set4HTMLOut(&$LName, &$LOrg, &$LWebSite, &$LPhones, &$LComments); echo 'After call:'. 'LName: '.$LName.''. 'LOrg: '.$LOrg.''. 'LWebSite: '.$LWebSite.''. 'LPhones: '.$LPhones.''. 'LComments: '.$LComments.''; The "echo" statements in the Set4HTMLOut() function echos all the correct data and proves the data was received correctly then altered by the htmlspecialchars() function appropriately. Notice that the caller passes each variable as a reference. Yet, the "echo" statement after the call displays the data without any changes, like the first "echo" statement in the Set$HTMLOut() function does. Is it not possible to pass variables by reference to a variable-length parameter list? Or am I doing something wrong? If so, what? I have already built a work around. I do not need any work arounds. I just think one should be able to pass variables by reference to a function that accepts a variable-length parameter list. Regards Robert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Same sessions / different domains
mbneto wrote: Hi, I need to access a website (written in php) using two different domains (www.foo.com and www.bar.com). I must see the same content. Since the site uses session and cookie variables I was wondering if (and how) it's possible to create a session id that is valid for the domains I'll be using... regards. embed the session id in url when linking to the other domain -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] marking words bold
Merlin wrote: Hi there, I am trying to mark words inside a sentence bold. Problem is, if there is an overlap it does not work anymore. I am using this code: $t = str_replace($word, "$word", $text); For eample: Mark those words bold: adventure in singapore Text: My adventure flying to singapore The problem lays in the word "in". The code I use does produce following: singapore which of course does not work properly. Does anybody have a good sugestion on how to improve this?` use preg_replace('/\b'.preg_quote($word).'\b/', ''.$word.'', ..); \b is word boundary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Editing PDF
Sam Smith wrote: I have an existing PDF file that I want to add text to or make changes to text with data from an HTML form via PHP. The PDF looks like this: 20 0 obj<>stream 8;X-DgMYb:(An746bc%oU,Mo*S]"SN?epNo... That is, not in plain text. If I wanted to add text to the PDF, e.g., Mr. Jones, where the heck would it go and what would it look like? Thanks it's a compressed pdf. make uncompressed pdf and you should see the raw text -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strpos with array?
Merlin wrote: Hi there, I am wondering if there is a function (I could not find) which does the same thing like strpos does, but with an array. For example: $replace = array("picture", "pics"); $pos = strpos ($term, $replace); if ($pos !== false) { $term = str_replace($replace, "", $term); echo 'term without the word:'.$term; } This does of course not work since strpos does not take arrays. Thank you for any help, Merlin http://www.php.net/array_search -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using header ('Location:) to pass varaiables
Ross wrote: Is it possible to send variables using header() ? I have tried variations on the theme header ('Location: email_confirm.php?email=$email); but nothing seems to work. I don't know what you tried, but the above results in parse error. Try: header ("Location: email_confirm.php?email=$email"); email_confirm.php: echo $_GET['email']; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] text with $
Martín Marqués wrote: I have a text variable that contains "$" symbols, that when I pass it out PHP thinks that the "$" mean that a variable name comes right after. I tried escaping the "$" put with no luck. Is there something I can do? How did you escape the symbol? You should use backslash: \ Or use single quotes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] API Number
Cole Ashcraft wrote: Hi. I need to know what PHP version had API # 20001222. Thanks, Cole 4.0.5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Any alternative to POST method FTP uploads from client computer?
Murray @ PlanetThoughtful wrote: Hi All, I need to implement the ability to ftp upload files from client machines via a form in a web application I'm developing. From reading the PHP help, all I can find to perform this is the POST method for handling file uploads (http://au2.php.net/manual/en/features.file-upload.php). From my perspective, while this seems to work, there are a couple of drawbacks, most important of which is that it seems you can only do comparisons of the uploaded file, against the potential that the file has already been uploaded, once the file has already been uploaded and is sitting in the server temp directory. This is a drawback to our application because the files can typically vary on a daily basis in size from 20mb thru to 400mb, and 400mb seems like a lot of bandwidth to consume to discover that the file already exists on our server. I had hoped there was a way in which I could retrieve stats of the file being uploaded prior to beginning the upload, to compare against files in the target directory, so that the application can advise the user that the file already exists and to give them the option to cancel the upload. PHP script starts once the upload is finished, but this is not true for some other languages, for example perl. Another minor drawback is that it seems the Post upload method changes the file datetime to the datetime of the upload. Browsers don't send file's modificaton time, so it's not available. So, can anyone confirm that there is no other way to upload files from a client machine using a form? (and assuming they don't have an ftp server at their end). Cliens need ftp client software, some sort is for sure installed on every machine. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm having a blond moment with a while loop???
George Pitcher wrote: Hi guys, I'm doing something dumb but I can't see it. The basic premise is: sql search of orders sorted by customer set g_customer_id to '' loop through resultset if customer_id not same as last record's customer_id (g_customer_id) get customer email details set up message header if this is the first record for a customer set item details else set item details set g_customer_id to customer_id endif send email end loop Should not be line "set g_customer_id to customer_id" be in the "if" part? It's certainly useless in the "else" part as it's already equal to customer_id ;) The problem is that as a sample I have two records from one demo customer (me) and I can only get my email to handle one record - either sending separate records for each record or one email covering the last record only Its as if I should have another inner loop Any tips MTIA George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST long texts to PHP
First of all, don't hijack threads. Instead of replying to a message, create a new one. SED wrote: I need to POST long texts through a form to PHP but the text cuts down to around 64.000 characters. Is there any way to allow longer texts (like in php.ini)? This is browser limit. Most, if not all, browsers limit textarea field length to this value. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random but ordered..
Ryan A wrote: Hey, I have been screwing around with this code for around a day and am hitting a wall, any help would be appreciated. Basically, I am working on a site that queries the DB for companies and the plans the company is offering, the DB is quite big (a few thousand records in each of the 20 tables) The parameters are taken from the client in the form of a search box and usually gives around 1000 results per query, they results are then displayed like this: company 1 [] plan [] plan [] plan [] plan company 2 [] plan [] plan [] plan company 3 [] plan company 4 [] plan [] plan So far, no problems (even though the code and the design are mixed together in the page) but so far the code is getting the results grouping via $cno, which results in the lowest being displayed first which gives the first companies who joined an edge as they are always getting displayed. Heres the kicker, he wants to have the same display as abovebut randomly from the DB *while still* having pagination.. so new joined companies too get displayed and not shoved at the end of the results. Choices: 1. ORDER_BY RAND(), and keep the full result set (or just the ids) in session 2. add another column, display_order, and update it at regular intervals to random values. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reducing size of htm output
Kirsten wrote: preg_replace('/s+/', ' ', $html); but watch out, this js code will work: var v alert(v) this one will not: var v alert(v) Sure but now: how do I access the htm output of the current executing script before it is send to the user? output buffering -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reducing size of htm output
Kirsten wrote: I need to reduce the size of the HTM generated by a PHP script for faster transmission. I'm actually using ob_start("ob_gzhandler") but I also need some function to reduce the size of javascript blocks, deletion of unnecesary blanks, etc. For example, Code A:
function any(){ somecode; }
can be converted to Code B: function any(){ somecode; } preg_replace('/s+/', ' ', $html); but watch out, this js code will work: var v alert(v) this one will not: var v alert(v) 1) Is there any function to do this (I'm using PHP 4.2) ? Or maybe some user has already done it? 2) Is it true that ob_start("ob_gzhandler") can cause problems on IE 5.5+? don't know. but you can detect these browsers and turn compression off -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multi dimensional arraySOLVED
Angelo Zanetti wrote: thanks richard. In the PHP.ini its set to on but in the .htaccess file we've set it to OFF. could this still be causing the problem?? run phpinfo() inside the directory thanks again Angelo Zanetti Z Logic www.zlogic.co.za [c] +27 72 441 3355 [t] +27 21 469 1052 Richard Lynch wrote: On Thu, May 5, 2005 3:37 am, Angelo Zanetti said: this is quite weird but apparently on the one server if you user $user as a variable name thats what causes the problem. I simply renamed my variable to something else and it worked, I find it strange that it worked on 1 server and not the other, is it possible that the different apache versions are responsible for this situation?? This would indicate to me that you've got register_globals "ON" and that your EGPCS settings are clobbering your $user variable with data from, say the environment $_ENV I'm betting that if you do: echo "ENV $_ENV[user]\n"; echo "GET $_GET[user]\n"; echo "POST $_POST[user]\n"; echo "SESSION $_SESSION[user]\n"; echo "COOKIE $_COOKIE[user]\n"; in the script that was giving you trouble, you'll find that one of those is set. Actually, since they could be set to the empty string, you should be echo-in isset($_XXX['user']) in the above test. The correct solution, then, is to turn register_globals OFF. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sort by date
William Stokes wrote: Hello, I made a mistake and stored date information to DB as varchar values (dd.mm.yyy). When I read the DB is it still possible to sort the data by date with SQL query (ORDER BY date ASC)? Or is it nessessary to have the date information to be stored as a date in the DB? Will it work or is the output going to be sorted randomly? It would be sorted by day first, then month, then year. Add another column (DATE type) to the table and update it from the current column using SUBSTRING() function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] control-M
David Christensen wrote: I am? That news to me??? I just did a 'grep nl2br form.php' and I don't any output with nl2br. I'm not sure this is what's going on. I did see that function in the "Strings" section of the manual, but it didn't do anything for me. Well, php isn't making it up, it has to be somewhere. Or are you using any htmlarea kind of input? We need to see your form.php to help you. On Thu, 2005-05-05 at 16:11 +0200, Marek Kilimajer wrote: David Christensen wrote: Actually, I forgot to also mention that the browser is changing the control-M (^M) from the query when it sets the default value for the textarea to "". I guess that is the HTML representation of the ^M. you are using nl2br() on the input, that funcion adds '' before all newline characters. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] control-M
David Christensen wrote: Actually, I forgot to also mention that the browser is changing the control-M (^M) from the query when it sets the default value for the textarea to "". I guess that is the HTML representation of the ^M. you are using nl2br() on the input, that funcion adds '' before all newline characters. I'm currently using: $_POST[$field] = str_replace("\r\n", "\n", $_POST[$field]); $_POST[$field] = strip_tags($_POST[$field], ''); in a foreach loop for all the $_POST vars, but it's still not removing it. Dave On Thu, 2005-05-05 at 10:12 +0200, Marek Kilimajer wrote: David Christensen wrote: I know I'm missing something, but I can't seem to find it or figure it out. I've done the google search, and I've done a quick scan of the list archives, but I can't seem to find the right way to remove control-M from a form submission page with textarea fields. I have a series of "textarea" fields that can/and do contain the dreaded ^M characters. For the life of me, I can't figure out how to remove them before I save them to the database, and how to remove the ones that are all ready stored there when I query them back to the browser from a web page. Also, if I do remove them, how do I make sure I format the text correctly when I push it back to the browser as the default values of these fields? Point me to the elixir of knowledge and let me bath in the fortitude of a master regex expression to rid me once and for all of the dreaded ^M!!! Thank you, and good night! ... = str_replace("\r\n", "\n", ...); But I don't see how this would infuence the default values of form inputs, plain htmlspecialchars() should be enough. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] insert not working
Ross wrote: $query = "INSERT INTO sheet1 (title, fname, sname, job_title, organisation, street, postcode, city, telephone, mobile, fax, email, web, add_info) VALUES ('$title', '$fname', '$sname', '$job_title', '$organisation', '$street', '$postcode', '$city', '$telephone', '$mobile', '$fax', '$email', '$web', '$add_info')"; $result= mysql_query($query); if($result){ echo "sucess"; } else { echo mysql_error() . "\n$query"; } why yould this not work? I can retrievethe data but not write any data to the database?? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to declare Vars in PHP?
Jon M. wrote: I know it's not necessary, but I still want to know how. I know in JavaScript, that you declare vars like so: var = variableName; So I'm assuming that in PHP you do it like this: var = $variableName; the above is wrong. you can declare variable inside class definition using (php4): var $varname [ = {default value} ]; but it's not necessery. It's good for documentation. php5 gives you more control with public, protected and private keywords. But there doesn't seem to be a single shred of documentation on PHP.net (or in ANY book) that covers this. All they say is that it's good practice, but not necessary. Then they always skip telling you how. outside of class definitions you declare a variable by assigning it a value, for example: $myvar = null; That's it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] control-M
David Christensen wrote: I know I'm missing something, but I can't seem to find it or figure it out. I've done the google search, and I've done a quick scan of the list archives, but I can't seem to find the right way to remove control-M from a form submission page with textarea fields. I have a series of "textarea" fields that can/and do contain the dreaded ^M characters. For the life of me, I can't figure out how to remove them before I save them to the database, and how to remove the ones that are all ready stored there when I query them back to the browser from a web page. Also, if I do remove them, how do I make sure I format the text correctly when I push it back to the browser as the default values of these fields? Point me to the elixir of knowledge and let me bath in the fortitude of a master regex expression to rid me once and for all of the dreaded ^M!!! Thank you, and good night! ... = str_replace("\r\n", "\n", ...); But I don't see how this would infuence the default values of form inputs, plain htmlspecialchars() should be enough. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: Finding out their server type
Ang Pinoy wrote: Such as Apache, IIS, GWS, etc. "Server" header in any http response from the server: $ telnet servername 80 HEAD / HTTP/1.0 200 OK Connection: close Date: Wed, 04 May 2005 15:00:55 GMT Accept-Ranges: bytes ETag: "fa878-22dd-422b6d78" Server: Apache/1.3.27 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] just going with LIKE
Ross wrote: Had a look at it and much easier to use LIKE with wildcards. Was unsure whether the query was case sensitive that is why I asked. As it turns out it is not. LIKE is case insensitive as well. Try casting to binary, this should work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5-mysqli
NSK wrote: hi how can I ensure that php5-mysqli is correctly loaded? the server is SuSE9.3 and I have installed the package from yast, but one app (phpmyadmin) says it cannot find the mysql extension (although other apps can query the db). which config files are responsible for loading mysqli in apache/php5 ? pmp_mysqli !== php_mysql mysqli works only with mysql >= 4.1.3, do you have this installed? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] inserting an auto incemented column in table already created
Ross Hulford wrote: Hi, I have a table with 15 columns or so that has been inherited from an older db and am trying to insert an auto increment column (in mysql) without having to number it manually. This is fine when I add new colums via a form but the old entries have a null value Alternatively It has been converted from Excel soif anyone knows how to do it that way that would help.I never use Excel so have no clue about it. R. $id = 1; do { mysql_query('update table_name set id = ' . $id++ . ' where id is null limit 1'); } while(mysql_affected_rows() > 0); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Skipping function arguments!
Vedanta Barooah wrote: Well that was simple, but this is what i am trying to solve: if you refer to the php documentation for ldap_open() function it says: resource ldap_search ( resource link_identifier, string base_dn, string filter [, array attributes [, int attrsonly [, int sizelimit [, int timelimit [, int deref]) if you look at the 4th and the 6th arguments to the function attributes is an array while sizelimit is an int, i want to pass the sixth element without passing the 4th and the 5th ... how do i do that?? you can do it only with user defined functions. so the answer is no, you can't do that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Skipping function arguments!
Bostjan Skufca @ domenca.com wrote: function add ($a=1, $b=2, $c=3) { return $a + $b + $c; } add(1, null, 1); will do just fine returns 2, OP wants 4 IMO r., Bostjan On Thursday 28 April 2005 14:16, Marek Kilimajer wrote: Vedanta Barooah wrote: Hello All, Cosider this : function add($a=1,$b=2,$c=3){ return $a + $b + $c; } how do i skip the second argument while calling the function, is there a process like this: echo add(1,,1); # where i expect 2 to be printed, php does not support this. you can workaround this using: function add($a = null,$b = null, $c = null){ if(is_null($a)) $a = 1; if(is_null($b)) $b = 2; if(is_null($c)) $c = 3; return $a + $b + $c; } add(1, null, 1); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Skipping function arguments!
Vedanta Barooah wrote: Hello All, Cosider this : function add($a=1,$b=2,$c=3){ return $a + $b + $c; } how do i skip the second argument while calling the function, is there a process like this: echo add(1,,1); # where i expect 2 to be printed, php does not support this. you can workaround this using: function add($a = null,$b = null, $c = null){ if(is_null($a)) $a = 1; if(is_null($b)) $b = 2; if(is_null($c)) $c = 3; return $a + $b + $c; } add(1, null, 1); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to a file using ftp functions
Giulio wrote: I tryied using ftp_put() with startpos parameter, but I receive an error Appen/Restart not permitted, try again http://www.proftpd.org/docs/faq/linked/faq-ch4.html#AEN408 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to a file using ftp functions
Giulio wrote: I tryied using ftp_put() with startpos parameter, but I receive an error Appen/Restart not permitted, try again I tryed both FTP_AUTOSEEK on and off, and both pasv true and false I imagine that this is an ftp server error message, and not a php error, since I have searched it on php documentation with no success, is startpos option depending on the ftp server supporting append commands? yes, it is. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] appending to a file using ftp functions
Giulio wrote: Hi, I'm developing an application that uploads file to a server using http. the app calls a php on the server sending all the data just like a web form post. It works just fine uploading little files, now i'm concerning about having the apllication split large files in little chunks ( about 256 KB os so ) and sending them with multiple post. Wanna do that to avoid possible problems with php temporary files max size. No problem on the client side ( is sends the form with some info and the firts chunk, waits for server response and then repost a form with succesive chunk of file, and so on ), and also on the php side should be quite easy to store a file with the first post, and keep on adding to it the subsequent chunks of file posted, at least using the filesystem functions. My problem is that I'm using, to make the system as general as possible, and make it work even on servers where php doesn't have write privileges, ftp functions instead of filesystem functions, and using ftp it seems that it's not possible to append to a file. I also thinked to use the fopen function with an ftp address, but reading the docs it says that fseek function ( to position the pointer at eof to go on appending ) may not work if the file is opened using ftp or http. Suggestion about this issue? ftp_put() has startpos parameter. I think you need to turn FTP_AUTOSEEK off, because you have only partial file. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JavaScript - object property
Eli wrote: Hi, I know this is not the forum, but I googled and couldn't find it, so please try to help me with this. /*/ function MyCls(name) { this.name=name; } function SayHi() { alert('Hi, '+this.name+'!'); } var obj=new MyCls('PHP'); obj.name='JavaScript'; //this will call SayHi() function /*/ I have a class in JS with a property variable in it. How can I execute a function when the property value is changed? Sorry it's off-topic.. -thanks, Eli Look at Object's watch() method -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 32 bit PNG (256 color alpha channel), TGA images, etc
Andrew D. Keyser wrote: I find it not quite right that imagecolorallocatealpha is limited to 128 levels right now (0-127) ... the png format can support 256 with true 32bit images. I am concerned about this because I am using php to make an application that loads a nonstandard image format (MM2/MC TEX) and converts it to png - but the format supports 256 alpha levels, imagecolorallocatealpha does not, and therefore I am losing small amounts of detail in the alpha channel by reducing it to conform to the max 128 levels idea. Can I get an explanation as to why it's limited at 128 levels instead of the preferred 256, and maybe an estimate or guess to whether or not this limitation will ever be lifted? On to the next part of this post. Is there any way to create an equivalent to imagecreatefrompng for tga (maybe imagecreatefromtga), /including/ alpha channel? I've found examples on php.net, but none of them take an image with more than 256 colors, much less one with an alpha channel. I'm not keen on the binary structure of the tga format, but i might be required to learn it this time.. Andrew It's likely limitation of gd or png library. Try imagick extension: http://pecl.php.net/packages.php?catpid=12&catname=Images -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can I join two mp3 files with php
QT wrote: I found an exe file, can I run that ms-dos exe file on linux machine with php? I didn't try anything like this before First, check if it's really for ms-dos. Command line does not mean ms-dos, it can be a WIN32 command line binary. If it's really ms-dos executable, use dosemu. If it's WIN32 binary, try wine. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php