[PHP] Re: PHP Coding Standards
charles kline wrote: Hi all, I was having a conversation with a friend and talking about coding standards in the open source community (focusing on PHP). I seem to remember there being a document out there that sort of laid it out pretty well. Anyone know where I might find a copy? PEAR has a page in their documentation about coding standards: http://pear.php.net/manual/en/standards.php HTH, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: text search in database
Vincent DUPONT wrote: Hi, I need to do a text search on some fileds in a database. I would like the users to be able to use some syntax like 'AND' 'OR' 'NOT' parentheses () and quotes to make their search queries more powefull. I face 2 problems : 1. parse the query 2. execute the search (create the appropriate SQL query) Do you known of any existing package that could parse such a syntax and /or generate some kind of sql query? tank you, vincent MySQL has a FULLTEXT index type which might provide what you need. I'm also using a program called SWISH-E (http://www.swish-e.org/) to index my website but it also allows you to index data from any source by using a custom spider. You could set this to extract data from your database in the correct format for indexing. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Can session.save_path data be saved to a database instead of a file system?
Caleb Walker wrote: I have 2 servers fail-over/load-balanced behind an F5 bigIP. I want session data to be maintained in the event one server takes a dive. In this scenario, if a user is in the middle of doing something while logged in, they will not have to lose all work and log back into the server to continue working. Can that be done without rewriting an application? I saw a link here: http://www.phpfreaks.com/quickcode/DB_eSession_class_securely_stores_PHP_sessions_in_a_MySQL_DB/286.php but this seems to be something that would have to be written into the application and I didn't write it and do not want to take on the responsibility to do so from here. Any thoughts would be much appreciated. Thank You, Caleb Yes, you can use a database to store session data and retain existing session manipulation methods. Surprisingly, the PHP manual tells you how: http://uk.php.net/manual/en/function.session-set-save-handler.php And lists a couple of examples, including this one at Zend: http://www.zend.com/zend/spotlight/code-gallery-wade8.php Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Can session.save_path data be saved to a database instead of a file system?
John W. Holmes wrote: From: "Caleb Walker" <[EMAIL PROTECTED]> This looks like modifications that need to be made to the application. I dont really want to touch the application. Instead I just want PHP, through the php.ini file or whatever to take the session data and put it in a database instead of the file system. In doing it this way, I assume that I will not have to touch somebody else's code. Can't do it that way. You need to load some PHP code that tells PHP what to do upon session starts, saves, reads, etc. Closest you could come is to set an auto prepend file that loads your session handler. ---John Holmes... This is how I would do it and would require no additional changes to the code - just set your auto prepend in a .htaccess file if you're using Apache. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Issue with 'W' in the date() function?
William Bailey wrote: Hi all, Can somebody please explain this for me... [EMAIL PROTECTED]:/usr/home/wb [11]-> php $time = strtotime('now -5 weeks'); printf("\n\n%s is in week %d of the year %d\n\n", date('Y-m-d', $time), date('W', $time), date('Y', $time)); ?> ^D 2003-12-30 is in week 1 of the year 2003 [EMAIL PROTECTED]:/usr/home/wb [12]-> Why does it return 1 as the week of the year for that date? Because week 1 is defined as the first week with four or more days in the new year. Therefore, working backwards, the 29th-31st are also in week 1 in 2004. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Date comparison
Burhan Khalid wrote: BEOI 7308 wrote: Hi I want to substract $first_date to $second_date and print the result this way : xx days, xx hours, xx minutes i tried (strtotime($second_date)-strtotime($first_date)) but what i get is a timestamp and i dont know what to do with it Is there already a function to print the result in a human readable way ? Thx http://www.php.net/date I'm not sure that helps too much. Subtracting unix timestamps will give the difference in seconds. You can then use division and remainders to calculate the hours, minutes and seconds. Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: str_replace not replacing
Aaron Merrick wrote: I'm reading in to a variable $section1 an entire php file that creates a mysql table. I can output the variable in a new file just fine (figured out what all had to be escaped in the original file). My problem is, I want to replace the table name in the original file with a new table name before I output it to the new file. But the str_replace has no effect. Neither does an ereg_replace. Is there something in the content of the file that is foiling the replace? Here is what I have right now. It produces the same file content as is read in. $search = "item"; $replace = "poem"; mkdir($replace, 0777); $section1 = file_get_contents("table_create.php"); str_replace($search, $replace, $section1); chdir($replace); $table_create = fopen($replace."_table_create.php","w+"); fwrite($table_create,$section1); ?> str_replace() doesn't affect $section1; it returns the subject with the replacements, so you'd need: $section1 = str_replace($search, $replace, $section1); Of course, you'd know this if you had RTFM ;-) http://www.php.net/str_replace Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: UK Postcodes Format
Shaun wrote: Hi, does anyone know the format of the postcodes in the UK so I can keep my database accurate? Thanks http://www.royalmail.com/portal/rm/content1?catId=400044&mediaId=9200078#3400055 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Crappy results from query
Ryan A wrote: $result=mysql_query("SELECT distinct(order_id),name,status,total FROM ". $tcname."_h2o LIMIT $limit1, $limit2"); The distinct keyword applies to the whole row. Since you're including other fields that will be different even though the name is the same, MySQL does not consider them duplicate rows. -- Stuart Hey Stuart, Thanks for replying. So what can I do to make sure I get only order_id distinct? possible? Thanks, -Ryan SELECT DISTINCT order_id FROM ... Then loop through the results and run another query to find out details of each order. HTH, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Encrypted Zip Files
Howard Miller wrote: Hi (again), I need to unzip (in/from PHP) files that have been zipped using pkzip on a windows machine using a password. Has anybody any thoughts on how to do this. I was just going to call a command line program (if I can find one!), but thought I would ask if there is something cleverer. Thanks!! A command line program is probably your best option. The unzip command under unix (and other operating systems) can take a password as an argument. HTH, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Send Attachments via mail using form
Dave Carrera wrote: Hi List, I would like to allow my visitors to send attachments via my contact form. I already have email validation, field verifications and other nice bits but I am stuck on the add attachment bit. Also would this be limited to one file or can multiple files be allowed ? Thank you in advance for any help or advise with this. Yours Truly Dave C Have you read the manual? Try reading the comments for the mail entry: http://www.php.net/mail Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: renamed images are now corrupt...
Check the permissions and ownership of the files, especially if you ran the script as some privileged user like root. chmod or chown can be used to changed these. Mike Bryan Henry wrote: Browser and FTP client act as if the image files do not exist, even though the directory contents can be views via FTP... What did I do? Bryan On Thu, 26 Feb 2004 17:56:25 -0600, Bryan Henry <[EMAIL PROTECTED]> wrote: Hello all, I wrote a small script to rename a few thousand images, both gif and jpeg... After running the script, none of the renamed images can be viewed or downloaded. Trying to download these images from an FTP client fails. FTP client attempts to download the images PASSIVE-ly Unaltered images can be downloaded as binary files with no problem.. I now have over 3000 images I cannot download or view on our website. What about rename caused this? Thank you, Bryan Henry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Parse error ???
Mike Mapsnac wrote: The script should upload files (images). Error message is give below, any ideas why I get this errror message? Parse error: parse error in /var/www/html/uploadproc.php on line 3 die() needs brackets around its arguments, eg: die("Error! The expected file wasn't a part of the submitted form"); Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Parse error ???
Is this what it actually looks like? if(!move_uploaded_file($_FILES['myfile']['tmp_name '], "/var/www/html/upload/")) { die "Error! Moving the uploaded file failed."; If so, the files array shouldn't be like that. It shouldn't be split onto two lines. Try $_FILES['myfile']['tmp_name']. Mike Mike Mapsnac wrote: brackets solve the probleb. But why I have the warning messages? The permission on the directory is correct. Any ideas what can cause such messages? Warning: move_uploaded_file(/var/www/html/upload/): failed to open stream: Is a directory in /var/www/html/uploadproc.php on line 11 Warning: move_uploaded_file(): Unable to move '/tmp/phpiMrdlQ' to '/var/www/html/upload/' in /var/www/html/uploadproc.php on line 11 Error Moving the uploaded file failed. From: Michael Nolan <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: [PHP] Re: Parse error ??? Date: Thu, 04 Mar 2004 13:40:46 + Mike Mapsnac wrote: The script should upload files (images). Error message is give below, any ideas why I get this errror message? Parse error: parse error in /var/www/html/uploadproc.php on line 3 die() needs brackets around its arguments, eg: die("Error! The expected file wasn't a part of the submitted form"); Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: wysiwyg editor
Outbound wrote: Hello, do you have any recommendation about what wysiwyg html(javascript) editor to use in php projects ? People usually don't like textareas and want to increate usability :-/ Best regards, Roman HTMLArea. Version 2 supports IE5.5+ V2: http://www.interactivetools.com/products/htmlarea/ Version 3 is currently out in RC1 and supports Mozilla 1.3+ as well as IE. I've got it running on a couple of sites and it works a treat: V3: http://dynarch.com/mishoo/htmlarea.epl Really easy to install - upload files, add a few lines of JavaScript and it will convert all textareas on the page into HTML editors. Back to PHP (!) - someone has written a PHP replacement for the Perl/Aspell spell checker that interfaces with HTMLArea. Not tried it, but since it's pretty much a straight clone it should work alright. Cheers, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Get "nice" variables from POST
Ryan A wrote: Does this look nicer? $fields = array('username', 'password', ...); foreach($fields as $key) $$key = $_POST[$key]; Hi Marek, A bit confused...whats the meaning of the double $ for "key"...or is that a typo? Thanks, -Ryan This manual page explains: http://uk.php.net/manual/en/language.variables.variable.php HTH, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with arrays
Elliot J. Balanza wrote: I need to make a query to a MySQL database that only has two fields, name & value. That I can do. Then I need to store the values i receive in an array in the form of: $variable['name'] = value; But haven't been able to do it neither with a foreach nor with a do while... Can anyone please assist me? If you mean how do you store all the returned results in an array of name/value pairs, this is how I'd do it: while ($result = mysql_fetch_assoc($query)) { $variable[$result['name']] = $result['value']; } ?> Don't know what 'value' represents, but it will give you an array something like this: print_r($variable); Array ( [michael] => nolan [joe] => bloggs [john] => smith ) HTH, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Printing landscape
Luis Mirabal wrote: actually, you can control your printer, look: http://www.php.net/manual/en/function.printer-set-option.php you have to do: $handle = printer_open(); printer_set_option ($handle, PRINTER_ORIENTATION , PRINTER_ORIENTATION_LANDSCAPE); printer_close($handle); you've got many interesting options with this function. ( These functions are only available under Windows 9.x, ME, NT4 and 2000. They have been added in PHP 4.0.4.) As one of the comments rightly says: "Should be pretty obvious, but in case there is any confusion... The printer in question is one that is connected to the _server_, not the _client_." Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: simple image manager app?
Gabriel Guzman wrote: On Thursday 01 April 2004 09:41 am, Jeff D. Hamann wrote: I often travel and would like to be able to upload digital photos to my server (either using a simple multiple file upload (one that I can select multiple file using the windows file dialog, or some other method that's idiot proof) and simply save them to my hard disk, or to a mysql database. Is there a simple set of scripts available for that? I've searched the web and only found lots of references to "how to build a huge table with a bunch of browse... buttons to select single files at a time to upload images in an array which doesn't seem like a meaningful solution. I haven't been able to figure out how to allow multiple selects in the windows file dialog box either. Is that possble using php and the html forms? check out gallery: http://gallery.menalto.com/ it is pretty easy to setup, and works very well, and is very easy to use. gabe. That still doesn't allow what Jeff wants to do! HTML file upload forms only allow you to select one file at a time. Some software (such as Gallery) allows you to upload a zip file containing multiple images. Gallery also allows you to connect with the very useful Gallery Remote, which does allow you to upload multiple files at once. HTH, Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php