RE: [PHP] read only?
Is there a simple php way to make a webpage read-only, please? Webpages are already read only. Well, read only in the browser. There is nothing to prevent the user from saving the page and altering to their hearts content. Did you mean to ask if there was a simple way to make a *form* read only? If so, you can simply add the 'readonly' attribute to the form elements (although, that won't work with select boxes, radio buttons or checkboxes, I believe). Also, you can look into PEAR's QuickForm; it has a Freeze Form and Freeze Element feature. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] keeping fields moving forward
Is there a way to get the data from page one without letting the users modify the information. I guess I could write the data to the database Or you could store the data in the session space... thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Generating executable code
Currently, I have an XML file that I load in, parse manually and iterate through the nodes to create objects, etc, using the node values as parameters. This works all well and fine but is a little resource intensive. Now, I can create a XSL template to transform the XML file and output all the PHP code that we are doing manually. However, when the transformation occurs, the result is pretty much just a string as far as PHP is concerned; it isn't executable PHP code. I know I can output the result to a temporary file then include it or I can pass the result to eval() to execute the code, but neither is ideal. Is there another way I can do what I need? Is there a way to 'include' (for the lack of a better term) the result of the XSL transformation such that PHP processes it as it would any other source code? thnx, Chris
RE: [PHP] Which PHP-Editor to use?
I have worked now for several years happily with homesite 4.5, but now it looks like I have to switch to another system as homesite will not run without admin rights on a XP machine. What editors do you use? I used Homesite for the longest time until I was introduced to Visual Slick Edit. It really is an amazing IDE and I've been using it for the last 3 - 4 years. http://www.slickedit.com/content/view/73/60/ thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Pirate PHP books online?
Some light humour: http://www.unm.edu/~humanism/socvsjes.htm I usually find your humour postings pretty funny but didnt find that in the least bit funny... :( Can't please everyone all of the time. Maybe you didn't get the joke :B Certainly it had be ROFLMFAO. Holy crap, that was funny! It reminded me a lot of The Euthyphro. :) thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Array difficulty
At this point, $result would be equal to uppercase. I feel like this is a really kludgey way to accomplish this. Is there a better way? Couldn't you just do arsort($chance); $lastItem = chance[( count( $chance ) - 1 )]; ? Why iterate through the array when all you need is the last value? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array difficulty
At this point, $result would be equal to uppercase. I feel like this is a really kludgey way to accomplish this. Is there a better way? Not tested it, but max() should work as the first parameter can be an array: http://uk3.php.net/max Except he's looking for the key and not the value, which max() would return. Come to think of it, the solution I provided does the same thing. Untested but one of the below should work: arsort($chance); $lastItem = key( $chance[( count( $chance ) - 1 )]); OR arsort($chance); $lastItem = key( end( $chance )); thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Array difficulty
Couldn't you just do arsort($chance); $lastItem = chance[( count( $chance ) - 1 )]; $lastItem = end( $chance ); end() returns the value as well. You would also need to use key(). thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] About One To Many MYSQL TO XML WITH PHP
Do you know any website that might explain how to convert joined multiple tables(with every rows) to XML? If you use PEAR (or even if you don't), you might want to take a look at the following packages: http://pear.php.net/package/Structures_DataGrid_Renderer_XML http://pear.php.net/package/XML_Query2XML Particularly that last one. Thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Pirate PHP books online?
The idea of even offering an electronic version should be to drive sales for the hard copy. Maybe offer a Condensed Version electronically, that has enough content that readers can get enough of a feel for the product to drive a buying decision. Throughout, make reference to the full version having more complete content, complete with an order now link. This method worked well for Readers Digest! Or watermark the .pdf with something that uniquely identifies each copy - this could be done with a script at the time of the order. Maybe the name of the original buyer, or the order number, etc. Doesn't prevent the piracy, but does give traceability should you wish to pursue the pirate. Didn't/doesn't the PHP Architect magazine do this? Or am I mis-remembering? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How would i construct a date from year/week?
How on earth would I do this? How can I construct a date only given a year and a week number? I hope you guys can help me here, as I have absolutely NO idea :) // whatever week number you are working with; arbitrary value here $weekNumber = 37; // seconds * minutes * hours; $day = 60 * 60 * 24; // days in a week $week = 7; // get the unix time for Jan 1 of this year $firstDayOfThisYear = mktime( 0, 0, 0, 1, 1, date( 'Y' )); // calculate the unix time for the date of the week number $weekNumberDate = $firstDayOfYear + ( $weekNumber * day * week ); // This will put you X weeks out of the day that Jan 1 fell on. // If Jan 1 was on a Thursday, this date should also be on a Thursday. // Using date( 'N', $weekNumberDate ), you can find out how many days // you need to subtract to get your Monday date echo date( 'm/d/Y', $weekNumberDate ); thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
while( TRUE ) { $actions++; $words--; } $bets = array(1,2,3,4,5); unset( $bets ); $arr = array( 'this', 'that', 'times' ); $arr[] = 'behind'; for( $i = 0; $i = 6; $i++ ) { $deep++; } for( $i = 0; $i = 5; $i++ ) { $flies--; } thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
Actions speak louder than words. Yup. All bets are off. Indeed. Behind the times. Correct. Deep Six. Got it. for( $i = 0; $i = 5; $i++ ) { $flies--; } Time flies backwards? // Not sure on this one. I wasn't sure if this one was done well enough; I guess it wasn't. The answer is 'Dropping like flies'. :p thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database administration framework
I just need a framework for administrating tables in a database. These are simple add/edit/remove operations from tables. Can you suggest a framework for this kind of job? Cause there are a lot of tables and I hope I can find a nice tool to work with. What database are you working with? phpMyAdmin is probably the most ubiquitous when working with MySQL databases. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Force zero numbers on a integer
I have a integer that is submitted by the user and i need it to always contain 5 digits. If the user submitted 45, i need it to be 00045. If the user submitted 4595, i need it to be 04595. How can i do this? Check out printf(); http://us.php.net/manual/en/function.printf.php thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Edinburgh, Scotland: PHP Developer Position
PS free milk and cookies and an afternoon nap actually sounds quite good now I come to think about it.. :p Almost better than healthcare and retirement benefits... :) thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] subtracting time from date and time
Something like this will get it into a time stamp...and then you can do your calculations with ease, and reformat... ?php $str = 20070617T193500; list($date, $time) = explode(T,$str); ? Even easier: $timestamp = strtotime( $str ); http://us2.php.net/manual/en/function.strtotime.php $oneMinute = 60; // seconds $oneHour= $oneMinute * 60; $oneDay = $oneHour * 24; echo '5 minutes ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneMinute * 5 )); echo '5 hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour * 5 )); echo '5 days ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneDay * 5 )); etc., etc., etc. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] subtracting time from date and time
This works great tell you get to 8 hours ago it shows the correct time but it does not change the date to the day before. 8 hours ago should be 06/16/2007 11:35:00 but what it shows is 06/17/2007 11:35:00 Your code works for me. Though, I had to change the format of $str slightly to get it to work on a windows box. Additionally, I tried the following (which also worked): ? $str = 2007-06-17T19:35:00; $timestamp = strtotime( $str ); $oneMinute = 60; // seconds $oneHour = $oneMinute * 60; $oneDay= $oneHour * 24; for( $i = 1; $i = 24; $i++ ) { echo $i . ' hours ago: ' . date( 'm/d/Y h:i:s', $timestamp - ( $oneHour * $i )) . 'br'; } ? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Faulting module php4ts.dll
We are running PHP 4.3.11 in a Windows Server 2003 environment using ApacheSSL v1.3. Starting just the other day, we starting seeing the following error pop up in the windows eventvwr: Faulting application Apache.exe, version 0.0.0.0, faulting module php4ts.dll, version 4.3.11.11, fault address 0x000c3d28. I've been searching Google all day and haven't been able to come up with a definitive cause (or even better, a solution) as to why this might be occuring. Has anyone else experienced anything like this? If so, were you able to fix it? If so, how? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] filesize() and mime_content_type()
Is there anything special you need to do to utilize these functions? The former says it's available in versions 4 and 5 while the latter states that it's available in versions = 4.3 and 5 (although is deprecated). I'm currently running PHP version 4.3.11 on a Windows NT box. Based on both those pieces of information, it seems like I should be able to make use of these 2 functions. However, whenever I run the script I wrote doing so, I get the errors Fatal error: Call to undefined function: mime_content_type() and Fatal error: Call to undefined function: filesize() Why? They are both internal PHP functions and are both available (or should be available) in the version of PHP that I am running. What's going on? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filesize() and mime_content_type()
Sounds like a problem with the installation. What could go wrong with an installation on a Windows machine that uses the binaries? Why would it be only these functions (that I can tell) that would be missing? Is there somewhere I can go and check (possibly using phpinfo()) to find out if these functions should be available? basename() works, dirname() works, filetype() works... all functions seemingly similar enough to, at least in my mind, filesize() such that I would think that if filesize() is undefined then those other functions would be undefined too. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filesize() and mime_content_type()
Sounds like a problem with the installation. What could go wrong with an installation on a Windows machine that uses the binaries? Why would it be only these functions (that I can tell) that would be missing? Is there somewhere I can go and check (possibly using phpinfo()) to find out if these functions should be available? However, speaking of deprecated, the mime_content_type() function is deprecated itself. It's replaced by the PECL extension Fileinfo. Yes, I saw that in the online docs. Unfortunately, we don't have PECL installed nor could I get it installed any time soon... thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filesize() and mime_content_type()
Oh, I also forgot to ask what do you get when you use stat()? stat() works, but not if I pass in the actual name of the file. I have to use fstat() in order to get the proper data. I'll have to check to see if there are any functions disabled in the php.ini (I don't believe there are any) but if fstat()/stat() work, I'm at a loss to explain why filesize() doesn't... :| or, also, why stat() doesn't work when I use a correct filename. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filesize() and mime_content_type()
Have you uncommented or added `extension=php_mime_magic.dll` in your php.ini file for mime_content_type()? What about adding something like this, as well: extension=php_mime_magic.dll is commented out in my php.ini. So that explains why the mime_content_type() isn't working. That's fine. Is this DLL also responsible for filesize()? Do you have anything in the `disable_functions =` area of your php.ini? No, there are no disabled functions definined in my php.ini. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file_get_contents
Does file_get_contents() not work with absolute paths? I'm able to successfully write data to a file that I create dynamically but when I go back to actually read the contents of the file, nothing seems to work. Not file_get_contents(), not file(), not fread() and not fgets(); $mydata = 'joebobbriggs'; $filename = 'c:\\temp\\my_file_name.txt'; $resource = fopen( $filename, 'w+' ); fwrite( $resource, $mydata ); fclose( $resource ); echo 'File data: ' . file_get_contents( $filename ); Nothing gets displayed but I see that the file was created and that it has the data I defined. What's going on? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents
What's going on? That's the strangest absolute path I've ever seen... it seems to have some kind of non-absolute prefix. This has been a troll :) Pardon? I'm not sure what you mean? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Return or not to return, that is the question
If there is no need to return a value then I don't do so. However, the function is going to process something, and surely you should check that the processing has succeeded or failed? This is precisely the point I was going to make. Unless an argument is passed in by reference for manipulation within the function, I can't think of a reason why you wouldn't want to return a value; true or false at the very least. You call a function to perform, well, a function. I would think that you would want to know whether or not the process within the function was successful, yes? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to eject cd-rom with php code?
I am writing a script and need to eject the cd-rom drive at some point. Does anyone have an idea how to do this? This is a simple command isn't it? I greatly appreciate your help ?php system( 'eject [-dfnpq] [device | nickname]' ); ? http://us.php.net/manual/en/function.system.php http://bama.ua.edu/cgi-bin/man-cgi?eject+1 thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with mssql_query()
I noticed the following in my logs: 22:04:42 [warning] [D:\PHP\pear\DB\mssql.php][439]: mssql_query(): Unable to set query 22:04:42 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][439]; function( mssql_query ); args( 1[value:select @@ERROR as ErrorCode] 2[value:Resource id #21] ) 22:04:42 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][489]; function( errornative ) 22:04:42 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][145]; function( mssqlraiseerror ) 22:04:42 [info] Backtrace: [D:\PHP\pear\DB\common.php][1146]; function( simplequery ); args( 1[value:SELECT * FROM wording WHERE wording_id = '8' ] ) 22:04:42 [critical] Error in the following query:brbrSELECT * FROM wording WHERE wording_id = '8' brDB Error: unknown error 22:04:52 [warning] [D:\PHP\pear\DB\mssql.php][439]: mssql_query(): Unable to set query 22:04:52 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][439]; function( mssql_query ); args( 1[value:select @@ERROR as ErrorCode] 2[value:Resource id #21] ) 22:04:52 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][489]; function( errornative ) 22:04:52 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][145]; function( mssqlraiseerror ) 22:04:52 [info] Backtrace: [D:\PHP\pear\DB\common.php][1146]; function( simplequery ); args( 1[value:SELECT * FROM wording WHERE wording_id = '8' ] ) 22:04:52 [critical] Error in the following query:brbrSELECT * FROM wording WHERE wording_id = '8' brDB Error: unknown error Why is mssql_query() saying that it's unable to set the query? I did some searching on Google and found that people were having this problem but that was back in 2001 using an earlier version of PHP. We are using version 4.3.11 and Microsoft SQL Server 2000 - 8.00.2039 (Intel X86). Has anyone had a similar problem? What was your solution? Why is this happening? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with mssql_query()
We use PEAR's DB class as our abstration layer. Here is the connection function from DB\mssql.php: function connect($dsninfo, $persistent = false) { if (!DB::assertExtension('mssql') !DB::assertExtension('sybase') !DB::assertExtension('sybase_ct')) { return $this-raiseError(DB_ERROR_EXTENSION_NOT_FOUND); } $this-dsn = $dsninfo; $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost'; $dbhost .= $dsninfo['port'] ? ',' . $dsninfo['port'] : ''; $connect_function = $persistent ? 'mssql_pconnect' : 'mssql_connect'; if ($dbhost $dsninfo['username'] $dsninfo['password']) { $conn = @$connect_function($dbhost, $dsninfo['username'], $dsninfo['password']); } elseif ($dbhost $dsninfo['username']) { $conn = @$connect_function($dbhost, $dsninfo['username']); } else { $conn = @$connect_function($dbhost); } if (!$conn) { return $this-raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, @mssql_get_last_message()); } if ($dsninfo['database']) { if ([EMAIL PROTECTED]($dsninfo['database'], $conn)) { return $this-raiseError(DB_ERROR_NODBSELECTED, null, null, null, @mssql_get_last_message()); } $this-_db = $dsninfo['database']; } $this-connection = $conn; return DB_OK; } We use the DSN: mssql://UID:[EMAIL PROTECTED]/db_name. We are not using persistent connections. thnx, Chris From: Dan Shirah [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 09, 2007 11:07 AM To: Chris Boget Cc: PHP General Subject: Re: [PHP] Problem with mssql_query() Post your block of code from your connection string (Leave out your username/password info please) to the end of the result set for your query so I can take a look at it. On 5/9/07, Chris Boget [EMAIL PROTECTED] wrote: I noticed the following in my logs: 22:04:42 [warning] [D:\PHP\pear\DB\mssql.php][439]: mssql_query(): Unable to set query 22:04:42 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][439]; function( mssql_query ); args( 1[value:select @@ERROR as ErrorCode] 2[value:Resource id #21] ) 22:04:42 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][489]; function( errornative ) 22:04:42 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][145]; function( mssqlraiseerror ) 22:04:42 [info] Backtrace: [D:\PHP\pear\DB\common.php][1146]; function( simplequery ); args( 1[value:SELECT * FROM wording WHERE wording_id = '8' ] ) 22:04:42 [critical] Error in the following query:brbrSELECT * FROM wording WHERE wording_id = '8' brDB Error: unknown error 22:04:52 [warning] [D:\PHP\pear\DB\mssql.php][439]: mssql_query(): Unable to set query 22:04:52 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][439]; function( mssql_query ); args( 1[value:select @@ERROR as ErrorCode] 2[value:Resource id #21] ) 22:04:52 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][489]; function( errornative ) 22:04:52 [info] Backtrace: [D:\PHP\pear\DB\mssql.php][145]; function( mssqlraiseerror ) 22:04:52 [info] Backtrace: [D:\PHP\pear\DB\common.php][1146]; function( simplequery ); args( 1[value:SELECT * FROM wording WHERE wording_id = '8' ] ) 22:04:52 [critical] Error in the following query:brbrSELECT * FROM wording WHERE wording_id = '8' brDB Error: unknown error Why is mssql_query() saying that it's unable to set the query? I did some searching on Google and found that people were having this problem but that was back in 2001 using an earlier version of PHP. We are using version 4.3.11 and Microsoft SQL Server 2000 - 8.00.2039 (Intel X86). Has anyone had a similar problem? What was your solution? Why is this happening? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHPInfo data
In looking at the PHPInfo data on our two seperate servers, I see that one server (server 1) has the following settings (while the other one, server 2, does not): Apache Environment downgrade-1_0 force-response-1_0 Environment BMC_GLOBALC_HOME PATROL_GC_VERSION PATROL_HOME PATROL_TEMP RTSERVERS TARGET Server 2 has the following settings (while the other one, server 1, does not): Apache Environment SSL_CIPHER SSL_CIPHER_ALGKEYSIZE SSL_CIPHER_EXPORT SSL_CIPHER_USEKEYSIZE SSL_CLIENT_VERIFY SSL_PROTOCOL SSL_SERVER_A_KEY SSL_SERVER_A_SIG SSL_SERVER_I_DN SSL_SERVER_I_DN_C SSL_SERVER_I_DN_CN SSL_SERVER_I_DN_Email SSL_SERVER_I_DN_L SSL_SERVER_I_DN_O SSL_SERVER_I_DN_OU SSL_SERVER_I_DN_ST SSL_SERVER_M_SERIAL SSL_SERVER_M_VERSION SSL_SERVER_S_DN SSL_SERVER_S_DN_CN SSL_SERVER_S_DN_O SSL_SERVER_S_DN_OU SSL_SERVER_V_END SSL_SERVER_V_START SSL_SESSION_ID SSL_VERSION_INTERFACE mod_ssl/2.8.25 SSL_VERSION_LIBRARY OpenSSL/0.9.8a HTTP Headers Information Transfer-Encoding chunked I've looked in the php.ini and httpd.conf and I don't see the settings in either. I ran windows search to find files with any of the text within and nothing was returned. Where can I find where these settings are defined and ensure that both servers are showing the same thing in PHPInfo? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sorting multi array
I have the following array, which I need to sort by quantity... I need to keep the indexes if poss. This may not be the most elegant solution. Let's call your array $origArray $tmpArray = array(); foreach( $origArray as $elKey = $elArray ) { $tmpArray[$elArray['quantity']] = $elKey; } if( ksort( $tmpArray )) { $sortedArray = array(); foreach( $tmpArray as $elKey ) { $sortedArray[$elKey] = $origArray[$elKey]; } echo 'Original: pre' . print_r( $origArray, TRUE ) '/prebr'; echo 'Sorted: pre' . print_r( $sortedArray, TRUE ) '/pre'; } else { echo 'Sorry, couldn\'t sort'; } thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sorting multi array
this won't work if he has the same quantity for several keys, I think Yes, you are correct. If that is the case, then you would just need to change the following line $tmpArray[$elArray['quantity']] = $elKey; to $tmpArray[$elArray['quantity']][] = $elKey; then change logic in this loop: foreach( $tmpArray as $elKey ) { to handle the additional array. If additional sorting needs to occur for those keys that have the same quantity then I think recursion will be in order. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Json.php
So only one of these is kosher static: return Services_JSON::decode($data); class: $json = new Services_JSON; return $json-decode($data); but not both. I'm not trying to start (or further add fuel to) any kind of war but instead an earnest question: why not both? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Outlook task via email
I've done some searching on Google but haven't been able to come up with anything helpful. Has anyone on the list done any work on sending an Outlook Task as part of an email? Or does anyone know of a good resource that shows how this can be done? I'm going to be using PHP's mail() to actually send and I'm familiar with attaching files to such emails but I'm just not sure how a task can be attached. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Parsing database variables
But this is a much better way of doing this than using eval(). eval is an evil little function! eval() isn't so bad if you have absolute, total and complete control over the data you are pulling or using. But once someone else becomes involved (particularly the front end user), you are probably better off looking at alternatives. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Timezone offset
On 3/28/07, Chris Boget [EMAIL PROTECTED] wrote: My server's timezone is set to (GMT) Greenwish Mean Time : Dublin, Edinburgh, Lisbon, London. But when I echo out date( 'O' ), it's returning the offset as +0100 and not +. Why? I would think that it should return +. Am I wrong? What about DST? Hmm, I didn't think the UK observed DST already. When did that happen? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Timezone offset
My server's timezone is set to (GMT) Greenwish Mean Time : Dublin, Edinburgh, Lisbon, London. But when I echo out date( 'O' ), it's returning the offset as +0100 and not +. Why? I would think that it should return +. Am I wrong? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Capitalizing the first letter
I would like to write a filter that takes the text smith or SMith and returns Smith; same for ralph smith. Is the a good source on using filters this way? It may not be the most efficient way of accomplishing this, but you could do something like: $string = 'SMith' $fixedString = ucwords( strtolower( $string )); thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular Expression help
?php echo 'Is String: [' . ( is_string( 'a1b2c3' ) preg_match( '/[A-Za-z]+/', 'a1b2c3' )) . ']br'; echo 'Is Numeric: [' . ( is_numeric( 'a1b2c3' ) preg_match( '/[0-9]+/', 'a1b2c3' )) . ']br'; echo 'Is String: [' . ( is_string( 'abcdef' ) preg_match( '/[A-Za-z]+/', 'abcdef' )) . ']br'; echo 'Is Numeric: [' . ( is_numeric( '123456' ) preg_match( '/[0-9]+/', '123456' )) . ']br'; ? Why is the first Is String check returning true/showing 1? preg_match should fail because 'a1b2c3' contains numbers and, as such, doesn't match the pattern... What am I doing wrong? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Converting array keys to variables?
Is there a way that I can simply loop through each array and convert the keys into variables? I want to avoid having to write lines of: Look into extract(). http://us3.php.net/manual/en/function.extract.php thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Join table with clashing fieldnames
I have an SQL query which has a simple join, this works and is fine the fields from the secondary table are added to the returned array. But what happens if I add another JOIN to a table which has fields which are the same name? Is there any way to have PHP prefix the key's (fieldnames) of the joined fields? You'll need to create an alias for the conflicting fields. SELECT Table1.ConflictingField AS Table1_ConflictingField, Table2.ConflictingField AS Table2_ConflictingField FROM Table1 INNER JOIN Table2 ON Table2.FK = Table2.PK Or something like that. Just doing SELECT * isn't best practice[1]. thnx, Chris [1] Though I'm terribly guilty of doing that way more often than I should be... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to Display a page while script runs?
I have a php script which takes maybe 15-20 seconds to run, however until it completes a blank web page is displayed to the user. Is there a way/method which would enable me to give some feedback to the user while the script is running so the blank page is not displayed? You could look into flush(); thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run script every 30 seconds
I have a script that I want it to run every 30 seconds, the problem is that cronjob can run every 1 minute only, do you have any solution ? Set the script up as a 2 iteration loop with sleep( 30 ) at the end of the first iteration. Or something like that... thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Job postings?
This is a general etiquette question. I have a job posting for a junior PHP programmer. Are there any of the PHP mailing lists to which it would be appropriate to post that? If not, can anyone recommend a good place to post, especially a place that might be read by many people with specifically PHP skills? This is exactly what you are looking for: http://finance.groups.yahoo.com/group/phpjobs thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach on a 3d array
$languages = array( af = array(Afrikaans, Afrikaans, South Africa), sq = array(Albanian, Shqipe, Albania)); foreach ($languages as $language){ if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) { printcenterYou are from .$language[2].!/center; } } What you want is something like this: foreach ($languages as $language = $valueArray ){ if ( strstr( $_HTTP_ACCEPT_LANGUAGE, $language) ) { printcenterYou are from .$valueArray[2].!/center; } } Your example is setting the variable $language to the array for each iteration. So the first iteration, $language is set to array(Afrikaans, Afrikaans, South Africa) and the second iteration, $language is set to array(Albanian, Shqipe, Albania) thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Text from Excel csv file loaded into MySQL table
Can anyone point me to a really good end to end tutorial on extracting text from an Excel csv file and uploading it into MySQL via a PHP script? Actually, depending on the integrity of the data and the consistency of the format in the CSV file, you can do this simply and easily using just MySQL. Take a look at the following pages: MySQL = 5.0 http://dev.mysql.com/doc/refman/5.0/en/load-data.html MySQL 5.0 http://dev.mysql.com/doc/refman/4.1/en/load-data.html thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach
$last = end ( $numbers ); reset ( $numbers ); I thought foreach() already performed a reset()? Why do it again here? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array size in bytes
How about saving the array as a file and then do a filesize()? Wouldn't this work? $arraySize = strlen( implode( '', $array )); Though, additional work would need to be done for nested arrays. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 object construct
ok, so if we were talking Java, perhaps you are looking for information that allows you to build 'accessor' and 'mutator' methods? If so, then your example should work (syntax aside). Here's another 'test' example that I just whipped up and tested that shows you can use any method name you wish. As I said previously, accessor/mutator methods are exactly what I am looking for. I do like the idea of having a public 'interface' (for the lack of a better word) to a private property. I don't particularly care for using just the __set() and __get() methods because they are too arbitrary. If I needed to do any specific checking or formatting for a property, either in defining or returning the value, I'd have to have a big giant switch() statement. So here is a roundabout solution that I got the idea/code for while researching this issue: class MyClass { private $_bob; // Private so all property access is done through the // __set() and __get() methods private function setBob( $bob ) { $this-_bob = $bob; } private function getBob() { return $this-_bob; } function __get( $var ) { $methodName = 'get' . $var; if( method_exists( $this, $methodName )) { return call_user_func( array( $this, $methodName )); } else { throw new Exception( 'Method [' . $methodName . '] does not exist' ); } //echo In __get( $var )\n; } function __set( $key, $var ) { $methodName = 'set' . $key; if( method_exists( $this, $methodName )) { call_user_func( array( $this, $methodName ), $var ); } else { throw new Exception( 'Method [' . $methodName . '] does not exist' ); } //echo In __set( $key, $var )\n; } function __call( $method, $args ) { //echo 'Calling [' . $method . '] with args: [' . print_r( $args, TRUE ) . ']'; } } try { $myClass = new MyClass(); $myClass-Bob = 'JoeBobBriggs' ; echo '$myClass: pre' . print_r( $myClass, TRUE ) . '/pre'; echo $myClass-Bob . ''; } catch( Exception $e ) { echo 'Caught exception: ', $e-getMessage(), \n; } Now I can do whatever checking I need to do in the setBob() method and any formatting in the getBob() method. The above is not my original idea and I wish I could remember the name of the person to thank for pointing me in this direction. :| thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 object construct
I read about a feature of PHP5 OOP that is something like this in a book or a magazine a while back. But now I don't remember exactly how this works and I can't find any reference to it in the online docs. The basic idea is something along these lines: class MyClass { private $bob; public $Bob { set( $var ) { $this-bob = $var; } get() { return $this-bob; } } } Could someone point me to the relevant section of the docs that discusses this? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 object construct
I read about a feature of PHP5 OOP that is something like this in a book or a magazine a while back. But now I don't remember exactly how this works and I can't find any reference to it in the online docs. The basic idea is something along these lines: class MyClass { private $bob; public $Bob { set( $var ) { $this-bob = $var; } get() { return $this-bob; } } } Could someone point me to the relevant section of the docs that discusses this? http://us2.php.net/class Any particular place on that page I should be looking? I've read it several times and didn't see anything like the above. The closest thing I saw were actual methods called setBob() and getBob(), which isn't exactly what I'm looking for... thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 object construct
Any particular place on that page I should be looking? I've read it several times and didn't see anything like the above. The closest thing I saw were actual methods called setBob() and getBob(), which isn't exactly what I'm looking for... Check here: http://us2.php.net/manual/en/language.oop5.magic.php So the only way I can do anything like this is by implementing the __get() and __set() methods? There is no attribute/property construct that is similar to the sample code in my OP? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] PHP5 object construct
well, perhaps I'm not seeing what it is that you're looking for. No, I'm not sure you are. Take a look at my sample code again. Pay particular attention to how both $bob and $Bob are defined. class MyClass { private $bob; public $Bob { set( $var ) { $this-bob = $var; } get() { return $this-bob; } } } thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 object construct
ok, so if we were talking Java, perhaps you are looking for information that allows you to build 'accessor' and 'mutator' methods? Yes, exactly. I was flipping through a PHP5 book (possibly a magazine, but it was definitely about PHP5 and not Java) and I saw this new language construct. Since I've done a bit of dabbling in C#, have used it there and found it useful, I thought it was really cool that PHP5 had implemented it. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] PHP5 object construct
PHP has __set and __get in some versions... I think that's what you are looking for. Yes, but exactly. They'll do if there is no other way (as below)... If you told us which particular feature in that pile of code you're asking about, it would help... the ability to set an accessor like such: public $Bob { set( $var ) { $this-bob = $var; } get() { return $this-bob; } } thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is there a list of all Timezones as an array or someting?
I need to have a selectbox filled with the available timezones of PHP. We are using v5.1.x, and it supports the date_default_timezone_set() etc.. As value you can give a string to what timezone. I want all these strings within an array or something so i can create a selectbox so users can select it. Thx in advance. Here's the array we've been using: $timeZonesArray = array( 'GMT'= array( 'GMT' = +0 // GMT ), 'North America' = array( 'NST' = -3.5, // Newfoundland Standard Time 'NDT' = -2.5, // Newfoundland Daylight Time 'AST' = -4, // Atlantic Standard Time 'ADT' = -3, // Atlantic Daylight Time 'EST' = -5, // Eastern Standard Time 'EDT' = -4, // Eastern Daylight Time 'CST' = -6, // Central Standard Time 'CDT' = -5, // Central Daylight Time 'MST' = -7, // Central Daylight Time 'MDT' = -6, // Mountain Daylight Time 'PST' = -8, // Pacific Standard Time 'PDT' = -7, // Pacific Daylight Time 'AKST' = -9, // Alaska Standard Time 'AKDT' = -8, // Alaska Daylight Time 'HAST' = -10, // Hawaii-Aleutian Standard Time 'HADT' = -9 // Hawaii-Aleutian Daylight Time ), 'Australia' = array( 'NFT' = +11.5, // Norfolk (Island) Time 'EST' = +10, // Eastern Standard Time 'EDT' = +11, // Eastern Daylight Time 'CST' = +9.5, // Central Standard Time 'CDT' = +10.5, // Central Daylight Time 'WST' = +8, // Western Standard Time 'CXT' = +7, // Christmas Island Time ), 'Europe' = array( 'GMT' = +0, // Greenwich Mean Time 'BST' = +1, // British Summer Time 'IST' = +1, // Irish Summer Time 'WET' = +0, // Western European Time 'WEST' = +1, // Western European Summer Time 'CET' = +1, // Central European Time 'CEST' = +2, // Central European Summer Time 'EET' = +2, // Eastern European Time 'EEST' = +3 // Eastern European Summer Time ), 'Military' = array( 'Z' = +0, // Zulu Time Zone 'Y' = -12, // Yankee Time Zone 'X' = -11, // X-ray Time Zone 'W' = -10, // Whiskey Time Zone 'V' = -9, // Victor Time Zone 'U' = -8, // Uniform Time Zone 'T' = -7, // Tango Time Zone 'S' = -6, // Sierra Time Zone 'R' = -5, // Romeo Time Zone 'Q' = -4, // Quebec Time Zone 'P' = -3, // Papa Time Zone 'O' = -2, // Oscar Time Zone 'N'
[PHP] DOM: Problem with loadXML(), createProcessingInstruction()
Apparently, loadXML() overwrites the existing structure of the document when called. The problem is that when I try to add a PI (namely a stylesheet), it adds it to the end of the document thus making so that the XML is not transformed by the client. To get around this, I thought I could just import my XML string into a DOMNode, but I do not see any method for that class analogous to the loadXML(). I looked at the possiblity of adding children to the document at specific positions (such that I could add the PI as the first child) but I do not see a DOMDocument method that allows it. appendChild() merely adds the child to the end of the document. Has anyone found a workaround for this; a workaround the fact that loadXML() completely replaces the existing document structure? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [Solved] Re: [PHP] DOM: Problem with loadXML(), createProcessingInstruction()
Has anyone found a workaround for this; a workaround the fact that loadXML() completely replaces the existing document structure? It's amazing what you find out after you've already made yourself look foolish. $xmlStr = 'rootchild_elementblah/child_element/root'; $doc = new DOMDocument( '1.0', 'UTF-8' ); $docFragment = $doc-createDocumentFragment(); $docFragment-appendXML( $xmlStr ); // Why this isn't called also loadXML() // I have no idea. It would make sense // that it would be so as to maintain // consistency in names of methods // where it relates to functionality, // particularly when that functionality is // similar across classes. $doc-appendChild( $doc-createProcessingInstruction( 'blah', 'blah' ); $doc-appendChild( $docFragment ); echo $doc-saveXML(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
Would it be possible to point to the relevant page in the documentation that discusses how to do this? If there is nothing builtin to do it, how tricky could it be to strip off the first line after you saved it?... Not tricky at all. Crude, but effective, Captain -- Spock Exactly. I was just hoping for something a bit more elegant. Hopefully using something that was built in to DOMDocument. Oh, well. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
Perhaps you missed my reply. If you pass the root node then you get the entire document without the XML declaration. That's both elegant and built-in. I didn't miss it. But you have to pass in the root DomNode object. The only way to get it is by doing the following: $nodeList = $doc-getElementsByTagname( 'RootTagName' ); echo $doc-saveXML( $nodeList-item( 0 )); So unless your root node has an ID, that seems pretty excessive. Now you have the wasted resources that $nodeList is using. While it is crude, I believe it is both faster and less resource intensive to just do: echo str_replace( '?xml version=1.0?', '', $doc-saveXML()); It would be really nice if you could also specify a string value -- the name of the root node. I do appreciate the time and effort in reply to my post. It forced me to relook at the method and to look into DomNode and DomNodeList. :) thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
Why? documentElement property works just fine and is much more flexible. Where can you find a list of properties for the object? I don't see anything like this in the documentation. Doing a search: http://us3.php.net/manual-lookup.php?pattern=DOMDocumentlang=en only returns the methods. Clicking on any one of the methods gives you a list of all the other methods (along with associated objects) in the right hand navigation menu but it doesn't have anything about the properties. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOMDocument-saveXML()
Click on one of th edom methods... when you get to the details page for that method, see the left navigation menu, at the very top is a link to the class details which contains information about the properties: http://us3.php.net/manual/en/ref.dom.php Excellent. Thank you very much! :) thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DOMDocument-saveXML()
I looked all through the documentation but was unable to find out if this was possible and, if so, how. When you call -saveXML(), it prints out the XML declaration ?xml version=1.0? alont with the structure of the document. Is there any way to suppress that? I'm trying to print out extra text (in the form of a stylesheet call) and the declaration that -saveXML() prints out is messing everything up. Would it be possible to point to the relevant page in the documentation that discusses how to do this? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] function does not exist
I'm getting the following error all throughout my PHP log: [warning] [Unknown][0]: Unknown(): Unable to call () - function does not exist I'm not sure it's going to survive the mailing but it appears to be a tab character after the 'call' and before the '()'. I've spent days (not consecutively) trying to track down this eror but have had absolutely no luck. Has anyone else experienced a problem like this? If so, what was causing it for you and what was your solution? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Documentation of PHP sourcecode
I am looking in some possibilities for automatically documenting my functions and classes. Preferably with some markup in the sourcecode and easy to implement. I am running Linux on my desktop so w* stuff won't do it for me :) Can anyone point me in the right direction? Check out PHPDocumentor. http://www.phpdoc.org/ This is just one package of the many that are out there. A quick search on google will show others. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Setting cookie on one domain for an other domain
However, I can not detect the cookie at domain2.com. You aren't going to be able to nor should you be able to. It's a security feature of the browsers. A solution would be to just make a redirect to the other domain where the cookie is set and then return. That would be one solution. Question is: Can I not set a cookie at domain1.com to work at domain2.com? No, you can't. You could, however, if you were trying to set it for a different sub-domain (eg. subdomain1.domain.com and subdomain2.domain.com). thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] XSLT WYSIWYG?
Perhaps, though, there is some magical PHP WYSIWYG tool out there to compare the HTML and the XML and make an XSLT for me?... It's not PHP based, but XMLSpy will do exactly what you need. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Controlling a scanner with PHP
I also thought it always had to be run under a web server, and would be interested to know what the other options/ opportunities are. You can run it from the command line. See http://us3.php.net/manual/en/features.commandline.php thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Need help with PEAR Quickform
I am busy working on a form using QuickForm. I would like to make use of a confirmation page where the user must eitheir select to change the details or continue. Does anyone know how to achieve this? On POST, you could redisplay the form in a Frozen state. If the form is frozen, you display a separate set of submit buttons and in checking to see if those new buttons were clicked do you actually process the form normally (access data store, etc). This is just one of the many ways you can go about achieving the same results. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delete
On Sun, June 4, 2006 3:11 am, Rabin Vincent wrote: You may find it easier to generate links of the form delete.php?id=1, etc. Then you won't have to use a seperate form for each link. The id will be available in delete.php in $_GET. The same sanity checking applies in this case too. Gah! That violates the HTTP spec for GET versus POST, to start with. How so? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using 'header' as redirect
As you can see, by the time that index.php includes the subpage, it has already outputted HTML. According to using the header() function, you are not allowed to output any HTML *before* using header(). However, I am doing this and it is redirecting fine. You can also always use the old tried and true: META http-equiv=REFRESH content=$lagTime; URL=$redirectPage That should redirect regardless of whether any HTML has already been sent to the browser. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sprintf() oddity
What's going on here: $number = 50.1234567890; echo sprintf( '%.05f', $number ); result: 50.12346 $number = 5.1234567890; echo sprintf( '%.05f', $number ); result: 5.12305 $number = 5000.1234567890; echo sprintf( '%.05f', $number ); result: 5000.0 Why isn't it formatting the decimals properly? And apparently losing some? Running PHP 4.3.11 on Windows Server 2003 box. thnx, Chris
RE: [PHP] interview
can you please send some interview questions for php i have in few days to inteview some people. 1) If I use PHP, and you use PHP, and everyone on this list uses PHP... what colour is my car? Hamburger. Oh, wait... 2) How do I avoid the number 42? Trip over the number 41 and apologize to the number 43. 3) What time is it Eccles? 1:02:03am :p Thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] echo, print and is_callable()/function_exists()
Because both echo and print are language constructs and not actual functions, you can't seem to use either is_callable() or function_exists() on either to determine if they are valid 'function' calls. Is there any other way to determine to check to see if I can execute either or? I'm writing a version of array_walk_recursive() (it doesn't exist in the version of PHP we are using) and if I try to pass in either echo or print as the function, nothing ever happens because neither resolves as an executable function... Any ideas as to how I can get around this? thnx, Chris
[PHP] Argument passed by reference?
Is there a way to test to see if a function argument was passed by reference instead of by value? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Argument passed by reference?
The way I understand it, pass by reference in php is determined in the function definition and not the function call. Something like: You used to be able to pass by reference at run time. But I see that is no longer allowed... :| So I guess that makes my question moot. Thanks for your help. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Going loopy with arrays.....
a. loop through it and recognize when I have com upon a new sub-array so that I can do 'new' output 2. OR get each of the sub-arrays out as individual arrays. This might help get you going in the right direction... script language=php function print_elements( $var ) { if( is_array( $var )) { foreach( $var as $k = $v ) { if( is_array( $v )) { print_elements( $v ); } else { echo $k = $vbr; } } } } $array = array(); $array['H7'][] = array( 'lon' = -99.2588, 'lat' = 29.1918 ); $array['H7'][] = array( 'lon' = -99.2205, 'lat' = 29.1487 ); $array['H7'][] = array( 'lon' = -99.242, 'lat' = 29.1575 ); $array['H7'][] = array( 'lon' = -99.2588, 'lat' = 29.1545 ); $array['H6'][] = array( 'lon' = -99.0876, 'lat' = 29.216 ); $array['H6'][] = array( 'lon' = -99.0618, 'lat' = 29.179 ); array_walk( $array, 'print_elements' ); /script thnx, Chris
[PHP] addslashes()
Can someone explain something to me: script language=php $string = Bob's carwash's door; echo 'addslashes(): ' . addslashes( $string ) . 'br'; echo 'mysql_escape_string(): ' . mysql_escape_string( $string ) . 'br'; /script Outputs: addslashes(): Bob''s carwash''s door mysql_escape_string(): Bob\'s carwash\'s door According to the documentation (http://us2.php.net/manual/en/function.addslashes.php), addslashes() should be doing exactly what mysql_escape_string is doing above (namely, add backslashes in front of each apostrophe). However, it's merely adding an additional apostrophe. Why? I'm running 4.3.11 on Windows NT 5.2 build 3790. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] addslashes()
I totally blew past that part with the sybase because we aren't using sybase. I guess I should have paid more attention. I'm curious why that directive affects general PHP code and not just the sybase functions. Oh, well. Thanks for the heads up. thnx, Chris - Original Message - From: Jasper Bryant-Greene [EMAIL PROTECTED] To: Chris Boget [EMAIL PROTECTED] Cc: PHP General php-general@lists.php.net Sent: Wednesday, March 29, 2006 5:29 PM Subject: Re: [PHP] addslashes() From http://php.net/addslashes : Having the PHP directive magic_quotes_sybase set to on will mean ' is instead escaped with another '. Jasper Chris Boget wrote: Can someone explain something to me: script language=php $string = Bob's carwash's door; echo 'addslashes(): ' . addslashes( $string ) . 'br'; echo 'mysql_escape_string(): ' . mysql_escape_string( $string ) . 'br'; /script Outputs: addslashes(): Bob''s carwash''s door mysql_escape_string(): Bob\'s carwash\'s door According to the documentation (http://us2.php.net/manual/en/function.addslashes.php), addslashes() should be doing exactly what mysql_escape_string is doing above (namely, add backslashes in front of each apostrophe). However, it's merely adding an additional apostrophe. Why? I'm running 4.3.11 on Windows NT 5.2 build 3790. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Where can I find nice Web icons for custom admin interface?
I have a habit of designing pretty much everything myself as far as CMS and admin areas, but I was wondering if anybody knew where to find Web icons to make the result look very professional? I am really not a graphical/layout guy! This is OT but you can always take a look on http://www.deviantart.com/ thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date question
I have a datetime column in MySQL DB. How can I match to that column from php code if I only have the date information available. 2006-02-24 12:00:00 against2006-02-24 This might be more SQL question sorry about that. use date_format(%Y-%m-%d,'date_column') in the sql http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html The above is likely one of the more elegant solutions. But if you wanted to do this completely in PHP, you could do something like: pseudocode $phpDate = '2006-02-24'; $rowData = mysql_fetch_assoc( $yourQuery ); if( date( 'Y-m-d', strtotime( $rowData['MySQLDate'] )) == $phpDate )) { echo 'Dates match!'; } /pseudocode thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static and Global at the same time!
Can I have a variable that is static and global at the same time within a function? Let's say I have: $data = ; function newdata() { static global $data; $data [$i] = $newdatatobestored_inthearray; } Isn't a global variable static within the function by it's nature of being global? Making it so that the static keyword is superfluous? Hmmm... Well, that is, of course, assuming that the function is the only place the variable is ever modified... thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Job opening in UK, London
My company is looking for a PHP developer to work out of their London office. If you live in/around the city and are interested, please respond to me (personally, not the list :p) with your resume/CV. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP][SOLVED] Re: usr VAR value as a VAR Name
echo $$foo Let me start by saying there is nothing wrong with the above and it's doing exactly what the OP needed. However, when I use variable variables, I prefer to use the following notation: ${$foo} It makes the coder's intention clear and makes it so that it can't be mistaken for a possible typo when someone comes in after the fact to maintain the code. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP][SOLVED] Re: usr VAR value as a VAR Name
Let me start by saying there is nothing wrong with the above and it's doing exactly what the OP needed. However, when I use variable variables, I prefer to use the following notation: ${$foo} It makes the coder's intention clear and makes it so that it can't be mistaken for a possible typo when someone comes in after the fact to maintain the code. And When I use this and when i use that. Oh i like this ^_^ Btw. my working buddys said on first view your example looked more wrong. Try it and see. ;) And on top of that, i wont let anyone code in my PHP docs who doesn't know what $$var is or does!! Agreed. But there have been a few times when I accidently added in an extra $ to the variable and, consequently, didn't get the results I expected. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular Expression help
I've been beating my head against the wall for a while trying to come up with the RE I need to use. I have a camel case word - let's use JimJoeBobBriggs. I need to come up with a RE that will fine all the upper case characters and insert an underscore prior to those characters with the exception of a possible first character. So using the aforementioned word, the RE would change it to Jim_Joe_Bob_Briggs. Any help would be greatly appreciated! thnx, Chris
Re: [PHP] The meaning of and @
and it's used wrongly in 99.99% of the cases. Are you trying to tell me that I'm *not* supposed to use it in front of *every* php function Oh, come *on* Why not?!? It makes the function call look so pretty and important/official looking... or something... :p thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Timezone and DST
I've got a little problem where our servers are in PST but the customer operates in Hawaii (-10 GMT). I believe I can just get the time for them by doing something like date(d H i, strtotime('now -2 hours') ); But here's the catch, how should I deal with day light savings ( DST) . In hawaii they don't observer DST, but in Washington State we do. You can use date( 'I' ) to determine whether or not your server is currently in DST and subtract the appropriate number of hours accordingly... thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What software do you use for writing PHP?
Visual Slick Edit works on a Mac. As I've said before (and will undoubtedly say again), it is by far the best IDE I've used to date. Features: http://www.slickedit.com/content/view/353/217 System requirements: http://www.slickedit.com/index.php?option=com_contenttask=viewid=161Itemid=57 thnx, Chris - Original Message - From: Jonathan Duncan [EMAIL PROTECTED] To: Eric Gorr [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Thursday, December 15, 2005 12:31 PM Subject: Re: [PHP] What software do you use for writing PHP? On Tue, 6 Dec 2005, Eric Gorr wrote: Quoting Torgny Bjers [EMAIL PROTECTED]: I recommend Zend Studio if you can afford it since it has a GUI for both Windows and Linux FlameBateAnd for those interested in using a real computer/FlameBate, it's GUI also runs under MacOSX. http://zend.com/store/products/zend-studio/requirements.php Actually, it does not. I installed it on my Mac, hoping to try it out and it would not run because it did not have the move recent Java JRE which is not available for Mac OSX (or was not at the time). I still do not have it running. Although it installed without a hitch. I would be interested in what people use to program PHP on Mac. I currently use TextWrangler and I have tried TextMate, but I am not completely sold on either of them. I use vim quite a bit also. Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] quickly discovered why refresh isn't nice
hello, I just found out why one reason for a meta refresh is a bad idea, it does exactly that, it refreshes the page every 3 or 2 or 0 seconds which basically is constant..so maybe the header idea is better in this case. While this is very true, what is typically the case when you use meta refresh is that you are using it to redirect a user to a subsequent page. In that case, so long as that final page doesn't use meta refresh, it isn't an issue. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What software do you use for writing PHP?
Pt'Edit' in DOS. ;) Absolutely!! It can't be beaten for undocumented features. :p thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What software do you use for writing PHP?
Forever now I've been using Frontpage for all my web work including php. I'm sure there's better software out there that is more suited to writing and editing PHP pages. What do you all use? I use Visual SlickEdit. You should check it out; it's a very powerful IDE. http://www.slickedit.com thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What software do you use for writing PHP?
HomeSite. I tried several others but always came back to HomeSite. :) I was a massive HomeSite proponent until I started using SlickEdit. Once I did, I never looked back. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What software do you use for writing PHP?
I primarily code in Dreamweaver 8. Two of my favorite features that were added from MX are as follows: 1. Code folding, basically you can collapse blocks of code. SlickEdit has this feature. 2. The built in FTP client. This one as well. I used Dreamweaver a while back (admittedly an older version) but I couldn't stand it. But that's IMO. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What software do you use for writing PHP?
When you say SlickEdit has a ftp client built in, is it a separate window that gets launched, or is it more integrated, like you can just right click on your list of files and say put these files up on the server. It's integrated. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDF Generator
What is the best FREE pdf generator for PHP? We use HTMLDoc and it works reasonably well. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using ($test)?$true:$false in a string
and I feel it would be more elegant to be able to do something like: $var =first part of string {(($a==$b)?$c:$d)} rest of string; $templateStr = 'first part of string %s rest of string'; $outputStr = sprintf($templateStr, (($a==$b)?$c:$d)); That is so totally slick! I'm definitely going to have to remember this neat little trick! :) thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regex help
Why isn't this regular expression ^[A-Za-z0-9\.]+\s*[A-Za-z0-9\.]*$ allowing for this value: 'Co. Dublin' (w/o the single quotes) ? It's failing the regular expression match... thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Wierd error
I'm seeing the following line showing up in my logs: 08:08:30 [warning] [Unknown][0]: Unknown(): Unable to call () - function does not exist and I've narrowed it down to this line of code: settype( $dbObject, null ); When I comment out the above line, the error goes away. When I uncomment it out, the error comes back. I've used both single and double quotes, I've tried using different types, I've tried passing the object both by value and by reference but nothing seems to help. What's going on? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php