[PHP] strcmp($var1, $var2) versus if ($var1 $var2)
Hi All, I must be overlooking something here ... $var1 = 01011090; $var2 = 010190; // 2 strings if ($var1 $var2) ECHO var1 var2; else ECHO var1 = var2; echo br /; $r = strcmp ( $var1 , $var2 ); if ($r 0) ECHO var1 var2, br /; 2nd line says: $var1 = $var2 4th line says: $var1 $var2 TIA, Cor
Re: [PHP] strcmp($var1, $var2) versus if ($var1 $var2)
- Original Message - From: David Otton [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] php-general@lists.php.net Sent: Wednesday, May 28, 2008 12:11 PM Subject: Re: [PHP] strcmp($var1, $var2) versus if ($var1 $var2) 2008/5/28 C.R.Vegelin [EMAIL PROTECTED]: $var1 = 01011090; $var2 = 010190; // 2 strings if ($var1 $var2) ECHO var1 var2; else ECHO var1 = var2; echo br /; $r = strcmp ( $var1 , $var2 ); if ($r 0) ECHO var1 var2, br /; 2nd line says: $var1 = $var2 4th line says: $var1 $var2 Implicit type conversion. is a numeric operator, so your strings are silently promoted to integers, where (1011090 10190). strcmp() treats the strings as strings, and orders them in something close to ASCII order (which isn't the same as alphabetical ordering, BTW, and see the comments at www.php.net/strcmp for locale-specific gotchas). PHP's implicit conversions can bite you if you don't understand them. Try this one: $a = 'string'; $b = 0; if ($a==true $b==false $a==$b) { echo ('universe broken'); } Hi David, I already suspected that the operator forced a numeric comparison. Even if I use: if ((string) $var1 (string) $var2) ... So I have to use strcmp() Thanks, Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More than one values returned?
?php $in = 4; calcpows($in, $pow2, $pow4); echo in = $in pow2=$pow2 pow4=$pow4; // define return fields as $... function calcpows($in, $pow2, $pow4) { $pow2 = $in * $in; $pow4 = $pow2 * $pow2; } ? HTH - Original Message - From: Teck [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tuesday, February 19, 2008 1:31 AM Subject: [PHP] More than one values returned? Hi, Is it possible to return more than one values in PHP? return $x; return $y; They don't work for me. -T -- 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] PHP Source code protection
See also: http://www.ioncube.com/ - Original Message - From: Bastien Koert [EMAIL PROTECTED] To: Zoran Bogdanov [EMAIL PROTECTED]; php-general@lists.php.net Sent: Wednesday, February 06, 2008 2:27 PM Subject: RE: [PHP] PHP Source code protection zend encoder? http://sourceforge.net/projects/php-screw/ google for more bastien To: php-general@lists.php.net From: [EMAIL PROTECTED] Date: Wed, 6 Feb 2008 12:28:12 +0100 Subject: [PHP] PHP Source code protection Hi, I'm building a C# application that connects to a server that has PHP scripts on it. We need to deliver the complete solution to a firm, the C# is no problem because it is compiled... But PHP is a problem bacause it is interpreted and we will have to deliver pure, unprotected script... Is htere a way to secoure my code so when they put it on the server, they can't see it! Thank You! -- 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] Array numeric key - alpha key replacement
- Original Message - From: [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Wednesday, December 05, 2007 1:00 PM Subject: [PHP] Array numeric key - alpha key replacement Hello All, Is the a built-in PHP call that I am overlooking which lets me replace key values in an array. $inputArray = array(0 = array, 1 = array); (generated programtically) I want to end up with : $newArray = array('FAF1' = array, 'ODM1' = array); Thanks. Scot L. Diddle, UPS Freight, Richmond VA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php What about: $inputArray = array(); $inputArray['FAF1'] = array(); $inputArray['ODM1'] = array(); print_r($inputArray); HTH, Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Transfer query result to another script
- Original Message - From: Jochem Maas [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED] Cc: David Giragosian [EMAIL PROTECTED]; php-general php-general@lists.php.net Sent: Friday, November 02, 2007 10:41 AM Subject: Re: [PHP] Transfer query result to another script C.R.Vegelin wrote: ... Hi Jochem, The reason for a redirect is that Report.php has functionality such as sorting on report columns, checkboxes to make graphs etc. Suppose the following report columns: Country 06.Q1 06.Q2 06.Q3 06.Q4 07.Q1 07.Q2 1 Austria 1226 12111233132813861362 2 Belgium1004 11931008973711021270 3 etc. If I don't use a redirect but an include Report.php then Engine.php must be rerun: - every time a user wants to sort on a columns, eg. Y06.Q1 - every time a user wants to make a graph with selected rows. Right ? I did use an include but I'm changing it because of the reasons above. using a redirect doesn't solve the 'problem' - what does Engine.php doe exactly? how long does it take? your going to have think about caching the dataset generated by Engine in some way ... and sticking a MySQL resultset resource id in $_SESSION is not going to work. also does calling the script 'Report.php' mean you no longer have to refresh the page if you want to use different parameters? or do you still have to do a page refresh?? I know it does have its price. Regards, Cor Hi Jochem, Engine.php does the following: a. checking validity of form query fields b. sending messages if invalid form query fields c. building the sql and executing it d. new: building $_SESSION['data'] for Report.php e. include / redirect for different output formats Step d. now passes the result set to Report.php. So Engine.php now redirects to Report.php once per query, and when the user changes report settings, Report.php is called by itself with required settings. More or less comparable to http://www.tonymarston.net/sample/person_list.php, except that my application is read-only and provided with graphs. I have to admit that I haven't tested the time needed for steps a-c. So I may save some time at the cost of extra mem to pass SESSION['data']. On the other hand, by splitting Engine and Report code I may save some mem, I think. Thanks for your time, Jochem. Regards, Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Transfer query result to another script
Hello David, Jim, Thanks for your response. Yes, I do have session_start() at the top of Report.php. The reason for having the query on a different page than the result is that the result may be sent to various output types / scripts. I will change my code as follows: Engine.php - $result = mysqli_query($connect, $myquery); if (!$result) error ... if (mysqli_num_rows($result) == 0) error ... // fill $_SESSION['results'] with query result switch ($output) { case HTML: header(Location: Report.php); break; case CSV: ... case XML: ... case PDF: ... } Thanks again for your advice. Regards, Cor - Original Message - From: David Giragosian To: C.R.Vegelin ; php-general Sent: Thursday, November 01, 2007 5:23 PM Subject: Re: [PHP] Transfer query result to another script On 11/1/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, Q: Is it possible to transfer a query result to another script ? For example with (fragments of) the following 2 scripts: Engine.php $result = mysqli_query($connect, $myquery); if (!$result) error ... if (mysqli_num_rows($result) == 0) error ... $_SESSION['result'] = $result; header(Location: Report.php); Report.php $result = $_SESSION['result']; while ($row = mysqli_fetch_array($result)) ... This last line gives Couldn't fetch mysqli_result. Is this because the result set is local to Engine.php ? TIA, Cor Cor, Do you have session_start() at the top of Report.php? The manual shows an example of passing a php created class object using a session variable, with the caveat of needing to include the class definition on each page. It may be different for a mysql result object though. Why do you need the query on a different page than the result? David
Re: [PHP] Transfer query result to another script
- Original Message - From: Jochem Maas [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED] Cc: David Giragosian [EMAIL PROTECTED]; php-general php-general@lists.php.net Sent: Friday, November 02, 2007 9:06 AM Subject: Re: [PHP] Transfer query result to another script C.R.Vegelin wrote: Hello David, Jim, Thanks for your response. Yes, I do have session_start() at the top of Report.php. The reason for having the query on a different page than the result is that the result may be sent to various output types / scripts. I will change my code as follows: Engine.php - $result = mysqli_query($connect, $myquery); if (!$result) error ... if (mysqli_num_rows($result) == 0) error ... // fill $_SESSION['results'] with query result switch ($output) { case HTML: header(Location: Report.php); break; WRONG!!! there is no reason to do a redirect, use an include to run code relevant to the selected $output (and you'll have the result set available for no extra charge). and you can't stick resources (e.g. a resultset id) into session and expect them to persist - the value may be there, but the resource it pointed to is loong gone by the time the second script starts. case CSV: ... case XML: ... case PDF: ... } Thanks again for your advice. Regards, Cor - Original Message - From: David Giragosian To: C.R.Vegelin ; php-general Sent: Thursday, November 01, 2007 5:23 PM Subject: Re: [PHP] Transfer query result to another script On 11/1/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, Q: Is it possible to transfer a query result to another script ? For example with (fragments of) the following 2 scripts: Engine.php $result = mysqli_query($connect, $myquery); if (!$result) error ... if (mysqli_num_rows($result) == 0) error ... $_SESSION['result'] = $result; header(Location: Report.php); Report.php $result = $_SESSION['result']; while ($row = mysqli_fetch_array($result)) ... This last line gives Couldn't fetch mysqli_result. Is this because the result set is local to Engine.php ? TIA, Cor Cor, Do you have session_start() at the top of Report.php? The manual shows an example of passing a php created class object using a session variable, with the caveat of needing to include the class definition on each page. It may be different for a mysql result object though. Why do you need the query on a different page than the result? David Hi Jochem, The reason for a redirect is that Report.php has functionality such as sorting on report columns, checkboxes to make graphs etc. Suppose the following report columns: Country 06.Q1 06.Q2 06.Q3 06.Q4 07.Q1 07.Q2 1 Austria 1226 12111233132813861362 2 Belgium1004 11931008973711021270 3 etc. If I don't use a redirect but an include Report.php then Engine.php must be rerun: - every time a user wants to sort on a columns, eg. Y06.Q1 - every time a user wants to make a graph with selected rows. Right ? I did use an include but I'm changing it because of the reasons above. I know it does have its price. Regards, Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Transfer query result to another script
Hi All, Q: Is it possible to transfer a query result to another script ? For example with (fragments of) the following 2 scripts: Engine.php $result = mysqli_query($connect, $myquery); if (!$result) error ... if (mysqli_num_rows($result) == 0) error ... $_SESSION['result'] = $result; header(Location: Report.php); Report.php $result = $_SESSION['result']; while ($row = mysqli_fetch_array($result)) ... This last line gives Couldn't fetch mysqli_result. Is this because the result set is local to Engine.php ? TIA, Cor
Re: [PHP] how to restart php
Hi Diana, To restart the IIS webserver with Windows XP: press Start, select Run, type IISreset HTH, Cor - Original Message - From: Richard Heyes [EMAIL PROTECTED] To: Diana [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Thursday, October 25, 2007 1:02 PM Subject: Re: [PHP] how to restart php Diana wrote: How can I restart php so it takes changes in my php.ini without having to reboot my machine? I have windows XP You don't restart PHP, rather the web server whatever that may be. Usually it involves restarting the web server service. If you can, just restart the computer. -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support -- 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] highlighting searchterms as bold text
Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor
Re: [PHP] highlighting searchterms as bold text
- Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlighting searchterms as bold text
- Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 11:29 AM Subject: RE: [PHP] highlighting searchterms as bold text thats odd because the regex passes when I test it with this online tool: http://samuelfullman.com/team/php/tools/regular_expression_tester_p2.php -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:59 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor Hi Deniz, I tried the referred regex tool as well, and I get Bad Result for /^ethyl/i and Good Result for /ethyl/i Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlighting searchterms as bold text
- Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 12:25 PM Subject: RE: [PHP] highlighting searchterms as bold text you probably have some characters before/after the phrase that prevents the match. This should do it: (i hope) /(\S|\s)*\bethyl\b(\S|\s)*/i -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 3:09 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 11:29 AM Subject: RE: [PHP] highlighting searchterms as bold text thats odd because the regex passes when I test it with this online tool: http://samuelfullman.com/team/php/tools/regular_expression_tes ter_p2.php -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:59 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor Hi Deniz, I tried the referred regex tool as well, and I get Bad Result for /^ethyl/i and Good Result for /ethyl/i Cor Hi Deniz, Edward, Mike, Thanks for your suggestions. Deniz, pattern /(\S|\s)*\bethyl\b(\S|\s)*/i makes from any line containing ethyl, such as Undenatured ethyl alcohol lines containing only: ethyl Edward, pattern /(\s|)ethyl(\s|)/i makes from: Undenatured ethyl alcohol Undenaturedethylalcohol (stripping spaces). I will take a look at http://suda.co.uk/projects/SEHL/. Mike, the \W character makes from Undenatured ethyl alcohol Undenaturedethylalcohol (stripping spaces). The \b character makes: Undenatured ethyl alcohol (okay) the word methyl is unchanged (okay) but ethylene keeps also unchanged ... Thanks anyway ! Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] highlighting searchterms as bold text
- Original Message - From: Puiu Hrenciuc [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Thursday, September 20, 2007 12:56 PM Subject: Re: [PHP] highlighting searchterms as bold text Sorry, I didn't read d) right (NOT Methyl), here is teh new regex : /(\b#SearchTermHere#(\w+)?)/i The code sample is the same, replace regex, of course . Output should be : bethyl/b Lorem bEthyl/b ipsum MeThYl dolor bEthylene/b sit Cheers Puiu Hrenciuc wrote: Hi, Here's what you need: RegEx: /((\w+)?#SearchTermHere#(\w+)?)/i Of course, replace your #SearchTermHere# with what you need, i.e. /((\w+)?ethyl(\w+)?)/i Code sample: $_textToHighlight='ethyl Lorem Ethyl ipsum MeThYl dolor Ethylene sit'; $_search='/((\w+)?ethyl(\w+)?)/i'; $_replace='b\\1/b'; $_highlightedText=preg_replace($_search,$_replace,$_textToHighlight); This should output: bethyl/b Lorem bEthyl/b ipsum bMeThYl/b dolor bEthylene/b sit Hope it helps, PuYa C.R.Vegelin wrote: - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 11:29 AM Subject: RE: [PHP] highlighting searchterms as bold text thats odd because the regex passes when I test it with this online tool: http://samuelfullman.com/team/php/tools/regular_expression_tester_p2.php -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:59 PM To: Deniz Dizman (BST UGB); [EMAIL PROTECTED] Subject: Re: [PHP] highlighting searchterms as bold text - Original Message - From: Deniz Dizman (BST UGB) [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, September 20, 2007 10:38 AM Subject: RE: [PHP] highlighting searchterms as bold text try /^ethyl/i what you want is ignore case and pattern begins with -- dd -Original Message- From: C.R.Vegelin [mailto:[EMAIL PROTECTED] Sent: Thursday, September 20, 2007 1:31 PM To: [EMAIL PROTECTED] Subject: [PHP] highlighting searchterms as bold text Hi everyone, I want to highlight (bold) searchterms in text. For example, for all words starting with ethyl: a) replace ethyl by bethyl/b b) replace Ethyl by bEthyl/b c) replace ethylene by bethylene/b d) but not methyl by bmethyl/b Now I use: $patterns[0] = /ethyl/; $replacements[0] = bethyl/b; $text = preg_replace($patterns, $replacements, $text); This works for a) and c), but not for b) and d). Any idea how to do this ? TIA, Cor Thanks Deniz, I tried pattern /^ethyl/i but this does not highlight anything. I also tried pattern /ethyl/i and this highlights all, but also methyl ... Any suggestion ? Cor Hi Deniz, I tried the referred regex tool as well, and I get Bad Result for /^ethyl/i and Good Result for /ethyl/i Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks Puiu, I tested your regex with the code below. However, it didn't work. Maybe I'm missing something ... To test it, change the $pattern setting. ?php $term = ethyl; $text = Ethylene, ethyl and methyl are different things.; $pattern = /(\b# . $term . #(\w+)?)/i; $replacement = b . $term . /b; // or: $replacement = b\\1/b; echo before: . $text, br /; $text = preg_replace($pattern, $replacement, $text); echo after: . $text, br /; echo wanted:br /bEthyl/bene, bethyl/b and methyl are different things., br /; echo or:br /bethyl/bene, bethyl/b and methyl are different things., br /; ? Regards, Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] javascript in head or in body ?
Are there any rules when to include javascript in head or in body ? For example, script type=text/javascript function reload(form) { var val=form.Chapter.options[form.Chapter.options.selectedIndex].value; self.location='QueryForm.php?Chapter=' + val ; } /script TIA, Cor
[PHP] Comment modes behavior in HTML and PHP
I have a PHP script, as follows: !-- ?php echo should this be echoed ?; ? -- As expected, the browser shows nothing, but when I view Source in the browser, I see: !-- start HTML comment should this be echoed ?-- Shouldn't it be just: !-- --, without the echo result ? I don't expect PHP to be active between !-- --. TIA, Cor
Re: [PHP] Comment modes behavior in HTML and PHP
Hi Daniel, Paul, Robert, Rick, Thanks for making it clear. Have a nice weekend. Cor - Original Message - From: Daniel Brown [EMAIL PROTECTED] To: Paul Novitski [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Saturday, July 28, 2007 4:29 PM Subject: Re: [PHP] Comment modes behavior in HTML and PHP On 7/28/07, Paul Novitski [EMAIL PROTECTED] wrote: At 7/28/2007 07:40 AM, C.R.Vegelin wrote: I have a PHP script, as follows: !-- ?php echo should this be echoed ?; ? -- As expected, the browser shows nothing, but when I view Source in the browser, I see: !-- start HTML comment should this be echoed ?-- Shouldn't it be just: !-- --, without the echo result ? I don't expect PHP to be active between !-- --. !-- ... -- is an HTML comment. /* ... */ and //... are PHP comments. The HTML comment syntax does not affect PHP, and PHP comment syntax does not affect HTML. http://www.php.net/manual/en/language.basic-syntax.comments.php Regards, Paul __ Paul Novitski Juniper Webcraft Ltd. http://juniperwebcraft.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Taking a moment to explain the WHY of what's happening should help you understand it a bit more, Cor. All HTML markup - including comments - is parsed on the browser side, while PHP is done on the server side. The server doesn't parse HTML at all, and PHP doesn't have any knowledge of it's position within a script, or what else exists outside of the ? ? tags. Thus, PHP is parsed, compiled, and executed prior to the web server serving the end-result as pure HTML, which is then parsed by the browser upon receipt. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- 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] repetition of tedious references
Hi OLav, what about this ? $language = isused($_SERVER[HTTP_ACCEPT_LANGUAGE]); echo language is . $language; function isused($variable) { return isset($variable) $variable != ? $variable : *; } HTH, Cor - Original Message - From: Olav Mørkrid [EMAIL PROTECTED] To: PHP General List php-general@lists.php.net Sent: Wednesday, July 18, 2007 1:24 PM Subject: [PHP] repetition of tedious references consider the following statement: $language = isset($_SERVER[HTTP_ACCEPT_LANGUAGE]) $_SERVER[HTTP_ACCEPT_LANGUAGE] != ? $_SERVER[HTTP_ACCEPT_LANGUAGE] : *; when using strings in arrays that may be non-existing or empty, you have to repeat the reference *three* times, which gets excessive and unreadable. is there any way to only have to write $_SERVER[HTTP_ACCEPT_LANGUAGE] only once? i know it's possible to supress is not set with @, but that just seems wrong in case there really is an error in the statement. i love php, but this is one of my pet peeves. -- 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] Dynamic refresh dropdown list
I have a selection form with multiple dropdown lists, let's say A, B and C. If the dropdown list B is changed, then dropdown list C should be updated. To get this done, I use a small javascript function reload(form) { var val=form.B.options[form.B.options.selectedIndex].value; self.location='myForm.php?B=' + val ; } called by select id=B name=B onChange=reload(this.form); This works fine, BUT all other dropdown lists are also reset. So if I select another A, then another B, then also A is reset to its prior value. Any idea how I can refresh a specific dropdown, without affecting all the other dropdowns ? TIA, Cor
[PHP] How to pass connection as global variable ?
I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); ... $link = mysqli_connect($mysqlhost, $mysqluser, $mysqlpsw, $mysqldb) or die(cannot connect); $_SESSION['connection'] = $link; ... ? faq.php --- ?php require(menu.php); $link = $_SESSION['connection']; $sql = SELECT Question, Answer FROM myfaqs; $result = mysqli_query($link, $sql); // previous line gives: //Notice: Undefined variable: _SESSION in C:\Inetpub\wwwroot\test\faq.php //Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\Inetpub\wwwroot\test\faq.php ... ?
Re: [PHP] How to pass connection as global variable ?
- Original Message - From: Chris [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] php-general@lists.php.net Sent: Wednesday, July 11, 2007 8:56 AM Subject: Re: [PHP] How to pass connection as global variable ? C.R.Vegelin wrote: I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); snip faq.php --- ?php require(menu.php); The first two lines give it away ;) You're missing a session_start(). -- Postgresql php tutorials http://www.designmagick.com/ Thanks Chris, I included session_start(); as first line in faq.php, but now I get other warnings /errors: Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in line $result = mysqli_query($link, $sql); Warning: mysqli_error() [function.mysqli-error]: Couldn't fetch mysqli in line if (!$result) { echo Can't execute query ($sql): . mysqli_error($link); exit; } Any idea why ? Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to pass connection as global variable ?
C.R.Vegelin wrote: I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); snip faq.php --- ?php require(menu.php); The first two lines give it away ;) You're missing a session_start(). -- Postgresql php tutorials http://www.designmagick.com/ Thanks Chris, I included session_start(); as first line in faq.php, but now I get other warnings /errors: Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in line $result = mysqli_query($link, $sql); Warning: mysqli_error() [function.mysqli-error]: Couldn't fetch mysqli in line if (!$result) { echo Can't execute query ($sql): . mysqli_error($link); exit; } Actually - shoot me for not noticing this before. You can't store a resource or connection in the session. You have to recreate your connection in each page. See http://php.net/session . -- Postgresql php tutorials http://www.designmagick.com/ Hi Chris, I recreated a new connection in faq.php and it's working now. I had the impression that 1 connection could last during a user session, but apparently a user session may need many connections. Thanks again, Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to pass connection as global variable ?
Thanks M. Sokolewicz for explaining the under water basics ... Cor - Original Message - From: M. Sokolewicz [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED] Cc: Chris [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Wednesday, July 11, 2007 9:56 AM Subject: Re: [PHP] How to pass connection as global variable ? C.R.Vegelin wrote: C.R.Vegelin wrote: I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); snip faq.php --- ?php require(menu.php); The first two lines give it away ;) You're missing a session_start(). -- Postgresql php tutorials http://www.designmagick.com/ Thanks Chris, I included session_start(); as first line in faq.php, but now I get other warnings /errors: Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in line $result = mysqli_query($link, $sql); Warning: mysqli_error() [function.mysqli-error]: Couldn't fetch mysqli in line if (!$result) { echo Can't execute query ($sql): . mysqli_error($link); exit; } Actually - shoot me for not noticing this before. You can't store a resource or connection in the session. You have to recreate your connection in each page. See http://php.net/session . -- Postgresql php tutorials http://www.designmagick.com/ Hi Chris, I recreated a new connection in faq.php and it's working now. I had the impression that 1 connection could last during a user session, but apparently a user session may need many connections. Thanks again, Cor Remember that the http protocol is stateless. Every request made is a new connection to the server. It's due to extra technologies like cookies (and in this case sessions) that some form of 'state' can be maintained. However, because there is no communication between client and server unless the client makes a request you can never actually determine the _current_ status of your session, only in retrospect you can. If a user makes a request, you could say the session is 'in progress', however, after sending that page you don't know if it's still 'in progress' or has ended until you recieve another request, thus telling you it WAS still in progress. Now, as for resources and connections: PHP clears up everything when it finishes sending a response to a request. This does not happen for certain very specific items which were stored away (like in a database or in a session, which is usually just a file). For a connection to be 'open' it needs to be able to communicate with both its' sides (client: your database; and the 'server': PHP), if php 'shuts down' because it finished the request, it doesn't leave anything of itself behind, and as such the 'server' of that connection also disappears, thus creating a broken link which is automatically destroyed. Of course the php engine is smart and knows this would happen, so it 'cleanly' closes the connection before disappearing to reappear again (fresh) on a next request. hope that helps you understand, - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undefined GD function [SOLVED]
Thanks for your advice, As mentioned, I am using IIS 5.1 and .. the problem was solved after restarting my machine. BTW, IIS can also restarted with iisreset. Regards, Cor - Original Message - From: Richard Lynch [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] php-general@lists.php.net Sent: Tuesday, June 05, 2007 11:30 PM Subject: Re: [PHP] undefined GD function getimagesize is okay, because it's not really really a GD function, even though it's lumped in there... Did you restart Apache? (or the whole machine if you run IIS)? On Mon, June 4, 2007 5:38 am, C.R.Vegelin wrote: Hi All, I am testing some GD functions, but I'm getting undefined function errors. I checked php.ini and changed ;extension=php_gd2.dll to extension=php_gd2.dll The php.ini file contains: extension_dir = c:/php/ext and this directory does contain php_gd2.dll (version 5.2.0.0) I am using Windows XP, PHP 5.2.0 and IIS 5.1. The function getimagesize($filename); is okay, but imagecreatetruecolor($width, $height); says undefined function. I would appreciate some hints. TIA, Cor -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] undefined GD function
Hi All, I am testing some GD functions, but I'm getting undefined function errors. I checked php.ini and changed ;extension=php_gd2.dll to extension=php_gd2.dll The php.ini file contains: extension_dir = c:/php/ext and this directory does contain php_gd2.dll (version 5.2.0.0) I am using Windows XP, PHP 5.2.0 and IIS 5.1. The function getimagesize($filename); is okay, but imagecreatetruecolor($width, $height); says undefined function. I would appreciate some hints. TIA, Cor
Re: [PHP] getting $_ENV variables
Thanks Daniel, Greg, Richard, I made a script with: ?php print_r($_ENV); ? and it results only into: Array ( ) nothing else ... So it must be caused by a different environment ? All I want is to check the $_ENV['OS'] within PHP scripts. Regards, Cor - Original Message - From: Daniel Brown To: C.R.Vegelin Cc: [EMAIL PROTECTED] Sent: Wednesday, May 09, 2007 5:26 PM Subject: Re: [PHP] getting $_ENV variables When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
Daniel, I did get the result via the web / IE with the address: http://127.0.0.1/test/ENVtest.php with ENVtest.php having: ?php print_r($_ENV); ? using Windows XP, PHP 5.2.0 - Original Message - From: Daniel Brown To: C.R.Vegelin Cc: [EMAIL PROTECTED] Sent: Thursday, May 10, 2007 2:24 PM Subject: Re: [PHP] getting $_ENV variables Cor, If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. Did you get that result when running the script from the CLI or via the web? On 5/10/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Thanks Daniel, Greg, Richard, I made a script with: ?php print_r($_ENV); ? and it results only into: Array ( ) nothing else ... So it must be caused by a different environment ? All I want is to check the $_ENV['OS'] within PHP scripts. Regards, Cor - Original Message - From: Daniel Brown To: C.R.Vegelin Cc: [EMAIL PROTECTED] Sent: Wednesday, May 09, 2007 5:26 PM Subject: Re: [PHP] getting $_ENV variables When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
Yes, my PHPinfo shows under configuration: variables_order = GPCS I will test EGPCS setting in php.ini But that also means that code using $_ENV cannot be run with hosts hiding the environment settings ?! And I assume that EGPCS will also affect: ?php print_r($_FILES); ? Now with GPCS this script shows also only: Array ( ) So also potential problems with $_FILES with hosts hiding the environment settings ?! Regards, Cor - Original Message - From: Richard Davey [EMAIL PROTECTED] To: [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, May 10, 2007 2:44 PM Subject: Re: [PHP] getting $_ENV variables Daniel Brown wrote: If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. The $_ENV superb-global contains an array of environment settings, so it's not totally baffling that print_r() on it should return an array. The reason it is empty is because the variables_order setting in the php.ini has had it disabled. The default is: variables_order = EGPCS But it must have been changed to: variables_order = GPCS Dropping the E (Environment variables) will cause a print_r($_ENV) to be totally empty. Some hosts do this in order to hide the environment settings because they can contain sensitive information such as the CPU identifiers, etc. I've seen the 'cheaper' hosts (especially those hosting on Windows and/or Virtual Servers) disable this so you can't tell what kind of CPU they're using, or where their system drive is. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- 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] getting $_ENV variables
Okay, I will use getenv() and keep variables_order = GPCS in php.ini Thanks all and with regards, Cor - Original Message - From: Richard Davey [EMAIL PROTECTED] To: [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, May 10, 2007 3:34 PM Subject: Re: [PHP] getting $_ENV variables C.R.Vegelin wrote: Yes, my PHPinfo shows under configuration: variables_order = GPCS I will test EGPCS setting in php.ini But that also means that code using $_ENV cannot be run with hosts hiding the environment settings ?! Correct. Sucks I know, but some hosts just do this. And I assume that EGPCS will also affect: ?php print_r($_FILES); ? No, $_FILES isn't part of the Environment list, it's created again at run-time when a file upload occurs. It would be worth running a test to see if they have tied it to the $_POST array, i.e. remove the 'P' from EGPCS and see if $_FILES gets lost with it. I would be curious to know, although I can't think of a single host that would be stupid enough to disable $_POST :) Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- 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] scrolling HTML tables
I hope it's not the wrong place to ask, but has anyone experience with scrolling HTML tables ? According http://www.w3schools.com/tags/tag_thead.asp The thead, tfoot and tbody elements enable you to group rows in a table. When you create a table, you might want to have a header row, some rows with data, and a row with totals at bottom. This division enables browsers to support scrolling of table bodies independently of the table header and footer. I don't want to reinvent the wheel in own software. Or is it better to ignore these tags because of bad browser support ? Thanks, Cor
[PHP] getting $_ENV variables
Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor