Re: [PHP] Text messaging from the web
Paul M Foster schrieb: Folks: Being fairly geezerly, I know almost nothing about this, so be gentle. Assuming someone entered information in a form on a website. Normally, you would email the responses to someone. But what if you wanted to send this information to a smartphone via text messaging? Is this possible, given normal programming tools (PHP/Javascript), or would you have to go through some commercial web to text messaging gateway? Does anyone know if this could be done, and how? Paul I guess you have to connect to any kind of interface of a commercial provider. I searched for php sms on google and got several tutorials and informations. Just give it a try. Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Text messaging from the web
Larry Martell schrieb: On Thu, Oct 14, 2010 at 9:45 AM, Paul M Foster pa...@quillandmouse.com wrote: Folks: Being fairly geezerly, I know almost nothing about this, so be gentle. Assuming someone entered information in a form on a website. Normally, you would email the responses to someone. But what if you wanted to send this information to a smartphone via text messaging? Is this possible, given normal programming tools (PHP/Javascript), or would you have to go through some commercial web to text messaging gateway? Does anyone know if this could be done, and how? You can send a text message via email: Verizon: 10digitphonenum...@vtext.com ATT: 10digitphonenum...@txt.att.net Sprint: 10digitphonenum...@messaging.sprintpcs.com T-Mobile: 10digitphonenum...@tmomail.net Nextel: 10digitphonenum...@messaging.nextel.com Cingular: 10digitphonenum...@cingularme.com Virgin Mobile: 10digitphonenum...@vmobl.com Alltel: 10digitphonenum...@message.alltel.com CellularOne: 10digitphonenum...@mobile.celloneusa.com Omnipoint: 10digitphonenum...@omnipointpcs.com Qwest: 10digitphonenum...@qwestmp.com Me again ;) Is that for free? I just found this interesting site: http://www.tech-faq.com/how-to-send-text-messages-free.html
Re: [PHP] Text messaging from the web
Larry Martell schrieb: On Thu, Oct 14, 2010 at 10:01 AM, Sebastian Detert php-maill...@elygor.de wrote: Larry Martell schrieb: On Thu, Oct 14, 2010 at 9:45 AM, Paul M Foster pa...@quillandmouse.com wrote: Folks: Being fairly geezerly, I know almost nothing about this, so be gentle. Assuming someone entered information in a form on a website. Normally, you would email the responses to someone. But what if you wanted to send this information to a smartphone via text messaging? Is this possible, given normal programming tools (PHP/Javascript), or would you have to go through some commercial web to text messaging gateway? Does anyone know if this could be done, and how? You can send a text message via email: Verizon: 10digitphonenum...@vtext.com ATT: 10digitphonenum...@txt.att.net Sprint: 10digitphonenum...@messaging.sprintpcs.com T-Mobile: 10digitphonenum...@tmomail.net Nextel: 10digitphonenum...@messaging.nextel.com Cingular: 10digitphonenum...@cingularme.com Virgin Mobile: 10digitphonenum...@vmobl.com Alltel: 10digitphonenum...@message.alltel.com CellularOne: 10digitphonenum...@mobile.celloneusa.com Omnipoint: 10digitphonenum...@omnipointpcs.com Qwest: 10digitphonenum...@qwestmp.com Me again ;) Is that for free? I just found this interesting site: http://www.tech-faq.com/how-to-send-text-messages-free.html Yes, you can send text messages for free this way. I just tried it. I guess, it is only possible to use those E-Mails if you are a customer of that phone company, right? I tried it with my own provider (O2 germany), sending an email to phonenum...@o2online.de failed, I had to activate that serviceby sending +OPEN to 6245, but every email to sms costs money ... Are you sure it is possible to send sms to phones around the world to any provider? How do u distinguish between provider and country? I'm sorry if I'm asking stupid stuff
Re: [PHP] Array / form processing
Ron Piggott schrieb: I am writing a custom shopping cart that eventually the cart will be uploaded to PayPal for payment. I need to be able to include the option that the purchase is a gift certificate. At present my add to cart function goes like this: === # Gift Certificate: 1 is a gift; 2 is personal use if ( $gift_certificate == yes ) { $gift = 1; } else { $gift = 2; } $_SESSION['life_coaching_order'][$product][$gift]['quantity'] = $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1; === Now I need to display the shopping cart contents. I want to do this through an array as the contents of the shopping cart are in a session variable. I start displaying the shopping cart contents by a FOREACH loop: === foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference = $value ) { === What I need help with is that I don't know how to test the value of $gift in the above array if it is a 1 or 2 (which symbolizes this is a gift certificate). I have something like this in mind: if ( $_SESSION['life_coaching_order'] == 2 ) { But I don't know how to access all the components of the array while I am going through the FOREACH loop. By using a 1 or 2 I have made gift certificates their own product. If you a better method I could use please provide me with this feedback. Ron The Verse of the Day Encouragement from God's Word www.TheVerseOfTheDay.info First at all, I wouldn't use 1 or 2 for defining important informations. use something like define('ORDER_GIFT', 1); define('ORDER_PERSONAL',2); If you want to check all values of your array you can use several foreach loops like foreach ($_SESSION['life_coaching_order'] AS $coaching_product = $tmp_array) { foreach ($tmp_array as $coaching_gift = $tmp_array2) { switch ($coaching_gift) case ORDER_GIFT: break; case ORDER_PERSONAL: break; ) } } Personally I would prefer writing a class like class Order { private $product; private $gift; private $quantity; const ORDER_GIFT=1; const ORDER_PERSONAL=2; function getGift() { return $this - gift; } } using $_SESSION['life_coaching_order'][] = new Order(); foreach ( $_SESSION['life_coaching_order'] as $order ) { switch ( $order - getGift() ) case ORDER_GIFT: break; case ORDER_PERSONAL: break; } I hope that will help you, Sebastian http://elygor.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and HBCI?
Do you have any specifications for HBCI interfaces? Socket connection, XML Exchange, DB Access ? If you have C code for such things, it should be possible to convert this to php code maybe Stephan Ebelt schrieb: On Fri, Oct 08, 2010 at 01:50:12PM +0100, a...@ashleysheridan.co.uk wrote: How do you mean? Did you want to process payments? Or wad it more of an actual banking thing you needed? I've not heard of hbci before, so can't offer much information back. HBCI is the german Home Banking Computer Interface which is supported by most banks over here. There are free implementations such as the one used in gnucash and some other projects: http://www.aquamaniac.de/sites/aqbanking/index.php (sorry, site is german but code is english). I could not find a way to use something like that from PHP code, only C and Java so far. My goal for now would be to access bank account statements in order to show the balances. I am not too eager to issue transactions. thanks, stephan Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: Stephan Ebelt s...@shared-files.de Date: Fri, Oct 8, 2010 13:37 Subject: [PHP] PHP and HBCI? To: PHP php-general@lists.php.net Hello, is there a way to do HBCI banking with PHP? stephan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need to check pdf for xss
OK THX to everyone. I will check the images with imagick and let the pdfs in adobes responsibility. One worry less. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Need to check pdf for xss
Hi, before I allow to upload images I read them and check for several html tags. If they exist I don't allow the upload. Is their any need to check pdf files, too? At the time I'm doing this, but the result is that many files are denied because of unallowed html tags. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need to check pdf for xss
Peter Lind wrote: On 14 August 2010 22:36, Sebastian Ewert seb2...@yahoo.de wrote: Hi, before I allow to upload images I read them and check for several html tags. If they exist I don't allow the upload. Is their any need to check pdf files, too? At the time I'm doing this, but the result is that many files are denied because of unallowed html tags. Reading and checking for html tags seems rather excessive - I would rather use image extensions/pdf extensions and tools to verify that the uploaded data was in fact one or the other. If someone uploads an image and you cannot get the image dimensions from the file, for instance, then it's likely not an image. Regards Peter So if imagick sais its an image/pdf there is no need to check for html tags? My upload class first checks the mime type with imagick. Do you know other tools? I think I can remember of a xss tutorial where the js code was included to an image. But I haven't tried it so I couldn't test the result. He used a programm to combine images with text. Perhaps I have undestood something wrong. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encoding for W3C Validation
Rick Dwyer wrote: Hello List. In the Alt section of the IMG tag below, the variable $myitem has a value of Who's There. echo div class='myclass'a href='#' class='color_thumb' img src='/itemimages/$mypic' alt='$myitem' width='60' When running through W3C validator, the line errors out because of the ' in Who's. I tried: $myitem=(htmlentities($myitem)); But this has no affect on Who's. What's the best way to code this portion so the apostrophe is handled correctly? TIA, --Rick Use it echo 'div class=myclassa href=# class=color_thumb img src=/itemimages/'.$mypic.' alt='.$myitem.' width=60 ...' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encoding for W3C Validation
Ashley Sheridan wrote: On Tue, 2010-08-03 at 15:00 -0400, Rick Dwyer wrote: On Aug 3, 2010, at 2:47 PM, Sebastian Ewert wrote: Rick Dwyer wrote: Hello List. In the Alt section of the IMG tag below, the variable $myitem has a value of Who's There. echo div class='myclass'a href='#' class='color_thumb' img src='/itemimages/$mypic' alt='$myitem' width='60' When running through W3C validator, the line errors out because of the ' in Who's. I tried: $myitem=(htmlentities($myitem)); But this has no affect on Who's. What's the best way to code this portion so the apostrophe is handled correctly? TIA, --Rick Use it echo 'div class=myclassa href=# class=color_thumb img src=/itemimages/'.$mypic.' alt='.$myitem.' width=60 ...' Thanks Sebastian. In the above, what is the function of the period in front of $myitem? --Rick It is a string concatenation in PHP. But, as my last email on this thread shows, you only need to add ENT_QUOTES to your htmlentities() call and everything will work. Thanks, Ash http://www.ashleysheridan.co.uk If you use single quotes you can't use variables inside the string. You have to combine strings and variables or two strings with a dot. echo 'foo'.$bar; http://www.php.net/manual/de/language.types.string.php I'm not shure but I think to validate xhtml you need the double quotes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Does class length slow down performance
Hi, I'm developing an joomla component and my helper an user classes are crowing bigger and bigger. The helper class is for static use only. Does class size decrease performance of my php scripts, even for static usage? Is there a general rule when to split a class to keep performance up? Thanks for reply, Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Does class length slow down performance
Ashley Sheridan wrote: On Thu, 2010-07-22 at 10:49 +0200, Sebastian Ewert wrote: Hi, I'm developing an joomla component and my helper an user classes are crowing bigger and bigger. The helper class is for static use only. Does class size decrease performance of my php scripts, even for static usage? Is there a general rule when to split a class to keep performance up? Thanks for reply, Sebastian How big roughly are we talking here? The larger a script or class is, the more memory this uses per instance. Out of the box, PHP doesn't have a way to share the memory space of libraries and classes, so creating massive scripts for a website is not a great idea. The user object contains 850 Lines and about 50 functions. It also implements 2 table-objects (DB Tables). The helper class contains 500 Lines. The typical approach is to break classes down into blocks such that you need only include per script what you actually need to run that script. For example, having a full class dedicated to user management would need somewhere to create a list of users. Now it doesn't make sense to include this user management class each time you want to create a list of users, so you could split that method off into a different class where it can easily be shared without every script loading in lots of unnecessary code. Thats exacty the point. In my user class I have functions whitch return object-lists of diffrent users or strings with html-form elements for managing this user account. But if I put all these in a helper class I would anyway need to implement the user object there, because of the other getter functions (getUserName etc.) and the table-objects. I always thought this would be less effective, because I have more instances of objects. Thanks, Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Does class length slow down performance
Jay Blanchard wrote: [snip] Thats exacty the point. In my user class I have functions whitch return object-lists of diffrent users or strings with html-form elements for managing this user account. But if I put all these in a helper class I would anyway need to implement the user object there, because of the other getter functions (getUserName etc.) and the table-objects. I always thought this would be less effective, because I have more instances of objects. [/snip] Sounds like a major refactoring is in order, how reusable is your class? There is not enough room in this e-mail to cover the basic and intermediate practices of OO design but it sounds like you may need to re-think your design. Does this class do one thing and only one thing? Does it do it really well? Thanks for your advice. I know that I have to go much deeper into programm design. I would appreciate if you could send me some links with practial examples. I've only read some theoretical and very general stuff about it and cannot link everything to the real world. Just from what I am reading I see that we have a user class (getUserName) and that class returns lists of users? It sounds as if to me that the user class talks not only about a single user, but perhaps all of the users (object lists of different users). That was just to generalize things. My user class only returns informations for one user. These informations are values of db-fields or generated html strings. But other classes like my message class have functions that return lists of instances of their own class. From what you've written I think its better to extract these functions into helper classes. But if you want to get all messages that refer to one specific msg its better to leave that function in the message class, isn't it? Or if you want to get a list with all friends of a specific user?(friends are not implemented yet) On the surface that sounds like to classes to me, a user class and a class to manipulate said users. But back to my first Problem: Is a class with 850 lines to long? If it is should I take all the html genarating functions and put them in a helper class? If I do so and there is no way to call those functions without initalizing the main user object, will there still be an increase of performance? Thanks, Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Does class length slow down performance
Peter Lind wrote: It's unlikely to cause you performance problems unless you've got a huge amount of traffic - and then you could probably fix your problems easier than refactoring classes. Personal anecdote: I've worked on classes longer than 3K lines with no marked performance problem. That doesn't mean I recommend it, though: bigger classes are a pain to maintain as you loose overview of what's in the class. Regards Peter So you think that a length of 850 lines won't lead to a performance problem? The site is not online yet. I just wanted to know when to split a class and if there are performance problems with to long classes. Thanks, Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Does class length slow down performance
No, I don't think there will be problems. I also think the only way you'll ever find out whether it *will* be a problem in your system is by testing. I've started some benchmarks with apachebench but the problem is I don't have any benchmarks to compare with. And so I started looking for something to change. I will try to find some good links for you but there is one book that I can whole-heartedly recommend (I have all of my younger, um, less experienced programmers read it); Head First Object-Oriented Analysis and Design http://oreilly.com/catalog/9780596008673/ Thanks to all. My question is answered and I have some lecture for the next week. Greets, Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to get the filesize of an online document?
Hello everyone, i have a little problem. I want to get the filesize of an online document (for example an rss or atom feed). I tried the filesize() function, but this doesn't work. I also search for options with cUrl but i didn't found any solution. Hope you can give me some hints or code snipplets so that i can work for an solution. Thanks in advance Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to get the filesize of an online document?
Hi, thanks for the hint, but how can i get the size when the header isn't specified? is there the possibility to count the bits and bytes when i get the file? Sebastian Gevorg Harutyunyan schrieb: Hi, You must get content-length http header value, but sometimes header is not set and you don't have any chance to get size. For more info see **get_headers** function description. On Wed, Apr 8, 2009 at 12:31 PM, Sebastian Muszytowski s.muszytow...@googlemail.com mailto:s.muszytow...@googlemail.com wrote: Hello everyone, i have a little problem. I want to get the filesize of an online document (for example an rss or atom feed). I tried the filesize() function, but this doesn't work. I also search for options with cUrl but i didn't found any solution. Hope you can give me some hints or code snipplets so that i can work for an solution. Thanks in advance Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Best Regards, Gevorg Harutyunyan www.soongy.com http://www.soongy.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] stream_set_timeout issue with ssl connection
Hello everyone, i have an issue with stream_set_timeout and ssl. I've written a php irc newsbot and my code looks like this: [...] while (!feof($con['socket'])) { stream_set_timeout($con['socket'], $CONFIG['qtime']); [...] I need this timeout because i want to read the news every X seconds from the Database. I use $con['buffer'] = trim(fgets($con['socket'], 4096)); to get the data. If i don't use the stream_set_timeout the bot would wait until it recieves data. In fact this solution works, but only if i connect with fsockopen to a non ssl connection. If i use a ssl connection steam_set_timeout seems to be ignored. Any clues or workarounds? Sebastian PS: You can download the whole code on http://muzybot.de/phpircbot.tar.gz or http://muzybot.de/phpircbot.zip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP + MySQL - Load last inserts
Hello :) I have some troubles with php and mysql. I have a normal MySQL Query and this returns X 3 rows. Now i want to get the last 3 inserted values. For Example i've inserted A, B, C, D, E I want to get the last inserted values, e.g. E D C (in reversed order) So how to do this? I already searched the web and the whole php.net site but i don't see any workaround. Thanks in advance Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
Thijs Lensselink schrieb: Sebastian Muszytowski wrote: Hello :) I have some troubles with php and mysql. I have a normal MySQL Query and this returns X 3 rows. Now i want to get the last 3 inserted values. For Example i've inserted A, B, C, D, E I want to get the last inserted values, e.g. E D C (in reversed order) So how to do this? I already searched the web and the whole php.net site but i don't see any workaround. Thanks in advance Sebastian It's not really a PHP question. But here goes : SELECT column FROM `table` ORDER BY column DESC LIMIT 3 Oh okay thank you very much :) I thought I must do this with php and some sort of mysql_fetch_asssoc or something like this -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP + MySQL - Load last inserts
haliphax schrieb: [..cut...] Except when your primary key value rolls over, or fills a gap between two other rows that was left when a row was deleted/moved/etc... there has got to be a better way than grabbing rows in descending order based on the auto_increment value. Are you doing the inserts one at a time? If so, why not just use code to remember what you put in the DB? I do the inserts one at a time, i could use code to remember but i think it would be very slow when i have too much users. The second thing that aware me from doing this is, why use/build ressources when you could use others? i think why should i use and add another system? I work with mysql already and when php+mysql have the function i need it's better and i don't waste ressources :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] a questoin about the # char
Hello, I want to know what the # char does. On a website I was working at, I tried to open a file with a # in it's name and I got an error. So I'd really appreciate any help to know how to avoid the error and what does the character do. Thanks a lot Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating ZIP-File with password
Dear PHP-Friends, normaly its my job to find solutions about problems around PHP. Now, i have a problem, that seems to be unsolved in PHP. Actually i create some zip-files and this works fine. $zip = new ZipArchive(); $zip-open(./foo.zip, ZIPARCHIVE::CREATE); $dir = scandir (doc/); foreach($dir as $filename) { if($filename != . || $filename != ..) { $zip-addFile(doc/.$filename, doc/.$filename); } } $zip-close(); Now, the ZIP-files must be protect. There a important files included. Each site and forum seems to have no solution about this problem. Now, I need a solution or a workarround. Are the some people, who have some ideas? Regards Sebastian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating ZIP-File with password
Hmmm... its not possible to use this function, because i can't use the command line. now, i will try to crypt my data bevor i insert them into the zip file. but this needs more performance. i will wait for other comments. I will report my solution. regards Per Jessen [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Sebastian Hopfe wrote: Now, the ZIP-files must be protect. There a important files included. Each site and forum seems to have no solution about this problem. Now, I need a solution or a workarround. Are the some people, who have some ideas? You could just use the zip command line utility and the '-P' option. However, the zip password mechanism does not really provide much in terms of protection - if you really need the encryption, I would look elsewhere. (PGP, X509). /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: back-up mysql database using PHP
Dear Vanessa You can use the SELECT ... INTO OUTFILE 'file_name' with mysql_query($vAnf, $dbconn); For the syntax you can have a look at http://dev.mysql.com/doc/refman/5.0/en/select.html Should you be allowed to send system-queries to the Server, than you should have a look to http://dev.mysql.com/doc/refman/5.0/en/backup.html There are many ways to backup the Database. I thought this will help you. Regards Sebastian Vanessa Vega [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] hello thereis there a way to create a back-up database through PHP?...i would like to create a file maybe an sql file that would served as back up of my database. Im using mysql database. I know i could use phpmyadmin to do this but i just like to have a function that would do this without going to phpmyadmin.any help? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: enhanced_list_box, 2 tables from a database
Dear kNish, first of all i have formated your PHP Code it looks better now. ?php echo tr\n; echo td height=\33\nbsp;/td\n; echo td width=\14%\ class=\style3\Artist/td\n; $options = mysql_query(SELECT artist_name FROM artist); $options=mysql_fetch_array($options); echo 'td'; enhanced_list_box(array( 'table' = 'artist', 'value_field' = 'artist_name')); function enhanced_list_box($options) { $sql = select . $options['value_field']; $sql .= from . $options['table']; $result = mysql_query($sql)or die(error in SQL); echo 'select name=', $options['value_field'],' size=1'; while ($row = mysql_fetch_array($result, MYSQL_NUM)) echo 'option value=' . $row[0] . '' . $row[0] . '/option'; echo '/select'; } echo ' /td'; echo /tr\n; echo tr\n; echo td height=\33\nbsp;/td\n; echo td width=\14%\ class=\style3\Project/td\n; $options = mysql_query(SELECT project_name FROM project); $options=mysql_fetch_array($options); echo 'td'; enhanced_list_box(array( 'table' = 'project', 'value_field' = 'project_name')); function enhanced_list_box($options) { $sql = select . $options['value_field']; $sql .= from . $options['table']; $result = mysql_query($sql)or die(error in SQL); echo 'select name=', $options['value_field'],' size=1'; while ($row = mysql_fetch_array($result, MYSQL_NUM)) echo 'option value=' . $row[0] . '' . $row[0] . '/option'; echo '/select'; } echo '/td'; ? After i had check your code, my php interpreter shows me an fatal error on the browser. kNish [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Hi, A newbie question. I have more than one table to access from a database. When I use the code as below, it gives no response on the web page. What may I do to run more than one table from the same database into the script. BRgds, kNish . . . . tr td height=33nbsp;/td td width=14% class=style3Artist/td ?php $options = mysql_query(SELECT artist_name FROM artist); $options=mysql_fetch_array($options); echo 'td'; enhanced_list_box(array( 'table' = 'artist', 'value_field' = 'artist_name')); function enhanced_list_box($options){ $sql = select . $options['value_field']; $sql .= from . $options['table']; $result = mysql_query($sql)or die(error in SQL); echo 'select name=', $options['value_field'],' size=1'; while ($row = mysql_fetch_array($result, MYSQL_NUM)) echo 'option value=' . $row[0] . '' . $row[0] . '/option'; echo '/select'; } echo '/td'; ? /tr tr td height=33nbsp;/td td width=14% class=style3Project/td ?php $options = mysql_query(SELECT project_name FROM project); $options=mysql_fetch_array($options); echo 'td'; enhanced_list_box(array( 'table' = 'project', 'value_field' = 'project_name')); function enhanced_list_box($options){ $sql = select . $options['value_field']; $sql .= from . $options['table']; $result = mysql_query($sql)or die(error in SQL); echo 'select name=', $options['value_field'],' size=1'; while ($row = mysql_fetch_array($result, MYSQL_NUM)) echo 'option value=' . $row[0] . '' . $row[0] . '/option'; echo '/select'; } echo '/td'; ? /tr http://www.php.net/a . . . . . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Sessionvariable
Dear Ronald, I would like to ask you, want kind of session you use in you application. regards Sebastian Ronald Wiplinger [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] I use at the first page a session variable to set a flag. After a few pages, or if somebody wait too long, the pages have another flag. I noticed that there are often more than one session file exist. How can I avoid that? How can I make sure that for one user is only one session file? bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with OOPHP
Dear Andrew, I think normaly it isn't possible to use another class in a class, without using extends. But you should use your array as a container. After you use as a container, you can make new instance into a array field. Now you can use the content of the container to administrate the instances of the complete class. I just changed some things at your example. Please have a look and ask if you have any questions. ?php class fruitBasket ext { private $fruits = array(); //this is a class Container public function addFruit($newFruit) { $this-fruits[] = new fruit($newFruit); } public function makeAllApples() { foreach($this-fruits AS $fruit) { $fruit-changeName(apple); } } public function showAllFruits() { foreach($this-fruits AS $fruit) { echo $fruit-showFruit().br; } } } class fruit { private $name; public function __construct($name) { $this-name = $name; } public function changeName($newName) { $this-name = $newName; } public function showFruit() { return $this-name; } } $Cls = new fruitBasket(); $Cls-addFruit(test1); $Cls-addFruit(test2); $Cls-addFruit(test3); $Cls-addFruit(test4); $Cls-addFruit(test5); $Cls-addFruit(test6); $Cls-makeAllApples(); $Cls-showAllFruits(); ? Andrew Peterson [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] I'm hoping you guys can help me out. I'm not sure if you can do this, but i'm trying to create a class that is build of another class. I also want to be able to do functions on the class1 from within class2. example: class fruitBasket{ private $fuit = array(); //this is a class public function addFruit($newFruit) { $this-fruitBasket[] = $newFruit(); } public makeAllApples() { foreach($this-fruit AS $value) { $value-changeName(apple); } } } class fruit{ private $name; public __construct($name) { $this-name = $name; } public changeName($newName) { $this-name = $newName; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Function variables in classes
It seems to be a PHP Bug, because normaly it should very well. but you can solve this problem, by a workarround. using eval($a.();); instead of $a(); in the class. Best regards Sebastian Paul van Haren [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Hi there, I'm trying to execute function variables. This works fine outside class code, but gives a fatal error when run within a class. The demo code is here: ?php function bar1 () { echo Yep, in bar1() right now\n; } function foo1 () { bar1(); $a = bar1; print_r ($a); echo \n; $a(); } class foobar { function bar2 () { echo Yep, in bar2() right now\n; } public function foo2 () { foobar::bar2(); $a = foobar::bar2; print_r ($a); echo \n; $a(); } } foo1(); $fb = new foobar (); $fb-foo2(); ? The error message reads: Fatal error: Call to undefined function foobar::bar2() in /home/paul/demo/demo.php on line 25 Is there anyone out there who can explain what's wrong in this code? Thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Function variables in classes
I think you should log it, because it seems to be, and you found this error. Regard Sebastian Paul van Haren [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Thanks, this helps. The code now works. In case this is truely a bug in PHP, where should I log it? Anything that I should do to make sure that it gets followed up? Regards, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] I need an opion!!! Thanks!
Hi, we have been using the following codes on our site for a year and I wanted to know if these codes are just spaghetti or its actual usable code. I know it can be bettered a lot I just need opinions if the codes can be used a while more until we reprogram everything as a complete CMS system. Thanks a lot! my superiors want to know because there is another coder that says these codes are just spaghetti. There is more codes but i am able to access the database fine and everything else. Of course the codes can be bettered but i dont believe its just spaghetti! I used these codes because there was no need to reinvent the wheel. I apreciate your help! -- file name: SystemComponent.php -- file name: dbconnector.php link = mysql_connect($host, $user, $pass); mysql_select_db($db); register_shutdown_function(array($this, 'close')); } //*** Function: query, Purpose: Execute a database query *** function query($query) { $this-theQuery = $query; return mysql_query($query, $this-link); } //*** Function: getQuery, Purpose: Returns the last database query, for debugging *** function getQuery() { return $this-theQuery; } //*** Function: getNumRows, Purpose: Return row count, MySQL version *** function getNumRows($result){ return mysql_num_rows($result); } //*** Function: fetchArray, Purpose: Get array of query results *** function fetchArray($result) { return mysql_fetch_array($result); } //*** Function: close, Purpose: Close the connection *** function close() { mysql_close($this-link); } } ? - File Name: Sentry.php userdata); session_destroy(); return true; } //== // Log in, and either redirect to goodRedirect or badRedirect depending on success function checkLogin($user = '',$pass = '',$group = 10,$goodRedirect = '',$badRedirect = ''){ // Include database and validation classes, and create objects require_once('DbConnector.php'); require_once('Validator.php'); $validate = new Validator(); $loginConnector = new DbConnector(); // If user is already logged in then check credentials if ($_SESSION['user'] $_SESSION['pass']){ // Validate session data if (!$validate-validateTextOnly($_SESSION['user'])){return false;} if (!$validate-validateTextOnly($_SESSION['pass'])){return false;} $getUser = $loginConnector-query(SELECT * FROM rusers WHERE user = '.$_SESSION['user'].' AND pass = '.$_SESSION['pass'].' AND thegroup = .$group.' AND enabled = 1'); if ($loginConnector-getNumRows($getUser) 0){ // Existing user ok, continue if ($goodRedirect != '') { header(Location: .$goodRedirect.?.strip_tags(session_id())) ; } return true; }else{ // Existing user not ok, logout $this-logout(); return false; } // User isn't logged in, check credentials }else{ // Validate input if (!$validate-validateTextOnly($user)){return false;} if (!$validate-validateTextOnly($pass)){return false;} // Look up user in DB $getUser = $loginConnector-query(SELECT * FROM rusers WHERE user = '$user' AND pass = PASSWORD('$pass') AND thegroup = $group AND enabled = 1); $this-userdata = $loginConnector-fetchArray($getUser); if ($loginConnector-getNumRows($getUser) 0){ // Login OK, store session details // Log in $_SESSION[user] = $user; $_SESSION[pass] = $this-userdata['pass']; $_SESSION[thegroup] = $this-userdata['thegroup']; if ($goodRedirect) { header(Location: .$goodRedirect.?.strip_tags(session_id())) ; } return true; }else{ // Login BAD unset($this-userdata); if ($badRedirect) { header(Location: .$badRedirect) ; } return false; } } } } ? - filename: validator.php errors[] = $description; return false; } } // Validate text only function validateTextOnly($theinput,$description = ''){ $result = ereg (^[A-Za-z0-9\ ]+$, $theinput ); if ($result){ return true; }else{ $this-errors[] = $description; return false; } } // Validate text only, no spaces allowed function validateTextOnlyNoSpaces($theinput,$description = ''){ $result = ereg (^[A-Za-z0-9]+$, $theinput ); if ($result){ return true; }else{ $this-errors[] = $description; return false; } } // Validate email address function validateEmail($themail,$description = ''){ $result = ereg (^[^@ [EMAIL PROTECTED]@ ]+\.[^@ \.]+$, $themail ); if ($result){ return true; }else{ $this-errors[] = $description; return false; } } // Validate numbers only function validateNumber($theinput,$description = ''){ if (is_numeric($theinput)) { return true; // The value is numeric, return true }else{ $this-errors[] = $description; // Value not numeric! Add error description to list of errors return false; // Return false } } // Validate date function validateDate($thedate,$description = ''){ if (strtotime($thedate) === -1 || $thedate == '') { $this-errors[] = $description; return
[PHP] R: [PHP] Date Function Questions
afaik it's the system time. Cheers En3pY Sebastian Konstanty Zdrojewski URL: http://www.en3py.net/ E-Mail: [EMAIL PROTECTED] Le informazioni contenute in questo messaggio sono riservate e confidenziali. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora Lei non fosse la persona a cui il presente messaggio è destinato, La invito ad eliminarlo dal Suo Sistema ed a distruggere le varie copie o stampe, dandone gentilmente comunicazione. Ogni utilizzo improprio è contrario ai principi del D.lgs 196/03 e alla legislazione Europea (Direttiva 2002/58/CE). -Messaggio originale- Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Inviato: lunedì 12 dicembre 2005 6.57 A: PHP-General Oggetto: [PHP] Date Function Questions This maybe a dumb questions, but in php where is the information taken from for the date() function? Is it pulled through Apache or the hardware or in the php.ini file? I am having an issue to where the time arbitraly changed one day from PST to CST. -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date: 09/12/2005 smime.p7s Description: S/MIME cryptographic signature
[PHP] R: [PHP] Performance question
Hi, I do prefer the first style programming after longer time in programming PHP. I like the idea of keeping HTML and PHP code separate for cosmetic purpose as well as mantainance. Actually a code with PHP only, I mean really with NO HTML code in it, is more portable and easy to mantain. As for performance I don't know, but a difference is present for sure. Actually I never benchmarked the performance of the two styles, but wanted to give my 10 cents for the coding style :) Cheers En3pY Sebastian Konstanty Zdrojewski URL: http://www.en3py.net/ E-Mail: [EMAIL PROTECTED] Le informazioni contenute in questo messaggio sono riservate e confidenziali. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora Lei non fosse la persona a cui il presente messaggio è destinato, La invito ad eliminarlo dal Suo Sistema ed a distruggere le varie copie o stampe, dandone gentilmente comunicazione. Ogni utilizzo improprio è contrario ai principi del D.lgs 196/03 e alla legislazione Europea (Direttiva 2002/58/CE). -Messaggio originale- Da: Anders Norrbring [mailto:[EMAIL PROTECTED] Inviato: lunedì 5 dicembre 2005 8.27 A: PHP General Oggetto: [PHP] Performance question I've been spending some time to find performance pros and cons, but so far haven't had any real luck. Can someone on this list say which is better than the other, and also why, when it comes to these kinds of syntax: 1. php code ? html statements?= $variable ?/end tag tag?= $var2 ?/end tag ? more php code 2. php code echo tag$variable/end tag; echo tag$var2/end tag; more php code In both cases, some processing is done, not that 'echo' uses a lot of cpu time, but still... On the other hand, there are more jumps in and out for the interpreter in the first example... I'd love some thoughts on this. -- Anders Norrbring Norrbring Consulting -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.362 / Virus Database: 267.13.11/191 - Release Date: 02/12/2005 smime.p7s Description: S/MIME cryptographic signature
[PHP] R: [PHP] Re: Performance question
Hi, actually I think that if you have performance problem is when you make the calculations and process. If you make processes while giving output to the client, you might have some problems whether being somehow output buffering dependant... I would rather leave the output management as final step, concentrating all the process in the first part hidden and not involved into the parsing of HTML code (useless). I rather prefer the approach of data entry/input - process - output instead of data entry - output while processing especially when the performance of process is critical. Do essential first, have fun laterz =:) Obviously IMHO :) Have fun, En3pY Sebastian Konstanty Zdrojewski URL: http://www.en3py.net/ E-Mail: [EMAIL PROTECTED] Le informazioni contenute in questo messaggio sono riservate e confidenziali. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora Lei non fosse la persona a cui il presente messaggio è destinato, La invito ad eliminarlo dal Suo Sistema ed a distruggere le varie copie o stampe, dandone gentilmente comunicazione. Ogni utilizzo improprio è contrario ai principi del D.lgs 196/03 e alla legislazione Europea (Direttiva 2002/58/CE). -Messaggio originale- Da: James Benson [mailto:[EMAIL PROTECTED] Inviato: lunedì 5 dicembre 2005 13.40 A: php-general@lists.php.net Oggetto: [PHP] Re: Performance question I dont think either will give a performance decrease any less than the other will do. Anders Norrbring wrote: I've been spending some time to find performance pros and cons, but so far haven't had any real luck. Can someone on this list say which is better than the other, and also why, when it comes to these kinds of syntax: 1. php code ? html statements?= $variable ?/end tag tag?= $var2 ?/end tag ? more php code 2. php code echo tag$variable/end tag; echo tag$var2/end tag; more php code In both cases, some processing is done, not that 'echo' uses a lot of cpu time, but still... On the other hand, there are more jumps in and out for the interpreter in the first example... I'd love some thoughts on this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.362 / Virus Database: 267.13.11/191 - Release Date: 02/12/2005 smime.p7s Description: S/MIME cryptographic signature
[PHP] R: [PHP] how to unregister session stored as multidimensional array?
Try ? @reset( $_SESSION['client'] ); while ( list( $var, $val ) = @each( $_SESSION['client'] ) ) { if ( $var != 'name' ) unset( $_SESSION['client'][ $val ] ); } ? a bit dirty but works... :-/ Sebastian Konstanty Zdrojewski URL: http://www.en3py.net/ E-Mail: [EMAIL PROTECTED] Le informazioni contenute in questo messaggio sono riservate e confidenziali. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora Lei non fosse la persona a cui il presente messaggio è destinato, La invito ad eliminarlo dal Suo Sistema ed a distruggere le varie copie o stampe, dandone gentilmente comunicazione. Ogni utilizzo improprio è contrario ai principi del D.lgs 196/03 e alla legislazione Europea (Direttiva 2002/58/CE). -Messaggio originale- Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Inviato: lunedì 5 dicembre 2005 21.46 A: PHP eMail List Oggetto: [PHP] how to unregister session stored as multidimensional array? Is this possible at all: I have stored info from form in session: $_SESSION['client']['name'] = 'Name' $_SESSION['client']['address'] = 'Address' $_SESSION['client']['city'] = 'City' $_SESSION['client']['state'] = 'State' $_SESSION['client']['zip'] = 'Zip Now, I want to unregister all $_SESSION['client'] info EXCEPT $_SESSION['client']['name']. With session_unregister('client'); I clear everything. session_unregister('address'); doesn't clear this session. session_unregister($_SESSION['client']['address']); doesn't work. What am I doing wrong? Thanks for any help. -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.362 / Virus Database: 267.13.11/191 - Release Date: 02/12/2005 smime.p7s Description: S/MIME cryptographic signature
[PHP] R: [PHP] Problem with Frames and Sessions
Change the logon script. The cookies of each frame are loaded separately, so if you want the session to be active in all the frames, at least once you got to reload them. The easiest way, I think, is to change the logon script: put it on a main page and once the user is logged in, create the frameset. The session will be available in all the frames. Cheers, En3pY Sebastian Konstanty Zdrojewski URL: http://www.en3py.net/ E-Mail: [EMAIL PROTECTED] Le informazioni contenute in questo messaggio sono riservate e confidenziali. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora Lei non fosse la persona a cui il presente messaggio è destinato, La invito ad eliminarlo dal Suo Sistema ed a distruggere le varie copie o stampe, dandone gentilmente comunicazione. Ogni utilizzo improprio è contrario ai principi del D.lgs 196/03 e alla legislazione Europea (Direttiva 2002/58/CE). -Messaggio originale- Da: Shaun [mailto:[EMAIL PROTECTED] Inviato: martedì 29 novembre 2005 0.53 A: php-general@lists.php.net Oggetto: [PHP] Problem with Frames and Sessions Hi, I have a frameset with a left column and a main column. I have a login script with a form in the left column. When I log in I get a menu in the left column which targets to the main column. My problem is that when I click on links in the left column nothing appears in the main frame, however if I refresh the browser then the links work. I am sure this must be a PHP session problem but I don't have any experience using frames, does anyone have suggestions as to what the problem might be? Thanks for your advice. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.362 / Virus Database: 267.13.8/184 - Release Date: 27/11/2005 smime.p7s Description: S/MIME cryptographic signature
[PHP] R: [PHP] Intersecting Dates
If you got also the year you can transform the dates into UNIX TIMESTAMP and check againist that. If you don't have that, write down a simple procedure that converts dates into days since 01/01 and use that method, but it will be faulty if the date ranges overlap years. Cheers En3pY Sebastian Konstanty Zdrojewski URL: http://www.en3py.net/ E-Mail: [EMAIL PROTECTED] Le informazioni contenute in questo messaggio sono riservate e confidenziali. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora Lei non fosse la persona a cui il presente messaggio è destinato, La invito ad eliminarlo dal Suo Sistema ed a distruggere le varie copie o stampe, dandone gentilmente comunicazione. Ogni utilizzo improprio è contrario ai principi del D.lgs 196/03 e alla legislazione Europea (Direttiva 2002/58/CE). -Messaggio originale- Da: Shaun [mailto:[EMAIL PROTECTED] Inviato: sabato 26 novembre 2005 22.18 A: php-general@lists.php.net Oggetto: [PHP] Intersecting Dates Hi, Given a start day and month and end day and month (i.e. 01-01 to 31-03) how can one check if another set intersects these dates? Thanks for your advice -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.362 / Virus Database: 267.13.8/183 - Release Date: 25/11/2005 smime.p7s Description: S/MIME cryptographic signature
[PHP] R: [PHP] Re: Can't execute external program
Try verifying the following: - does the web server user (apache/nobody) have a shell? - can the web server user/group execute the file? (x permission) I believe this is your problem, the exec option for the apache would be useful if you need to run an executable from the apache service, not from the command line. Check out the earlier and I think you're gonna solve your issue. Regards, En3pY Sebastian Konstanty Zdrojewski URL: http://www.en3py.net/ E-Mail: [EMAIL PROTECTED] Le informazioni contenute in questo messaggio sono riservate e confidenziali. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora Lei non fosse la persona a cui il presente messaggio è destinato, La invito ad eliminarlo dal Suo Sistema ed a distruggere le varie copie o stampe, dandone gentilmente comunicazione. Ogni utilizzo improprio è contrario ai principi del D.lgs 196/03 e alla legislazione Europea (Direttiva 2002/58/CE). -Messaggio originale- Da: n.g. [mailto:[EMAIL PROTECTED] Inviato: giovedì 24 novembre 2005 10.16 A: Henry Castillo Cc: php-general@lists.php.net Oggetto: [PHP] Re: Can't execute external program put the executable into another directory rather than DOC_ROOT, maybe you have reached apache security settings. or try add `option +exec' to your apache conf, but be aware this maybe a security problem to your site to do so. On 11/24/05, Henry Castillo [EMAIL PROTECTED] wrote: Hi Still desperate DOCUMENT_ROOT is /var/www/html Check all settings at http://provi.voicenetworx.net:8080/t.php From the command line it runs perfectly: [EMAIL PROTECTED] html]# /var/www/html/myprog -E 123456789098.dat sample1.txt sample1.new (no output, it just creates the file .new) Here is the php I've created, fairly simple: ?php exec(/var/www/html/myprog -E 123456789098.dat sample1.txt sample1.new); phpinfo(); ? On 11/22/05, n.g. [EMAIL PROTECTED] wrote: is /var/www/html your web root dir ? maybe its the plobrem. On 11/23/05, Henry Castillo [EMAIL PROTECTED] wrote: That was on of the first things I checked: safe mode is set to off Any ideas... Henry Voip tech said the following on 11/20/2005 10:31 PM: Hello, I cannot get exec(), system() or passthru() to run an extenal program. From the command line it runs perfectly: snip I'm getting frustrated, Any help will be deeply appreciated Henry The answer is probably in your php.ini. Look into whether you are running in safe mode or not, and if you are whether you have your program in the safe_mode_exec_dir or not. Also check disable_functions to see if any of the ones you are having trouble with are listed. - Ben -- Tomorrow will be a good day :-) -- Tomorrow will be a good day :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.362 / Virus Database: 267.13.7/180 - Release Date: 23/11/2005 smime.p7s Description: S/MIME cryptographic signature
Re: [PHP] 'God' has spoken... :-)
Matthew Weier O'Phinney wrote: * Sebastian wrote: i spent hundreds of hours building my site on php4, im not about to rewrite any of it to make it 'compatible' with php5. Don't rewrite it to make it compatible with PHP5 -- rewrite it to take advantage of PHP5's better performance and new features. Besides, you probably will not need to rewrite any code -- probably just do some cleanup and a few changes. More below. maybe my impressions of php5 are wrong, but last i heard apps built on php4 may or may not work right under php5 - meaning you would have to rewrite code. am i wrong? I've converted quite a bit of PHP4 code to PHP5, and I've had very few problems. Typically, I find that I get a few notices about deprecated functions or some warnings -- and the warnings are usually about things that should have generated warnings in PHP4, didn't, but now do in PHP5 (things like declaring a class property twice, for instance). The fixes for these are typically not rewrites, but, as I said, fixes -- if anything, they make the code better. Additionally, it's fairly easy to make such code backwards compatible with PHP4, if you feel the need to do so. so i am 'afraid' of going with php5 in fear it will break my website. The only way to find out if it will break is to try it. I'm willing to wager that your code, if written well, will not only *not* break, but likely perform better. explain better performance. if i have a script written on php4 and i run it on php5 i doubt its going to be any faster.. even so, i don't think there is much if at all any speed gain from php4 to php5... speculating of course, but i have yet to read any evidence php5 is faster than php4. a few extra features isn't enough to convince *most* to switch to php5. now if they say php5 is 20% faster than php4 than i would upgrade overnight ;) -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.8/71 - Release Date: 8/12/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 'God' has spoken... :-)
Greg Donald wrote: On 8/14/05, Sebastian [EMAIL PROTECTED] wrote: now if they say php5 is 20% faster than php4 than i would upgrade overnight ;) Who is 'they' ? Go write a benchmark and see for yourself. obviously coming from the developers.. i guess im more or less wanting to know exactly where the php5 performance gains are over php4, if any. sure i can do benchmarks, but again, would be nice to hear from the devs on certain performance gains as well as overall. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.8/71 - Release Date: 8/12/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] which operating system?
I will be building a new server and wondering what would be a good choice for php/mysql/apache other than redhat. I was thinking either Debian or CentOS. can anyone share their thoughts on them for php environment? does anyone use them on high traffic php sites? or is there not a difference in what distro you run php on? sorry these may sound like stupid questions but i mostly used redhat since i started using php and thought i'd try something different. thanks. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.8/71 - Release Date: 8/12/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 'God' has spoken... :-)
Jochem Maas wrote: if you haven't seen it yet and are interested in the future of php you might be interested in the _big_ thread on php-internals that starts with the message: http://www.manucorp.com/archives/internals/200508/msg00398.php IMHO every halfbaked php coder should read it ;-) to cut it short for those to busy, or what not, Rasmus offered his his vision of php6 (which seems will be the version that will first bring the awesome unicode [and date?] functionality to the masses - hey thats us! :-) ) and there seems to be pretty much unanimous agreement on his main points (lots of discussion on more issues/ideas other people have brung up in response) the future's bright, the future is green. why php6 and not php5? look how long it took to get to php4 (with php5 just starting to rolling out) and people are already talking about php6? sure it is just a 'versioning' thing, but right now huge numbers of php users aren't using php5 (including me) on production environments, let alone start talking about php 6. anyway, i think i will be with php4 for a long time to come. kinda of how apache2 hasn't been a real success over apache1. i just hope php doesn't end up being bloat-filled with the not-so-useful thing just taking up resources. i only been coding in php for a couple(3) years so maybe i have no idea what im talking about. maybe a 'php-lite' version ;) -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.8/71 - Release Date: 8/12/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 'God' has spoken... :-)
Matthew Weier O'Phinney wrote: * Sebastian [EMAIL PROTECTED] : why php6 and not php5? look how long it took to get to php4 (with php5 just starting to rolling out) and people are already talking about php6? My observation was that more people jumped to PHP4 from PHP3 than have so far from PHP4 to PHP5. And PHP5 has hardly just started to roll out; the official 5.0.0 release was over a year ago. sure it is just a 'versioning' thing, but right now huge numbers of php users aren't using php5 (including me) on production environments, let alone start talking about php 6. And why aren't you using PHP5? Is there any specific reason? Is it because your service provider doesn't offer it? If so, ask them why -- and report it here. As soon as PHP5 hit stable, I started using it, and I've never looked back. Performance is better, and there are many features -- exceptions, the new OOP model, autoload, iterators, etc. -- that simply have no analogs in PHP4. anyway, i think i will be with php4 for a long time to come. Please tell the list why -- what does PHP4 offer over PHP5 for you? I honestly want to know, and I'm sure there are others who would be interested to see why people are not making the switch i spent hundreds of hours building my site on php4, im not about to rewrite any of it to make it 'compatible' with php5. maybe my impressions of php5 are wrong, but last i heard apps built on php4 may or may not work right under php5 - meaning you would have to rewrite code. am i wrong? so i am 'afraid' of going with php5 in fear it will break my website. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.8/71 - Release Date: 8/12/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] one more mysql question
they are just grumpy old men i guess.. it is not like you asked a windows question on a linux list.. i've seen stupid html questions here.. yet they get answered. i always try to help when i can and if i cant offer help i dont say anything because that wasnt the way i was raised. it is rude. at least if it was too offtopic for the list someone could of just nicely said ask on the mysql list but that wasn't case. anyway, consider this a done deal as you already received help. [EMAIL PROTECTED] wrote: Hey! Stop it! I put a question on wrong place. I was nailed for it by John. I accepted I was wrong. I apologized. What do you want now? Sebastian wanted to help – in difference to you and John. Even it’s “wrong place”. I guess you would never stop and help to car in trouble on highway because you are IT or “it’s not your department”, ha? C’mon… It’s really not place to be sarcastic… -afan Jochem Maas wrote: John Nichel wrote: Sebastian wrote: while were not on the subject John I have a question about your wife ... oh shit wrong list ;-) no no I meant to ask about sand - how do I make a CPU using the stuff? take what other say with a grain of salt.. im sure you're using php to pull info from mysql anyway.. And he might be using Apache on Linux like the majority of PHP users. More than likely outputting some HTML and maybe some JavaScript. Probably using a PC too. So what? the fact is without mysql php would be nowhere where it is today.. its like peanut butter w/o the jelly.. The fact is, without IBM, PHP would be nowhere it is today. Say, here's an idea, let's just make this the IBM and anything which relates to it list. see my reply in the other email.. im sure it will work for you. I'll be sure to tell everyone on the MySQL list that they can shut it down, since you have it covered over here. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.8/71 - Release Date: 8/12/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] one more mysql question
[EMAIL PROTECTED] wrote: I tried this one: SELECT trans_no FROM orders WHERE trans_no IN ( SELECT trans_no FROM special_orders ) but gives me an error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT trans_no FROM special_orders )' at line 5 ??? Philip Hallstrom wrote: I apology for mysql question posted here, but, as I said once, I like you guys more! :) have two tables: orders and special_orders. foreign key is trans_no. I can't figure it out how to create a query that pulls orders from the orders tables that are NOT in special_orders table? I can never remember the syntax, but you want to LEFT JOIN the tables and then only return rows where the resulting special_orders column is NULL. something like this (most likely wrong syntax): SELECT o.trans_no, s.trans_no FROM orders o LEFT JOIN special_orders s ON o.trans_no = s.trans_no WHERE s.trans_no IS NULL But that should get you started... -philip try this (untested): SELECT * FROM trans_no LEFT JOIN special_orders ON (trans_no.id = special_orders.id) WHERE special_orders.id IS NULL; just change id to the primary key... -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.8/71 - Release Date: 8/12/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] one more mysql question
take what other say with a grain of salt.. im sure you're using php to pull info from mysql anyway.. the fact is without mysql php would be nowhere where it is today.. its like peanut butter w/o the jelly.. see my reply in the other email.. im sure it will work for you. [EMAIL PROTECTED] wrote: ok. accept critique. :( @moderator: please take my mysql questions off the php list. I apology to everybody for any inconviniance. -afan John Nichel wrote: [EMAIL PROTECTED] wrote: I apology for mysql question posted here, but, as I said once, I like you guys more! :) I like my wife more than I like the people on these lists, but I don't go asking her my MySQL questions. I go to the MySQL list for that. What you like doesn't make your post any less off topic, or any less against netiquitte. To me, it's even a bigger offense than the newbie wo doesn't know any better...you know you're question is off topic, and yet you ask anyway...numerous times. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.8/71 - Release Date: 8/12/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] graph - dowloads/hr
Richard Lynch wrote: On Tue, August 9, 2005 3:07 pm, Sebastian wrote: i'd like to create a graph with the amount of downloads per hour, i am a little confused how i should go about this. i know i can use rrdtool/mrtg, but im looking for more 'user friendly' graphs with custom colors,etc. each time someone downloads a file it is incremented in the db and the last time the file was downloaded. i am unsure about the data i would need to store to create and if what i am storing is enough to do this. any suggestions or tools that already exists to create this types of graph? select count(*) as score from downloads where date_add(download_time, interval 1 hour) = now() group by filename order by score desc Then you use jpgraph on that result set. Or just roll your own with http://php.net/gd Richard, the last download time is store in unix timestamp.. is it possible to still do it? thanks. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.6/69 - Release Date: 8/11/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting average down to 5
Ryan A wrote: Hey, Having a bit of a problem working out the logic to this one (its 5am now...), basically people vote on pics like hotornot.com, but here they vote on a scale of 1-5 (one being something like what was hit by a bus at birth and five being the person you will never have a chance to have children with) :-D Anyway.how do i get the averages down to a max of 5pts? eg: 1.2 is ok 4.5 is ok 5.0 is ok 3.1 is ok 1.1 is ok 2.2 is ok etc 97.3 is not ok 5.3 is not ok etc Thanks, Ryan i assume you're using mysql and each row has a value of 1 - 5. SELECT AVG(rating) as rating FROM table WHERE id = $id then that will give you numbers as such: 3.4242 4.1212 etc.. then use number_format() number_format($row['rating'], 1, '.', ''); 3.4 4.1 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.6/69 - Release Date: 8/11/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] force download
some of my users are complaining that when they try download media files (mp3, mpeg, etc) their media player opens and doesn't allow them to physically download the media. These are IE users, firefox seems to like my code, but IE refuses to download the file and plays it instead.. can anyone view my code and see how i can force media file downloads on IE? --snip-- header('Cache-control: max-age=31536000'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['date']) . ' GMT'); if ($extension != 'txt') { header(Content-disposition: inline; filename=\$file[type]\); } else { // force txt files to prevent XSS header(Content-disposition: attachment; filename=\$file[type]\); } header('Content-Length: ' . $file['size']); switch($extension) { case 'zip': $headertype = 'application/zip'; break; case 'exe': $headertype = 'application/octet-stream'; break; case 'mp3': $headertype = 'audio/mpeg'; break; case 'wav': $headertype = 'audio/wav'; break; case 'mpg': $headertype = 'video/mpeg'; break; case 'avi': $headertype = 'video/avi'; break; default: $headertype = 'unknown/unknown'; } header('Content-type: ' . $headertype); --/snip-- -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] force download
James R. wrote: That would be browser dependent, something you have no control over. Maybe you can include a little text message saying right-click save as for the users not intelligent enough to figure it out themselves. - Original Message - From: Sebastian [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Wednesday, August 10, 2005 12:00 PM Subject: [PHP] force download some of my users are complaining that when they try download media files (mp3, mpeg, etc) their media player opens and doesn't allow them to physically download the media. These are IE users, firefox seems to like my code, but IE refuses to download the file and plays it instead.. can anyone view my code and see how i can force media file downloads on IE? --snip-- header('Cache-control: max-age=31536000'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['date']) . ' GMT'); if ($extension != 'txt') { header(Content-disposition: inline; filename=\$file[type]\); } else { // force txt files to prevent XSS header(Content-disposition: attachment; filename=\$file[type]\); } header('Content-Length: ' . $file['size']); switch($extension) { case 'zip': $headertype = 'application/zip'; break; case 'exe': $headertype = 'application/octet-stream'; break; case 'mp3': $headertype = 'audio/mpeg'; break; case 'wav': $headertype = 'audio/wav'; break; case 'mpg': $headertype = 'video/mpeg'; break; case 'avi': $headertype = 'video/avi'; break; default: $headertype = 'unknown/unknown'; } header('Content-type: ' . $headertype); --/snip-- there has to be a way to tell stupid IE Not to open the damn file. i'll be damned to find a way. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] force download
James R. wrote: That would be browser dependent, something you have no control over. Maybe you can include a little text message saying right-click save as for the users not intelligent enough to figure it out themselves. - Original Message - From: Sebastian [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Wednesday, August 10, 2005 12:00 PM Subject: [PHP] force download some of my users are complaining that when they try download media files (mp3, mpeg, etc) their media player opens and doesn't allow them to physically download the media. These are IE users, firefox seems to like my code, but IE refuses to download the file and plays it instead.. can anyone view my code and see how i can force media file downloads on IE? --snip-- header('Cache-control: max-age=31536000'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['date']) . ' GMT'); if ($extension != 'txt') { header(Content-disposition: inline; filename=\$file[type]\); } else { // force txt files to prevent XSS header(Content-disposition: attachment; filename=\$file[type]\); } header('Content-Length: ' . $file['size']); switch($extension) { case 'zip': $headertype = 'application/zip'; break; case 'exe': $headertype = 'application/octet-stream'; break; case 'mp3': $headertype = 'audio/mpeg'; break; case 'wav': $headertype = 'audio/wav'; break; case 'mpg': $headertype = 'video/mpeg'; break; case 'avi': $headertype = 'video/avi'; break; default: $headertype = 'unknown/unknown'; } header('Content-type: ' . $headertype); --/snip-- forgot to mention, they can't right click to save as because if you notice from my code i am pushing the file to them... without an actual path to the file. so if they did do a save as it'll just save the php/html output, which will be blank in this case. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] force download
Richard Lynch wrote: On Wed, August 10, 2005 12:49 pm, Chris wrote: if ($extension != 'txt') { header(Content-disposition: inline; filename=\$file[type]\); } else { // force txt files to prevent XSS header(Content-disposition: attachment; filename=\$file[type]\); } The Content-disposition header is a made-up bull-crap thing that came about with html enhanced (cough, cough) email. If you want *EVERY* browser to download something, forget this header and use: header(Content-type: application/octet-stream); The Content-disposition will, on *SOME* browsers, on *SOME* OSes appear to be useful for getting the filename in the dialog prompt for Save As... to be the filename you want. Unfortunately, it does *NOT* work universally. If you want a UNIVERSAL solution, make the URL look like it's a static URL and have the filename you want to be used appear at the end of the URL. Converting dynamic to static-looking URLs is covered in many places. Google for PHP $_SERVER PATHINFO Under no circumstances should you be using headers like audio/mpeg if you want me to download it -- I guarantee my browser will open that up in an MP3 player. Many other users will also have been led through the process to make that happen. But if the browser doesn't download application/octet-stream it's a very very very broken browser. if i don't use Content-disposition IE downloads the file as unknown (mp3, exe, or otherwise) with no extension and the names the file you are downloading becomes the name of the script that was called. lol? can never win with IE .. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generating a 404 status message with header()
Paul Waring wrote: On Mon, Aug 08, 2005 at 04:37:12PM -0400, Eric Gorr wrote: Should it? Is it possible to write a doesexists.php script which would cause the 404 directive to be triggered? I also tried: header(Status: 404 Not Found); but this did not work either. Try searching the archives for this list, I'm sure this question, or one very similar to it, was asked and answered fairly recently. Paul header('HTTP/1.0 404 Not Found'); -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.4/66 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generating a 404 status message with header()
Jasper Bryant-Greene wrote: Sebastian wrote: Paul Waring wrote: On Mon, Aug 08, 2005 at 04:37:12PM -0400, Eric Gorr wrote: Should it? Is it possible to write a doesexists.php script which would cause the 404 directive to be triggered? I also tried: header(Status: 404 Not Found); but this did not work either. Try searching the archives for this list, I'm sure this question, or one very similar to it, was asked and answered fairly recently. Paul header('HTTP/1.0 404 Not Found'); I'm afraid you missed the original point of the question. His problem was that Apache does not display the ErrorDocument if PHP sends a 404 status header. This behaviour is by design (Apache checks to see if the PHP script handling the request exists; it does, so Apache does not display the ErrorDocument) What I would recommend is to send the 404 header and then include() the ErrorDocument as specified in Apache's config. Jasper yeah sorry, i must of deleted the original topic and all i had was the followups.. anyway, what do you want, the cake and eat it too? why two types of 404's? i mean you either use ErrorDocument or use php headers.. i guess i dont understand why use both.. to send 404 header and then display a custom document you might as well use the ErrorDocument in apache, it would be the same affect. might as well set ErrorDocument in apache to point to a php file and do whatever you want in the php script.. like send more 404 headers.. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.4/66 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] graph - dowloads/hr
i'd like to create a graph with the amount of downloads per hour, i am a little confused how i should go about this. i know i can use rrdtool/mrtg, but im looking for more 'user friendly' graphs with custom colors,etc. each time someone downloads a file it is incremented in the db and the last time the file was downloaded. i am unsure about the data i would need to store to create and if what i am storing is enough to do this. any suggestions or tools that already exists to create this types of graph? -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.4/66 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] graph - dowloads/hr
Philip Hallstrom wrote: i'd like to create a graph with the amount of downloads per hour, i am a little confused how i should go about this. i know i can use rrdtool/mrtg, but im looking for more 'user friendly' graphs with custom colors,etc. each time someone downloads a file it is incremented in the db and the last time the file was downloaded. i am unsure about the data i would need to store to create and if what i am storing is enough to do this. any suggestions or tools that already exists to create this types of graph? jpgraph can do it... as can a lot of other graph/chart libraries... http://www.aditus.nu/jpgraph/ yeah, i found that, but i dont know what type of data i would need to store to get the downloads an hour (24 hours). likewise, i only increment a counter and last time file was download and im pretty sure this isn't enough to generate such graphs. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.4/66 - Release Date: 8/9/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] writing to file
i have this app where a user fills out a form and after submit it displays the values they entered. i want to save this info to a file after they submit, then allow them to download the file. some other user does the same, fills in the form and allow that person to download the file... and so on. i don't know how i should go about doing this.. rather than keep creating files i would like to recycle the file each time someone uses the system, but that can lead to other problems.. like several users using the app at once.. any suggestion/ideas/tips how i should do this? basically, just write the info from POST to a file and allow them to download the file. obviously i am worried how secure i will be able to make this. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.2/65 - Release Date: 8/7/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return Path
try using -f mail($toemail, $subject, $message, $from, '-f [EMAIL PROTECTED]'); [EMAIL PROTECTED] wrote: I don't seem to be able to set the return path using the mail() function. I can't figure out why from will let me set it, but not the return path. $headers = 'From: [EMAIL PROTECTED]' . \r\n . 'Return-path: [EMAIL PROTECTED]' . \r\n . 'X-Mailer: PHP/' . phpversion(); mail($email, $subject, $message, $headers); Any thoughts? Andrew Darrow Kronos1 Productions www.pudlz.com -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.1/64 - Release Date: 8/4/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fast count of recordset in php...
you'd be suprized how fast an index can be.. you should read the manual on indexes, http://dev.mysql.com/doc/mysql/en/mysql-indexes.html If a table has 1,000 rows, this is at least 100 times faster than reading sequentially while you may not get 100x faster, it will be faster than having no index.. also try using mysql_num_rows() $sql = mysql_query(SELECT col FROM tbvara WHERE Varunamn LIKE '$checkLev%'); // record count echo mysql_num_rows($sql); PS, 'reply all' to list. Gustav Wiberg wrote: Hi there! There are about 300 records. You're right, I can add an index, but Is that the only way to get a faster solution? /mr G @varupiraten.se - Original Message - From: Sebastian [EMAIL PROTECTED] To: Gustav Wiberg [EMAIL PROTECTED] Sent: Saturday, August 06, 2005 11:08 PM Subject: Re: [PHP] Fast count of recordset in php... how many records in the table? its going to be slow no matter what, especially if you have a lot of records.. your searching each record then counting them.. do you have any indexes? judging by your query you can add index on Varunamn and it should be more speedy.. Gustav Wiberg wrote: Hello there! How do i get a fast count of a recordset in php? Look at this code: $sql = SELECT COUNT(IDVara) cn FROM tbvara WHERE Varunamn LIKE '$checkLev%'; $querys = mysql_query($sql); //Count products in db // $dbArray = mysql_fetch_array($querys); $nrOfProducts = $dbArray[cn]; It's slow... Why? Any suggestions? /mr G @varupiraten.se -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.1/64 - Release Date: 8/4/2005 -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.0/63 - Release Date: 2005-08-03 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.1/64 - Release Date: 8/4/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using File to count number of lines
you sure each is on its own line (\n) ? if you're only getting a value of 1 it is likely putting everything on a single array key.. Tom Chubb wrote: I'm having a problem with the following code: ?php $file = http://www.mysite.co.uk/mailing_list_database.list;; $lines = count(file($file)); echo $lines ; ? I'm trying to show the number of subscribers to my visitors from a text file, but it returns a value of 1 when it should be 5000. I think it's to do with recognising the line break but I don't know how to make it work!?! (I've looked on php.net for the file, fopen count functions and can't find anything, although fopen mentions using the -t mode. Any ideas? Thanks, Tom -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using File to count number of lines
do this: $file = 'http://www.mysite.co.uk/mailing_list_database.list'; echo 'pre'; print_r($file); echo '/pre'; im pretty sure you'll only see 1 key.. if each has its own line, you would see something like: Array ( [0] = foo [1] = foo [2] = foo [3] = foo ) etc... Tom Chubb wrote: When I open the list in notepad everything is on one line with a square box character. When I open it in wordpad, it's one email address on each line. On 04/08/05, Sebastian [EMAIL PROTECTED] wrote: you sure each is on its own line (\n) ? if you're only getting a value of 1 it is likely putting everything on a single array key.. Tom Chubb wrote: I'm having a problem with the following code: ?php $file = http://www.mysite.co.uk/mailing_list_database.list;; $lines = count(file($file)); echo $lines ; ? I'm trying to show the number of subscribers to my visitors from a text file, but it returns a value of 1 when it should be 5000. I think it's to do with recognising the line break but I don't know how to make it work!?! (I've looked on php.net for the file, fopen count functions and can't find anything, although fopen mentions using the -t mode. Any ideas? Thanks, Tom -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using File to count number of lines
sorry, i forgot to put file(); Sebastian wrote: do this: $file = 'http://www.mysite.co.uk/mailing_list_database.list'; echo 'pre'; print_r($file); echo '/pre'; im pretty sure you'll only see 1 key.. if each has its own line, you would see something like: Array ( [0] = foo [1] = foo [2] = foo [3] = foo ) etc... Tom Chubb wrote: When I open the list in notepad everything is on one line with a square box character. When I open it in wordpad, it's one email address on each line. On 04/08/05, Sebastian [EMAIL PROTECTED] wrote: you sure each is on its own line (\n) ? if you're only getting a value of 1 it is likely putting everything on a single array key.. Tom Chubb wrote: I'm having a problem with the following code: ?php $file = http://www.mysite.co.uk/mailing_list_database.list;; $lines = count(file($file)); echo $lines ; ? I'm trying to show the number of subscribers to my visitors from a text file, but it returns a value of 1 when it should be 5000. I think it's to do with recognising the line break but I don't know how to make it work!?! (I've looked on php.net for the file, fopen count functions and can't find anything, although fopen mentions using the -t mode. Any ideas? Thanks, Tom -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strip out too many newlines
im working on a comment/forum app and when a user enters too many carriage returns i want to remove them before insert to db. example, user input: -snip- [quote=user] foo [/quote] bunch of extra lines more text... -snip- I to change to: [quote=user]foo[/quote] more text... i try this regexp: $message = preg_replace('#(\[quote(=(quot;||\'|)([^\]]*)\\3)?\])\s+#i', \\1\n, $_POST['message']); doesn't remove / replace anything. I need for it to work when they use [quote=xx] or [quote] and ends with [/quote] any help? -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strip out too many newlines
thanx for the reply, but 1 problem. there is not only \n there are \r in the POST too (carriage returns) so a string can look like this: $string = '[quote=xx]\r\nfoo\r\n[/quote]\r\nmore text\r\n\r\n\r\n\r\n'; and your regexp will only catch if there is just \n any solution for \r\n in combination too? ty. Marco Tabini wrote: Don't know much about the app you're writing, but does this do the trick for you? echo preg_replace ('! ( \[quote (?:=[^\]]*)? \] )# Capture the [quote=xxx] part \n*# Eliminate any extra newlines here (.+)# Get contents \n*# Eliminate any extra newlines here (\[/quote\])# Capture this part \n*# Eliminate any extra newlines here !x', \$1\$2\$3\n\n, $string); HTH, Marco -- BeebleX - The PHP Search Engine http://beeblex.com On 8/4/05 9:44 AM, Sebastian [EMAIL PROTECTED] wrote: [quote=user] foo [/quote] bunch of extra lines more text... -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.0/63 - Release Date: 8/3/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strip out too many newlines
that works for my orginal request, but i found something else: $string = '[quote=xx]foo[/quote]\nmore text\r\n\r\n\r\n\r\nmore text'; now if they enter more carriage returns i get the results from above. its no big deal, but you always have someone trying to 'break' the system. thanks, i really need to learn some regexp. Marco Tabini wrote: Try changing the \n* patterns to (?:\r?\n)* Cheers, Marco -- BeebleX - The PHP Search Engine http://beeblex.com On 8/4/05 10:39 AM, Sebastian [EMAIL PROTECTED] wrote: [quote=user] foo [/quote] bunch of extra lines more text... -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.0/63 - Release Date: 8/3/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] encrypting urls
i need to mask (hide) some vars in a url so they arent visible to the user. example, i want a url like this: page?id=3something=12more=12 to turn into: page?id=3;LyFU;MLFxvy so from LyFU i can access $something and from MLFxvy $more any ideas how i can do this? doesn't have to be 100% secure, just a simple way hide it from the user. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array()
is it always necessary to call array() when you do something like this: mysql_query(SELECT ); while($rows .) { $data[] = $rows; } if so, why? i have a habit of never calling array() and someone told me i shouldn't do this. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] allowing selected file types
i know i shouldn't rely on mime types for file verification but anyways.. I use application/zip which works fine on firefox and only allows zips.. however, on Internet explorer it doesn't work since IE returns application/x-zip-compressed for zips.. problem with this is it also allow rar files.. so even checking mime types is just as useless as not using it.. one mime type allows two different file types. pffft. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] dynamic two column table
i know how to break up db results into two tables but im having a hard problem with this: db structure --- | id | cid | title --- | 1 | 2 | hardware | 2 | 3 | software | 3 | 3 | software | 4 | 2 | hardware how can i have hardware on column 1 and software on column 2 using 1 query? i thought a simple if statement on cid might do it but regardless it spreads the results on both columns. thanx. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] define (true/false)
i never really used constants before so this may sound stupid.. when you define a constant using define() and want to return true/false is this logical: if($bars == 3) { define('BAR', 1); } then: if(BAR) { // bars is true } or should i need to do an else statement as well: if($bars == 3) { define('BAR', 1); } else { define('BAR', 0) } lastly is it more practical to just do: if($bars == 3) { $bar = true; } i am curious what most people would use. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.5/58 - Release Date: 7/25/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to check for a static call from an object
Sebastian Mendel wrote: Hi, how can i check if a method is called statically when called from inside another object? (without debug_bactrace()) class foo { function bar() { if ( isset( $this ) ) { return 'not static'; } return 'static'; } function bar2() { foo::bar(); } } sorry, my mistake // returns 'static' echo foo::bar(); // returns 'not static' but should be 'static' $foo = new foo; echo $foo-bar2(); so, how can i prevent a method from called static or not called static? and btw. does anynone know why it is not good to let one function handle both mehtods of calling (static and not static) as in PHP 5 you will get notices if called wrong - but PHP doesnt support multiple function-definitions like: class foo { static function bar() { return ANY_DEFAULT_VALUE; } function bar() { return $this-value; } } or even class foo { static function bar( $param ) { return $param; } function bar() { return $this-param; } } or is this at least an issue for the internals-list? -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Tracking a mobile phone
The phone would have to have GPS capabilities.. Ethilien wrote: I think that would require tapping the cellphone network, which I doubt they would let you do since it be a major violation of privacy, because you could track the general location of anyone on their network. Thomas wrote: Hi there, I was wondering if anybody has attempted to track a mobile phone through a country. I know that this is usually more a case for the FBI . a friend of mine is going on a 4 month bike tour and I would like to 'track' him for locations. I thought of an sms receiving system, but if could do any other way would be great. Any ideas? Thomas -- Certified E-mail - No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.336 / Virus Database: 267.9.0/50 - Release Date: 7/16/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] max_file_size
Each time i try setting MAX_FILE_SIZE in a form and using the upload error code to check if the file is large it always uploads the entire file before showing the error that the file is too big.. either the manual is incorrect or this does not work as every method i've tried always waits for the file to be uploaded before it errors. eg: form enctype=multipart/form-data method=post input type=hidden name=MAX_FILE_SIZE value=1048576 / input type=file name=userfile size=29 / input type=submit name=submit value=Upload / /form switch($_FILES['userfile']['error']) { case 1: $message[] = 'Error #1 - ...'; break; case 2: $message[] = 'Error #2 - File is too big'; break; case 3: $message[] = 'Error #3 - File was partially uploaded'; break; } --snip -- IF no error then start upload... --snip yet it waits for file to upload before error. I've been using php for serveral years and i cant remember ever getting this to work like the manual states. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] max_file_size
Ahmed Saad wrote: hi Sebastain, On 7/12/05, Sebastian [EMAIL PROTECTED] wrote: yet it waits for file to upload before error. I've been using php for serveral years and i cant remember ever getting this to work like the manual states. Quoting the *php manual* The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted. (((This is an advisory to the browser))), PHP also checks it. Fooling this setting on the browser side is quite easy, so never rely on files with a greater size being blocked by this feature. The PHP settings for maximum-size, however, cannot be fooled. This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too big and the transfer failed. In a nut-shell, it's just a hint to the browser that may or may NOT consider it. -ahmed it doesnt seem to work on IE or Firefox.. two of the most popular browsers.. this shoudn't even be in the manual then because if it doesnt work for these two browsers then i would consider it pointless to use. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Register globals and ini_set
if you have php = 4.2.3 yes, otherwise no. it has to be set in php.ini, .htaccess, or httpd.conf [EMAIL PROTECTED] wrote: Hi, If i use, at the beginning of my scripts, ini_set('register_globals', 0), register globals will be turned off? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MMcache question
you sound exactly like someone i know.. i enjoy reading your long posts.. no sarcasm ;-) i'd defently hire you, but you're probably too expensive ;-) Richard Lynch wrote: On Sat, June 25, 2005 3:37 am, Catalin Trifu said: No! You don't have to rewrite your application. What mmacache does is to keep a bytecode version of the script available so that PHP won't have to reparse the script every time, which is expensive and also has a nice code optimizer. This is a common misconception about PHP cache systems... The PHP parser is *NOT* the big win Avoiding the hard disk read is the big win The PHP parser, even in PHP 5, just is NOT that complex. We're not talking C++ here. We're not even talking C. It's PHP! The entire language fits on a couple web pages for cripes' sake. [Not all the module/function stuff, just what the PARSER has to figure out] mmcache, Turck, eaccalerator, Zend Cache, whatever. They all have this oft-repeated misconception that they make your script faster because the PHP parser is taken out of the loop. The PHP parser being taken out of the loop is just gravy -- Something the cache does just because it's mind-numbingly easy, once you develop a cache at all. The true performance win is not having to hit the hard drive to *read* the PHP script before you parse it. It's already in RAM. The Zend Cache will make most applications at least 2 X as fast. About 1.9 of this speed increase probably comes from the fact that the script is in RAM. And maybe only 0.1 from the PHP parser getting bypassed. I made the 1.9 and 0.1 numbers up out of thin air for illustrative purposes!!! They are NOT real numbers. They *ARE* representative of the imbalance at work here. The 2 X number ain't made up. That's what Zend customers routinely reported in worst-case situations when I worked there (several years ago). 4 X was often the real world speed-up. You don't get a 2 X speed-up from the PHP parser not ripping through a bunch of text. No way. No how. You could (possibly) achieve similar speed-ups just having a RAM disk for all your PHP code. Though I think even a RAM disk has significant overhead in mimicing the file control function calls that is beggared by the Cache lookup. There are pathalogical cases where the Cache will do you no good at all, or even degrade performance. The most obvious one is if you have *WAY* too many PHP scripts scattered into *WAY* too many files, and your site has a *LOT* of pages with widely-distributed viewing. IE, imagine a site with 10,000 pages, but instead of the home page being the one everybody hits all the time, that site has everybody deep-linking to all the pages equally often. Also imagine that each of the 10,000 pages opens up 10 *different* PHP include files to generate its output. [This is an extreme pathalogical example... But less extreme real-world cases exist.] The Cache will end up thrashing and re-loading script after script because they can't all fit in RAM at once. I saw one client that literally had snippets of PHP code spread out in thousands of files, which they were combining to create PHP scripts on the fly from the database in a combinatorial-explosive algorithm. The Cache they used (not naming names, because it's irrelevent) was actually slowing down their site, a little bit, due to the overhead involved. They would have to have consolidated scripts, thrown *WAY* more RAM at it, or just completely changed their algorithm to fix it. I think they ended up doing a little of all that. Plus throwing more hardware at it. PHP is a shared-nothing architecture for a reason. :-) Most sites have a couple include files that get loaded on every page. Those pretty much get loaded into RAM and never move. And that's where the cache shines. No disk read. Just RAM. Raw Hardware Speed, baby. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ad management
i am looking for a simple ad management app to keep track of ad views/impressions. i was looking at phpadsnews, but it seems way too much bloat of what i need i to do. anyone know of a simple ad script to keep track of views/impressions? thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] the BACKSLASH
backslash was invented for windows ;) Jochem Maas wrote: the backslash has caught us all out when we first started, and beyond. many 'noobs' have had the fortune of being explained, in depth, how and why concerning the backslash by a singular Richard Lynch ... but obviously nobody is immune (spot the mistake): http://www.zend.com/codex.php?id=15single=1 made me chuckle, thanks Richard - also for the whereis function and the many tips! :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Converting [and] to XML format- help/advise requested
Dotan Cohen wrote: On 6/15/05, Sebastian Mendel [EMAIL PROTECTED] wrote: Dotan Cohen wrote: Hi gurus. I'm having fun replacing the text within [ and ] to XML format on 4000+ files on a windows XP machine. I installed php (and an apache server) on the machine because it is the only language the I am remotely familiar with. I want and text that is with [ and ] to be enclosed with note and /note. Going through the archives I found this nice regex (I changed it a bit- I hope that I didn't break anything important) that fits into str_replace: str_replace(/[([a-zA-Z]+?)]/, note.$what was_inside_the_parethesis./note, $string); str_replace doesnt support regular expressions http://www.php.net/str_replace what you need is preg_replace() http://www.php.net/preg_replace But how on sweet mother Earth do I get the $what was_inside_the_parethesis variable to stick into the note tags? I tried functions that would remove the [ and ], then do $new_str=note.$what was_inside_the_parethesis./note; and then replace the whole [$what was_inside_the_parethesis] with $new_str. I did get that far. preg_replace( '/\[([^\]]+)\]/', 'note\1/note', $string); Now the catch! If $what_was_inside_the_parethesis contains the word 'algebra' then I want nothing returned- in other words [$what was_inside_the_parethesis] should be cut out and nothing put in it's place. I added an if function in there that checked the presence of the word algebra, but it ALWAYS returned blank. preg_replace( '/\[(algebra|([^\]]+))\]/', 'note\2/note', $string); just to mention, you need only the second example, the first ist just to explain the step toward the final ocde. The code works great for [] tags that do not contain the word algebra. If the word algebra is alone between the tags then it returns note/note, which I can easily remove with one more line of code. But if the word algebra appears with another word, then it is converted to a note just as if it did not contain the word. $search = array( '/\[[^\]*algebra[^\]*\]/', '/\[([^\]]+)\]/', ); $replace = array( '', 'note\1/note', ); preg_replace( $search, $replace, $string); Thank you Sebastian. Know that I not only appreciate your assistance, but that I also make a genuine effort to learn from your example. I think that it's about time that I learned to brew regexes. On my to google now... there are just two things you need to learn regular expressions: the PHP-manual: http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php http://www.php.net/manual/en/reference.pcre.pattern.syntax.php http://www.php.net/manual/en/ref.pcre.php http://www.php.net/manual/en/ref.regex.php and the regex coach: http://www.weitz.de/regex-coach/ -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: incrementing a register global
Aaron Todd wrote: I am posting data to a php script. I have several variables that are the same except the number at the end is different. So the url of the called script will be something like: http://www.something.com/test.php?name1=Samname2=Billname3=Joe On my script I am using substr() and strrchr() to get the number of last variable: $names = substr(strrchr($_SERVER['QUERY_STRING'],),7,1); I am then trying to run a loop to call each variable and just print it on the screen: for($i=1;$i=$boxes;$i++){ echo $_GET['name'].$i; } did you tried foreach() with $_GET ( or $_REQUEST ) ? foreach ( $_GET as $key = $var ) { echo $key . ' = ' . $var; } but this is not incrementing a register global but 'accessing a superglobale array' -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Freing memory resources?
Gustav Wiberg wrote: Hi there! I have a script that runs about 10 minutes... Localy on my computer (Windows XP 2.6Ghz, Apache) the computer hangs a little now and then when the script is running. Is there any good way of releasing more memory while the script is running? The script could take 20 minutes, it's not a big matter how long the script takes. (As long as the server can do other things at the same time) why do you expect this comes from memory-consumption? did you check your Querys? try 'EXPLAIN SELECT ...' and check your indices how large are your tables? -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Freing memory resources?
Sebastian Mendel wrote: Gustav Wiberg wrote: Hi there! I have a script that runs about 10 minutes... Localy on my computer (Windows XP 2.6Ghz, Apache) the computer hangs a little now and then when the script is running. Is there any good way of releasing more memory while the script is running? The script could take 20 minutes, it's not a big matter how long the script takes. (As long as the server can do other things at the same time) why do you expect this comes from memory-consumption? did you check your Querys? try 'EXPLAIN SELECT ...' and check your indices how large are your tables? Hi Sebastian! The table are about 600-700 rows, but i only select 25 rows at a time, so I guess that isn't the issue. For each row, a comparison is done with a textfile that has almost 30.000 rows. I guess this is the problem is... It takes time to load same textfile for each row, but an array for 30.000 rows should not be done either or should it? Is there a better way of solving this? The script loads after 25 rows, because of I don't want to get any timeout... We don't have any own webserver, so we have to rely on our Webhotel-supplier. And our webhotel doesn't wan't to change certain thing for security reasons. why not move the text-file into the DB? of course not as a whole. or why not elsewise take 25 lines from the textfile against the 700 rows in the DB? or not load the whole file in the array, check line by line - http://www.php.net/fgets -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: unable to load php_gd2.dll
ddiffa wrote: Okay I at loss. I have tried but i can seem to get the php_gd2.dll to work properly. Any help this is what i have done so far. I have in my php.ini file, check phpinfo() that you are using the right php.ini ; Directory in which the loadable extensions (modules) reside. extension_dir = C:\PHP\extensions I have also uncommented the extension = php_gd2.dll I have in the c:\php\extension folder the php_gd2.dll I have restarted IIS but still nothing I am using Window XP $ 2000 with IIS 5.0 but still nothing what means 'nothing'? does it start? or does it report any errors? what says phpinfo() about gd? -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Converting [and] to XML format- help/advise requested
Dotan Cohen wrote: Hi gurus. I'm having fun replacing the text within [ and ] to XML format on 4000+ files on a windows XP machine. I installed php (and an apache server) on the machine because it is the only language the I am remotely familiar with. I want and text that is with [ and ] to be enclosed with note and /note. Going through the archives I found this nice regex (I changed it a bit- I hope that I didn't break anything important) that fits into str_replace: str_replace(/[([a-zA-Z]+?)]/, note.$what was_inside_the_parethesis./note, $string); str_replace doesnt support regular expressions http://www.php.net/str_replace what you need is preg_replace() http://www.php.net/preg_replace But how on sweet mother Earth do I get the $what was_inside_the_parethesis variable to stick into the note tags? I tried functions that would remove the [ and ], then do $new_str=note.$what was_inside_the_parethesis./note; and then replace the whole [$what was_inside_the_parethesis] with $new_str. I did get that far. preg_replace( '/\[([^\]]+)\]/', 'note\1/note', $string); Now the catch! If $what_was_inside_the_parethesis contains the word 'algebra' then I want nothing returned- in other words [$what was_inside_the_parethesis] should be cut out and nothing put in it's place. I added an if function in there that checked the presence of the word algebra, but it ALWAYS returned blank. preg_replace( '/\[(algebra|([^\]]+))\]/', 'note\2/note', $string); just to mention, you need only the second example, the first ist just to explain the step toward the final ocde. The code works great for [] tags that do not contain the word algebra. If the word algebra is alone between the tags then it returns note/note, which I can easily remove with one more line of code. But if the word algebra appears with another word, then it is converted to a note just as if it did not contain the word. $search = array( '/\[[^\]*algebra[^\]*\]/', '/\[([^\]]+)\]/', ); $replace = array( '', 'note\1/note', ); preg_replace( $search, $replace, $string); -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: unable to load php_gd2.dll
Sebastian Mendel wrote: ; Directory in which the loadable extensions (modules) reside. extension_dir = C:\PHP\extensions I have also uncommented the extension = php_gd2.dll I have in the c:\php\extension folder the php_gd2.dll I have restarted IIS but still nothing I am using Window XP $ 2000 with IIS 5.0 but still nothing what means 'nothing'? does it start? or does it report any errors? what says phpinfo() about gd? Well, this is the error i get PHP Warning: PHP Startup: Unable to load dynamic library 'c:/windows/system32\php_gd2.dll' - The specified module could not be found. in Unknown on line 0 I have also tried pointing the extension_dir to the c:/php/extension, but it still give the same error did you check your Windows System Eventviewer? this error doesnt mean that 'php_gd2.dll' can not found, but that another dll, required by php_gd2.dll can not be found. -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: unable to load php_gd2.dll
; Directory in which the loadable extensions (modules) reside. extension_dir = C:\PHP\extensions I have also uncommented the extension = php_gd2.dll I have in the c:\php\extension folder the php_gd2.dll I have restarted IIS but still nothing I am using Window XP $ 2000 with IIS 5.0 but still nothing what means 'nothing'? does it start? or does it report any errors? what says phpinfo() about gd? Well, this is the error i get PHP Warning: PHP Startup: Unable to load dynamic library 'c:/windows/system32\php_gd2.dll' - The specified module could not be found. in Unknown on line 0 I have also tried pointing the extension_dir to the c:/php/extension, but it still give the same error did you check your Windows System Eventviewer? this error doesnt mean that 'php_gd2.dll' can not found, but that another dll, required by php_gd2.dll can not be found. I checked the even view but no help there. What dll do you think i would need? Please I appreciate your help. extension_dir = c:\php\extensions\ http://www.php.net/manual/en/install.windows.extensions.php Please do not forget the last backslash -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: formatting paragraphs in to strings
Paul Nowosielski wrote: I'm having a perplexing problem. I'm gather data through a textarea html from field and dumping it to MySQL. I want to display the data as a long string with no carriage returns or line breaks in a dhtml div window. The problem I'm have is that the form data is remembering the carriage returns. I tried using trim() and rtrim() with no luck. The data is still formatted exactly like it was inputed. this happens only if the text is dsiplayed as pre-formated, like inside pre/pre-tags, but this can also be done by CSS Any ideas why this is happening and how I can format the text properly?? not, with any look at your code or results try preg_replace( '|\s*|', ' ', $string ); it will replaces any occurence of one or more white-space-characters with one single space http://www.php.net/manual/en/reference.pcre.pattern.syntax.php -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: DB relationship chart generator?
Thomas wrote: Is there an app out there that can easily create a relationship (flow) diagram of a given database? DBDesigner at http://www.fabforce.net/dbdesigner4/ -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Right syntax for max value??
twistednetadmin wrote: I am making a table at my homepage that automatically collects the latest news from mysql db. I have got it to work at my own server at home, but not at www.torewestre.com (my remote site) Local settings:(WinXP Pro) Apache 2.0.54, PHP 5.0.4 and MySQL 4.1.11 Remote settings:(Unix) Apache 1.3.27, PHP 4.3.4 and MySQL 3.23.54 This is the query that works on localhost: $getnewstitle = SELECT newstitle FROM `news` WHERE news_id = ( SELECT max( news_id ) FROM news ) ; MySQL 3.x doesnt support sub-querys What it does: collects the newstitle from the field where PRIMARY key(news_id) is the highest auto_increment number. This works just as excpected on localhost but not on remote. Does anybody know the right syntax? SELECT `newstitle` FROM `news` ORDER BY `news_id` DESC LIMIT 1 -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Converting [and] to XML format- help/advise requested
Dotan Cohen wrote: Hi gurus. I'm having fun replacing the text within [ and ] to XML format on 4000+ files on a windows XP machine. I installed php (and an apache server) on the machine because it is the only language the I am remotely familiar with. I want and text that is with [ and ] to be enclosed with note and /note. Going through the archives I found this nice regex (I changed it a bit- I hope that I didn't break anything important) that fits into str_replace: str_replace(/[([a-zA-Z]+?)]/, note.$what was_inside_the_parethesis./note, $string); str_replace doesnt support regular expressions http://www.php.net/str_replace what you need is preg_replace() http://www.php.net/preg_replace But how on sweet mother Earth do I get the $what was_inside_the_parethesis variable to stick into the note tags? I tried functions that would remove the [ and ], then do $new_str=note.$what was_inside_the_parethesis./note; and then replace the whole [$what was_inside_the_parethesis] with $new_str. I did get that far. preg_replace( '/\[([^\]]+)\]/', 'note\1/note', $string); Now the catch! If $what_was_inside_the_parethesis contains the word 'algebra' then I want nothing returned- in other words [$what was_inside_the_parethesis] should be cut out and nothing put in it's place. I added an if function in there that checked the presence of the word algebra, but it ALWAYS returned blank. preg_replace( '/\[(algebra|([^\]]+))\]/', 'note\2/note', $string); just to mention, you need only the second example, the first ist just to explain the step toward the final ocde. -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting checkboxes as array
Don't forget to mention that even if you don't select a checkbox it will still add a empty record to the db.. i know for sure the foreach loop will add a record even if a box is not check, so you have to check its actually set before you start inserting. Richard Davey wrote: Hello jack, Friday, June 10, 2005, 2:16:06 AM, you wrote: jj $query = INSERT INTO media_art (media_art_id,art_id, media_id) jj VALUES ('',' . $art_id . ',' . $media_types[2]. '); jj repeat as many or few times as possible to account for the number of jj checked boxes, such as One way: for ($i = 0; $i count($media_types); $++) { $query = INSERT INTO media_art (media_art_id,art_id, media_id) VALUES ('','$art_id','{$media_types[$i]}'); // perform query here } Another: foreach ($media_types as $type) { $query = INSERT INTO media_art (media_art_id,art_id, media_id) VALUES ('','$art_id','$type'); // perform query here } Best regards, Richard Davey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting checkboxes as array
well, your trying to get the insert_id() without running the query first. so you have to add: mysql_query($query); before: $art_id = mysql_insert_id(); also, your foreach loop should be: foreach ($media_types as $type) (without the brackets []) i am assuming $media_types is an array already. jack jackson wrote: Whoops. I must be botching this syntax because this is printing ,,0,, as the query: All the first part of the query works and inserts records into the database, and it's when I try to get mysql_insert_id () that I seem to run into trouble. Ah. ave I not yet run the first query? The part of the code that actually runs it was given to me in a class and I don't quite understand how it's suppose to be working ... Thanks in advance: $trimblog = (trim($_POST['blog'])); $blog = (nl2br($trimblog)); $image = mysql_real_escape_string($final_imgname); $image_thb = mysql_real_escape_string($final_thb_filename); $pubwidth = mysql_real_escape_string(trim($_POST['art_width'])); $pubheight = mysql_real_escape_string(trim($_POST['art_height'])); $origwidth = mysql_real_escape_string(trim($_POST['orig_width'])); $origheight = mysql_real_escape_string(trim($_POST['orig_height'])); $publisher = mysql_real_escape_string(trim($_POST['publisher'])); $series = mysql_real_escape_string(trim($_POST['series'])); $subject = mysql_real_escape_string(trim($_POST['subject'])); $title = mysql_real_escape_string(trim($_POST['title'])); $caption = mysql_real_escape_string(trim($_POST['art_caption'])); $blog = mysql_real_escape_string($blog); $keywords = mysql_real_escape_string(trim($_POST['keywords'])); $query = INSERT INTO art (art_id,art_thumbnail, art_image, art_width, art_height, orig_width, orig_height, art_pub_date, publisher_id, art_creation_date, series_id, subject_id, art_title, art_caption, art_keywords, art_blog) VALUES ('',' . $image_thb . ',' . $image . ',' . $pubwidth . ',' . $pubheight . ',' . $origwidth . ',' . $origheight . ',' . $pubdate . ',' . $publisher . ',' . $orig_date . ',' . $series . ',' . $subject . ',' . $title . ',' . $caption . ',' . $keywords . ',' . $blog . '); $art_id = mysql_insert_id(); foreach ($media_types[] as $type) { $query .= INSERT INTO media_art (media_art_id,media_id, art_id) VALUES ('',' . $type . ',' . $art_id . '); // perform query here } if (!mysql_query($query) || mysql_error($query)!= ''){ $errMsg = mysql_error($query); trigger_error(Problem with addrecord: $query\r\n$errMsg\r\n, E_USER_ERROR); } else { $msgText = 'trtdstrongYour record was saved!/strong/td/tr'; } On 6/9/05, Richard Davey [EMAIL PROTECTED] wrote: Hello jack, Friday, June 10, 2005, 2:16:06 AM, you wrote: jj $query = INSERT INTO media_art (media_art_id,art_id, media_id) jj VALUES ('',' . $art_id . ',' . $media_types[2]. '); jj repeat as many or few times as possible to account for the number of jj checked boxes, such as One way: for ($i = 0; $i count($media_types); $++) { $query = INSERT INTO media_art (media_art_id,art_id, media_id) VALUES ('','$art_id','{$media_types[$i]}'); // perform query here } Another: foreach ($media_types as $type) { $query = INSERT INTO media_art (media_art_id,art_id, media_id) VALUES ('','$art_id','$type'); // perform query here } 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] string highlight
i'm looking for a function that can highlight certain search terms in a string. anyone have something already made that i can plugin to my exisiting code? I found a couple but they do not work very well.. some break html code if the string contains the keywords in the html. thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $date(l-m);
is it possible for $mydata-lastinsalled to have -MM-DD format? ie: 2004-05-31 you can use strtotime to convert it to unix timestamp to compare...something like this: $stamp = strtotime('2004-06-31'); // $mydata-lastinsalled if($stamp = strtotime('1 year ago')) { echo 'less than 1 year'; } else { echo 'over 1 year'; } otherwise its impossible to tell if it is over one year without knowing the day as well.. unless you guess and figure on the first of the month.. John Taylor-Johnston wrote: $mydata-lastinsalled = 2004-05; How can I determne if $mydata-lastinsalled is one year or more older than the current $date(l-m); Anyting simple and over looked? I have been browsing the manual:: http://ca.php.net/manual/en/function.strtotime.php http://ca.php.net/manual/en/function.date.php John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mozilla urlencode
i dont think having a + in an achor tag is standard.. but i could be wrong. John Taylor-Johnston wrote: I seem to have a problem with Mozilla or with IE? echo a name=\.urlencode($mydata-district).\/a; a name=Montr%E9al+District+%234/a 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 a name=\.$mydata-district.\/a; a name=Montréal District #4/a 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sanitizing get vars
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? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delay?
yea.. takes hours... sometimes 6+ or more. i dont post that much to the list for this reason.. if it stays like this i'll just unsubscribe.. its pointless... this is suppose to be E-mail, not post office mail. Jack Jackson wrote: Has anyone else noticed significant delays in messages getting posted? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mailing list delays
Thanks. *test* Rasmus Lerdorf wrote: We found a problem caused by a recent disk failure that wiped out a named pipe qmail needed. I am hoping the mailing list delays should be fixed now. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mailing list delays
wow, got that in 20 seconds.. can we go for a record? ;) Sebastian wrote: Thanks. *test* Rasmus Lerdorf wrote: We found a problem caused by a recent disk failure that wiped out a named pipe qmail needed. I am hoping the mailing list delays should be fixed now. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick q, most prolly 0T
you can do that with just an index.php file. say you have a directory called 'foo' with an index.php you can do something like this: if($_GET['a'] == 1) { echo 'blah'; } mysite.com/foo/index.php?a=1 would be the same as: mysite.com/foo/?a=1 Ryan A wrote: Hey, I noticed a site that is using php, but he is has shortened the url so that the filename was not shown.. eg: somesite.com/?a=1 How did they do that? if it was url rewriting it would be somesite.com/1/ so what is he using? Thanks, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php