Re: [PHP] opposite of quotemeta ?
Hi Matthew, you might have magic quotes enabled in your PHP installation. Have a look at http://php.net/manual/de/security.magicquotes.php about that topic. If you want to unescape the string, use the stripslashes-function (http://php.net/stripslashes). Greetings from Germany Marc Matthew Croud wrote: Hi, In my script I want the user to enter some html which is saved to a file, I've noticed that php rather cleverly escapes the speech marks, so: a href=www.google.comGoogle/a becomes: a href=\www.google.com\Google/a Is there some function which prevents or reverts this ? something similar to html_entities maybe? Many thanks! Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace
Hey Ben, to replace everything thats not alphanumeric, use the following statement: $output = preg_replace('/[^[:alnum:]]/', '', $input); Greetings from Germany Marc PS: Spaces are not alphanumeric ;) Ben Miller wrote: Oh yeah - not sure if spaces are considered alphanumeric or not, but I need to keep spaces - replacing anything that is NOT a letter, a number or a space. Thanks again. -Original Message- From: Ben Miller [mailto:biprel...@gmail.com] Sent: Friday, June 05, 2009 2:09 AM To: php-general@lists.php.net Subject: [PHP] preg_replace I bought PHP MySQL for DUMMIES and it shows me how to use special characters for pattern matching and I've figured out the basics of using preg_replace to replace pattern matches. What I am having trouble with, though, is figuring out how to replace anything that does not match the pattern. For example, I want to replace anything that is NOT an alphanumeric character. Any help would be appreciated. Thanks. Ben -- Synchronize and share your files over the web for free http://bithub.net/ My Twitter feed http://twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP scalability problem
Have a look at APC. APC is a bytecode cache, that stores bytecode generated of your PHP scripts, so that your PHP code don't need be parsed every time the script is invoked. http://pecl.php.net/package/apc I was able to increase the performance of my PHP scripts dramatically. Greetings from Germany Marc tRace DOliveira wrote: What I am trying to achieve is to have the server do less processing. Like I said PHP is a server side scripting language and each time a request is made a process is spawned and processes are heavy weight as compared to a thread which is a light weight process. So I want to take away much processing away from the server and have the client do it instead. Because if many requests are made the server will eventually go down because it will over the server.I am not trying to get away from PHP but I am trying to solve the problem of scalability Thank you, Leonard D'Oliveira -- Synchronize and share your files over the web for free http://bithub.net/ My Twitter feed http://twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to delete part of string
I guess you mean GET parameters instead of POST. $string = preg_replace('/^(.*?)id=/', 'id=', $_SERVER['QUERY_STRING']); Don't know, if that's exactly what you wanted. Greetings from Germany Marc Grega Leskovsek wrote: I have a POST string field and I want to skip some fields before id= How do I simply delete operation=nekajprice=fddfid=deid=ta ... into id=deid=ta ... Thanks in advance, -- Synchronize and share your files over the web for free http://bithub.net/ My Twitter feed http://twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with global not working
Maybe your code overwrites the variable anywhere? You should think about switching to a constant in that case by using define('TEST_MODE', true); [...] if (TEST_MODE) { [...] } else { [...] } Greetings from Germany Marc Joey wrote: Hello All, I am running into a problem after I moved a site from a server with PHP4 to PHP5. As an example I have a variable defined at the top of my code lets say: $test_mode = no; Then within the code I check if we are in test mode to bypass certain functionality like so: function runTransaction() { global $test_mode; do some things; do some more things; if ($test_mode == yes) { don't do anything; } else { Do something; } My problem is that $test_mode NEVER contains the value no. Any ideas appreciated. Joey -- Synchronize and share your files over the web for free http://bithub.net/ My Twitter feed http://twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change color of anything in double/single quotes
Andrew Hucks wrote: If I have something like $string = 'hello there'; (the word hello is in double quotes, if you can't see it), how would I output it as something like font color=colorhello/font there. Try $string = preg_replace('/(.*?)/', 'font color=color\\1/font', $string); Greetings from Germany Marc Steinert -- Synchronize and share your files over the web for free http://bithub.net/ My Twitter feed http://twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reflection question
Have a look at example #5 on http://de3.php.net/manual/en/language.oop5.reflection.php#language.oop5.reflection.reflectionmethod Greetings from Germany Marc Pulni4kiya wrote: Hi, everyone! I need to do the following: Let's say I have this class: class A { public function b(array $c, $d = 6) { ... } } I need to get this in runtime: public function b(array $c, $d = 6) What's the best way to do it? (I don't quite like the idea of reading the file in which the class is defined and it might not always work...) -- http://bithub.net/ Synchronize and share your files over the web for free My Twitter feed http://twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] try - catch is not so clear to me...
Basically try-catch gives you the ability to handle errors outside a class or method scope, by the calling instance. This comes in handy, if you are programming in an object orientated way and thus enables you to seperate error handling from the rest of your functionality. Means, your methods do only the things, they are meant to do, without bothering to handling occuring errors. Hope, that made things clearer. Greetings from Germany Marc Lamp Lists wrote: hi to all! actually, the statement in the Subject line is not 100% correct. I understand the purpose and how it works (at least I think I understand :-)) but to me it's so complicated way? -- http://bithub.net/ Synchronize and share your files over the web for free My Twitter feed http://twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax
Terion Miller wrote: $query .= WHERE stamp NOW()-7 ; I have no clue here on this Try $query .= WHERE stamp SUBDATE(NOW(), INTERVAL -7 DAY); instead. Marc -- http://bithub.net/ Synchronize and share your files over the web for free My Twitter feed http://twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax
Marc Steinert wrote: Terion Miller wrote: $query .= WHERE stamp NOW()-7 ; I have no clue here on this Try $query .= WHERE stamp SUBDATE(NOW(), INTERVAL -7 DAY); instead. Marc Damn, hit the send-button too fast. Replace -7 with 7. Sry for spamming the list. -- http://bithub.net/ Synchronize and share your files over the web for free My Twitter feed http://twitter.com/MarcSteinert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RewriteRules
Jason Pruim schrieb: Now, on that site I have a few links... right now the likes are in the format of: HTTP://purl.raoset.com/design.php?purl=test112 What I would like is to have it read: HTTP://purl.raoset.com/test112/design Try the following rule (dunno, if it works for you, but you should get the idea): RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ /$2.php?purl=$1 /Marc -- http://bithub.net/ Synchronize and share your files over the web for free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can a script tell if there's a MySQL problem?
Brian Dunning schrieb: I have one server that's pretty busy and runs into Too many connections from MySQL from time to time, and needs to have MySQL restarted to clear it up. I've tried everything I can think of to have PHP take note of this error but continue executing with other stuff, but no matter what I try the PHP script stops whenever it encounters this and just displays Too many connections. Anyone know if there's a way for PHP to gracefully detect this and resume operation without choking? Take a look at http://php.net/mysql_ping -- http://bithub.net/ Synchronize and share your files over the web for free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] setting up FTP account names via PHP
Merlin Morgenstern schrieb: Hello everybody, I am running a real estate site where I would like to enable bulk upload via real estate software that exports an xml file into an ftp account. In order to give every user unique access I would need to generate individual ftp name and passwords for each member. I can not see how this should work. My portal is written in PHP 4.x and there every members loges in with a unique ID. The FTP Server runns on the same linux machine. How could I generate users for this FTP server with php, for example on sign up? Thank you for any help on this. Best regards, Merlin What ftp server are you using? -- http://bithub.net/ Synchronize and share your files over the web for free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable as an index
MikeP schrieb: I have tried putting the quotes all over and all I get is: 'Array[U]'. Try to avoid accessing the two-dimensional array $users inside a string. Use echo's ability to accept multiple parameters: echo 'trtd.', $users[$x]['U'], '/td'; Or by concating the string with the .-Operator: echo 'trtd.'.$users[$x]['U'].'/td'; The first method is faster and needs less memory. -- http://bithub.net/ Synchronize and share your files over the web for free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable as an index
German Geek schrieb: Why is the first method faster and uses less memory? Because the concatenation operator first reassembles a new string, stores it in memory then passes this newly created string to the echo function, if I'm not misstaken. -- http://bithub.net/ Synchronize and share your files over the web for free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] First PHP program
Anwarulhaq wrote: I am working on MS.net.But now i days i want to work on PHP. I dont know the basis of PHP. Can any one guide me how i have to start with PHP and which editor i should use. Also the links of useful sites for help in PHP. I shall be thankful. Since you've allready worked with .NET, I assume, that you are already familiar with basics principles of programming. Zend (the company behind PHP) offers some great resources and tutorials for programmers that want to give a shot at PHP, without the obligatory what is a variable etc chapters, that most ppl tend to skip anyways. http://devzone.zend.com/node/view/id/627 for instance is imo a good start, plus it covers PHP4 PHP5 equally. http://php.net/ is great as reference, to quickly look up some functions and real world examples. On the editor part I can strongly recommend Zend Studio, though it's not free: http://www.zend.com/en/products/studio/ If you need something free, try weaverslave: http://www.weaverslave.ws/ Hope, I could help you. Marc -- http://bithub.net/ Synchronize and share your files over the web for free -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php