RE: [PHP] Help with regex: breaking strings down to 'words' and 'phrases'
On Wed, 11 May 2005, Murray @ PlanetThoughtful wrote: Hi All, I'd very much appreciate some help building a regular expression for preg_match_all that can differentiate between 'words' and 'phrases'. For example, say I have a string that contains: 'this is an example of a phrase' I'd like to be able to break that down to: this is an example of a phrase I haven't thought this through fully, but what if you exploded the string on into an array. Then loop through the array and for every even element, explode on a space, otherwise just store the whole string into the new array. I think I *may* have solved this at my end. The following statement seems to work: preg_match_all('/([\w\-]+?|[(]|[)]|\.+\)/U',strtoupper($prep_sql),$sqlarr) ; I need to test it out with a whole series of different possible combinations to see if it behaves the way I want it to, but so far the results are good. If anyone can see any flaws, I'd love to know about them! Many thanks, Murray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help formatting a mysql datetime variable
On Fri, April 29, 2005 7:38 am, Bosky, Dave said: I'm trying to get a mysql datetime variable called $cdate formatted so it will print: Thursday, April 28, 2005 at 8:00:00 PM Eastern Time I tried the following but it's not perfect. -- $newDate = date('I, F d, Y at g:i:s A T', $cdate); echo $newDate; -- http://php.net/date may help you. You should also consider using MySQL's date_format function. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help outputting an array?
On Tuesday 26 April 2005 06:55, Brian Dunning wrote: Hi all - it seems the longer I use PHP, the stupider my questions are getting. I finally got my XML parsed into an array, but perhaps my skills at dealing with the array are not where I thought they were. My array print_r's out like this: Array ( [PARAS] = Array ( [PARA] = Array ( [__multi] = 1 [0] = Array ( [NOTE] = Here is my first note. [TITLE] = Here is my first title. ) [1] = Array ( [NOTE] = Here is my second note. [TITLE] = Here is my second title. ) ) ) ) I just want to loop through the array and output it as a table. It would look something like this: tdHere is my first note./tdtdHere is my first title./td tdHere is my second note./tdtdHere is my second title./td Use 'foreach' (http://www.php.net/foreach) to loop through the arrays and check each member of the array with the function 'is_array' (http://www.php.net/is_array) to see if it's been a XML parameter or XML child element. What incredibly easy way to do this am I just missing? Thanks! :) -- Cyberly yours, Petar Nedyalkov Devoted Orbitel Fan :-) PGP ID: 7AE45436 PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436 pgpWuEGmW6Scn.pgp Description: PGP signature
Re: [PHP] Help outputting an array?
Brian Dunning wrote: Hi all - it seems the longer I use PHP, the stupider my questions are getting. I finally got my XML parsed into an array, but perhaps my skills at dealing with the array are not where I thought they were. My array print_r's out like this: Array ( [PARAS] = Array ( [PARA] = Array ( [__multi] = 1 [0] = Array ( [NOTE] = Here is my first note. [TITLE] = Here is my first title. ) [1] = Array ( [NOTE] = Here is my second note. [TITLE] = Here is my second title. ) ) ) ) I just want to loop through the array and output it as a table. It would look something like this: tdHere is my first note./tdtdHere is my first title./td tdHere is my second note./tdtdHere is my second title./td What incredibly easy way to do this am I just missing? Thanks! :) Hi All, crikey, you'd think I woulda seen that myself. Forgot something so fundamental...it's been a while since I played with programming..it shows..cheers. Mark Sargent. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help for me about session
On Sat, April 23, 2005 7:35 pm, Josephson Tracy said: hi everyone, when i study php, i have a problem as following: - file1.php ? if($NextCourse == 1){ do something;} else($NextCourse ==){do something other } ? script language=javascript function hasNextCourse(){ document.form1.NextCourse.value = 1; alert('Setting NextCourse to 1'); } /script form name=form1 method=post action=file1.php onSubmit=return checkform() input type=hidden name=NextCourse input type=submit name=Submit32 value=next onClick= return hasNextCourse() /form - but when the 2ed access the file1.php the value of $NextCourse is the $NextCourse in the ? and ?, Not the There is no value give to it initially, so I'm not quite sure what you mean... If you have register_globals OFF, it might appear to never get set to 1, because it's in $_POST['NextCourse'] not in $NextCourse Your else() above isn't valud syntax... Perhaps you should post EXACTLY what your code looks like... value of document.form1.NextCourse.value. could someone tell me why?thanks This could probably be done easier, by the way, by just using: input type=submit name=NextCourse value=Click me if there is another and then: ?php if (isset($_POST['NextCourse'])){ //They clicked the button to indicate another } else{ //They clicked some other button } ? -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with install to one page only
lisa, i think your problem may be simple enough... but if this doesn't work, i dunno... i'm guessing that you're using some webhost right? well... Note: Your file should be present in the same folder where HEC/ is present E.g: ~/testcal.php [your file where you want to display event calendar] ~/HEC/ [unzipped HEC package] ( I made a page called testcalendar.php and put it in the foldeer HEC, but I am getting error messages. okay.. you put your file (testcalendar.php) in the HEC folder, but you're supposed to put it in the same folder as the HEC folder... using windows, the path would look like this: c:\folder\subfolder\testcalendar.php c:\folder\subfolder\HEC\ but http addresses are written in unix style, so it looks like this /folder/subfolder/testcalendar.php /folder/subfolder/HEC/ hope that makes a little more sense to you... just move that file up one directory and try running it again. drew -- dc .. drewcore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help for me about session
At 09:35 PM 4/23/2005, Josephson Tracy wrote: hi everyone, when i study php, i have a problem as following: - file1.php ? if($NextCourse == 1){ do something;} else($NextCourse ==){do something other } ? - but when the 2ed access the file1.php the value of $NextCourse is the $NextCourse in the ? and ?, Not the value of document.form1.NextCourse.value. could someone tell me why?thanks I believe it should be: ? if($NextCourse == 1){ do something; } elseif(!$NextCourse){ do something other; } ? By the way you have your statement, I think you are only looking for the 1. You might try the following instead. ? if($NextCourse == 1){ do something; }else{ do something else; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help for me about session
-- mierda carajo saquenme de sta lista de mierda q llema mi correo de huevadas rapido carjo.nierdas --- Banco de Crédito BCP - Dedicados a hacerte la Banca más simple. Visita nuestra Banca por Internet http://www.viabcp.com --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP!
Yes -- In your example - $result_id would be accessed on page2 as $result_id = $_GET['result_id']; Then through out your script on page 2 you could access $result_id. Hope that helps. -- - $result_id 2 $result_id = $_get['result_id ' ]; 2 $result_id ?php /* Stephen Johnson c | eh The Lone Coder http://www.thelonecoder.com [EMAIL PROTECTED] 562.924.4454 (office) 562.924.4075 (fax) continuing the struggle against bad code */ ? From: [EMAIL PROTECTED] Date: Wed, 13 Apr 2005 11:00:36 +0800 To: php-general@lists.php.net Subject: [PHP] HELP! HI, Any body give me any hinder I would be very appreciated! I want to use a parameter of fist page in the second page, how can I realize it. For example, there is a segment in the first page: tr tdcom/tdtda href='/cgi-bin/english/E_new_domain_list.cgi?domainType=1'? echo $num_com;?/a/td tda href=autorenew.php?$result_id = 1? echo $buy_com_num;?/a/td /tr But I wan to use the parameter $result_id in the second page(autorenew.php) : switch($result_id){ case 1 : ..; Break; case 2 : ..; Break; Can the parameter $result_id pass from fist page to second page(autorenew.php)? Sincerely yours, justin E-mail/MSN: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with proper post method...
very quick and *very* dirty, put this in top of your file extract($_POST); and voila, you bypassed registerglobals off -- Lars B. Jensen, Internet Architect CareerCross Japan Japan's premier online career resource for english speaking professionals http://www.careercross.com - Original Message - From: Joey [EMAIL PROTECTED] To: PHP php-general@lists.php.net Sent: Wednesday, April 06, 2005 2:23 PM Subject: [PHP] Help with proper post method... OK I am migrating some sites from an old school server to one with MySQL 4 newest PHP, however certain things aren't running because of the register_globals variable on the new server is set to OFF for security reasons. What I am trying to do is post like so with hidden variables form method=post action=display_info.php The display_info.php says Undefined variables in the file, because of course since globals is off it's not being passed to it from the first form. Now I'm not trying to become the master here, but need a quick and dirty way of patching these programs to accept the hidden passed values so I don't have to go and re-code everything... Any links to a good example etc would be greatly appreciated. Thanks! Joey -- 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] Help with proper post method...
On Tue, April 5, 2005 10:23 pm, Joey said: OK I am migrating some sites from an old school server to one with MySQL 4 newest PHP, however certain things aren't running because of the register_globals variable on the new server is set to OFF for security reasons. What I am trying to do is post like so with hidden variables form method=post action=display_info.php The display_info.php says Undefined variables in the file, because of course since globals is off it's not being passed to it from the first form. Now I'm not trying to become the master here, but need a quick and dirty way of patching these programs to accept the hidden passed values so I don't have to go and re-code everything... Any links to a good example etc would be greatly appreciated. For each variable that it says is Undefined and/or which is coming from POST, simply global search and replace: $foo -$_POST['foo'] If it's embedded in a string$foo you want string$_POST[foo] Note that doing import($_POST) is strictly an emergency measure which completely defeats the purpose of register_globals OFF in the first place. You can do it for a few hours, days before you fix it for real, as above. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx- Narrowed it down!
What you see as round numbers in base 10, are not so in binary. Numbers such as .5, .25, .125, .0625 and so on, multiples of one half, are round numbers in binary, though they don't look so in decimal. Others which look pretty simple in decimal are not, for example, 0.1 gives you an infinite series 0.11001100110011... in binary. All this numbers give you rounding errors. That is why many languages have introduced 'currency' or 'money' data types, they are either integer data types scaled back to a fixed number of decimal places, or they are floats rounded of the least significant digits. You can do either by yourself, that is, have all currency internally represented as cents and scale it to full units when showing it, or round off at two cents after each calculation. Satyam Anthony Tippett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] btw, thanks for your response. I'm not sure as if I understand why. It's not like I'm using a very precise number when dealing with the hundreths place. Even without the multiplication the number gets messed up. eg. $a = 17.00; $a+= 1.10; $a+= 0.32; $a+= 0.07; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) I'm just trying to add money amounts? Can I not rely on floats to do this? Richard Lynch wrote: Floats are NEVER going to be coming out even reliably. You'll have to check if the difference is less than X for whatever number X you like. Or you can look at something like BC_MATH where precision can be carried out as far as you like... But what you are seeing is to be expected. That's just the way computers work, basically. On Mon, April 4, 2005 5:07 pm, Anthony Tippett said: Ok i've narrowed it down a little bit but still can't figure it out.. Here's the code and what I get for the output. Does anyone know what's going on? Can someone else run it on their computer and see if they get the same results? ?php $a = 17.00 * 1; $a+= 1.10 * 1; $a+= 0.32 * 1; $a+= 0.07 * 1; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) ? Anthony Tippett wrote: I'm having trouble figuring out why subtraction of two floats are giving me a very small number. I'm thinking it has something to do with the internals of type casting, but i'm not sure. If anyone has seen this or can give me some suggestions, please. I have 2 variables that go through a while loop and are added/subtracted/ multipled. InvAmt and InvPay are shown as floats but when they are subtracted, they give me a really small number // code var_dump($InvAmt); var_dump($InvPay); var_dump($InvAmt-$InvPay); // output float(18.49) float(18.49) float(2.1316282072803E-14) -- 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] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx
Anthony Tippett wrote: I'm having trouble figuring out why subtraction of two floats are giving me a very small number. I'm thinking it has something to do with the internals of type casting, but i'm not sure. If anyone has seen this or can give me some suggestions, please. I have 2 variables that go through a while loop and are added/subtracted/ multipled. InvAmt and InvPay are shown as floats but when they are subtracted, they give me a really small number // code var_dump($InvAmt); var_dump($InvPay); var_dump($InvAmt-$InvPay); // output float(18.49) float(18.49) float(2.1316282072803E-14) Computers are not able to represent floating point numbers precisely. If you are doing financial stuff I would suggest using integer math and working completely in pennies. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with GD
On Sun, April 3, 2005 12:31 am, [EMAIL PROTECTED] said: is there any way to edit and resize animated gifs in PHP? with imagegif() i only get a static image Not as far as I know... Though I do recall seeing something about this on the GD page, so maybe you want to look at adding that support to PHP... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!
Ok i've narrowed it down a little bit but still can't figure it out.. Here's the code and what I get for the output. Does anyone know what's going on? Can someone else run it on their computer and see if they get the same results? ?php $a = 17.00 * 1; $a+= 1.10 * 1; $a+= 0.32 * 1; $a+= 0.07 * 1; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) ? Anthony Tippett wrote: I'm having trouble figuring out why subtraction of two floats are giving me a very small number. I'm thinking it has something to do with the internals of type casting, but i'm not sure. If anyone has seen this or can give me some suggestions, please. I have 2 variables that go through a while loop and are added/subtracted/ multipled. InvAmt and InvPay are shown as floats but when they are subtracted, they give me a really small number // code var_dump($InvAmt); var_dump($InvPay); var_dump($InvAmt-$InvPay); // output float(18.49) float(18.49) float(2.1316282072803E-14) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!
Floats are NEVER going to be coming out even reliably. You'll have to check if the difference is less than X for whatever number X you like. Or you can look at something like BC_MATH where precision can be carried out as far as you like... But what you are seeing is to be expected. That's just the way computers work, basically. On Mon, April 4, 2005 5:07 pm, Anthony Tippett said: Ok i've narrowed it down a little bit but still can't figure it out.. Here's the code and what I get for the output. Does anyone know what's going on? Can someone else run it on their computer and see if they get the same results? ?php $a = 17.00 * 1; $a+= 1.10 * 1; $a+= 0.32 * 1; $a+= 0.07 * 1; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) ? Anthony Tippett wrote: I'm having trouble figuring out why subtraction of two floats are giving me a very small number. I'm thinking it has something to do with the internals of type casting, but i'm not sure. If anyone has seen this or can give me some suggestions, please. I have 2 variables that go through a while loop and are added/subtracted/ multipled. InvAmt and InvPay are shown as floats but when they are subtracted, they give me a really small number // code var_dump($InvAmt); var_dump($InvPay); var_dump($InvAmt-$InvPay); // output float(18.49) float(18.49) float(2.1316282072803E-14) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!
btw, thanks for your response. I'm not sure as if I understand why. It's not like I'm using a very precise number when dealing with the hundreths place. Even without the multiplication the number gets messed up. eg. $a = 17.00; $a+= 1.10; $a+= 0.32; $a+= 0.07; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) I'm just trying to add money amounts? Can I not rely on floats to do this? Richard Lynch wrote: Floats are NEVER going to be coming out even reliably. You'll have to check if the difference is less than X for whatever number X you like. Or you can look at something like BC_MATH where precision can be carried out as far as you like... But what you are seeing is to be expected. That's just the way computers work, basically. On Mon, April 4, 2005 5:07 pm, Anthony Tippett said: Ok i've narrowed it down a little bit but still can't figure it out.. Here's the code and what I get for the output. Does anyone know what's going on? Can someone else run it on their computer and see if they get the same results? ?php $a = 17.00 * 1; $a+= 1.10 * 1; $a+= 0.32 * 1; $a+= 0.07 * 1; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) ? Anthony Tippett wrote: I'm having trouble figuring out why subtraction of two floats are giving me a very small number. I'm thinking it has something to do with the internals of type casting, but i'm not sure. If anyone has seen this or can give me some suggestions, please. I have 2 variables that go through a while loop and are added/subtracted/ multipled. InvAmt and InvPay are shown as floats but when they are subtracted, they give me a really small number // code var_dump($InvAmt); var_dump($InvPay); var_dump($InvAmt-$InvPay); // output float(18.49) float(18.49) float(2.1316282072803E-14) -- 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] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!
Thanks to everyone that helped. After further googling, bug 9288 had a good explanation of what was going on ( which is not a bug) http://bugs.php.net/bug.php?id=9288edit=3 I'll just include the answer for anyone that comes upon this tread on a search engine. [15 Feb 2001 2:55pm CET] hholzgra at php rot dot fot net short answer: never use floats or doubles for financial data! longer answer: the internal number format in modern computers is binary (base 2) and not decimal (base 10) for performance and complexity reasons while it is possible to convert decimal numbers into binaries and back this does not hold true for fractions something like 0.3 (decimal) would be a periodic binary fraction like 10/3 is 0.... in decimal this leads to loss of precision when calculation with decimal fractions as you have when storing currency values solution: if you just summ up values then you should store values in the smalest unit your currency has (pennies?) instead of what you are used to (Pounds?) to totally avoid fractions if you cannot avoid fractions (like when dealing with percentage calculations or currency conversions) you should just be aware of the (usually very small) internal conversion differences (0.27755575615629 in your example) or use the bcmath extension, although for monetary values you should go perfectly fine with using round(...,2) on your final results Anthony Tippett wrote: btw, thanks for your response. I'm not sure as if I understand why. It's not like I'm using a very precise number when dealing with the hundreths place. Even without the multiplication the number gets messed up. eg. $a = 17.00; $a+= 1.10; $a+= 0.32; $a+= 0.07; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) I'm just trying to add money amounts? Can I not rely on floats to do this? Richard Lynch wrote: Floats are NEVER going to be coming out even reliably. You'll have to check if the difference is less than X for whatever number X you like. Or you can look at something like BC_MATH where precision can be carried out as far as you like... But what you are seeing is to be expected. That's just the way computers work, basically. On Mon, April 4, 2005 5:07 pm, Anthony Tippett said: Ok i've narrowed it down a little bit but still can't figure it out.. Here's the code and what I get for the output. Does anyone know what's going on? Can someone else run it on their computer and see if they get the same results? ?php $a = 17.00 * 1; $a+= 1.10 * 1; $a+= 0.32 * 1; $a+= 0.07 * 1; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) ? Anthony Tippett wrote: I'm having trouble figuring out why subtraction of two floats are giving me a very small number. I'm thinking it has something to do with the internals of type casting, but i'm not sure. If anyone has seen this or can give me some suggestions, please. I have 2 variables that go through a while loop and are added/subtracted/ multipled. InvAmt and InvPay are shown as floats but when they are subtracted, they give me a really small number // code var_dump($InvAmt); var_dump($InvPay); var_dump($InvAmt-$InvPay); // output float(18.49) float(18.49) float(2.1316282072803E-14) -- 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] Help! mod_php4 upgrade breaks GD!
On Saturday 02 April 2005 02:46, [EMAIL PROTECTED] wrote: No clue why it couldn't find libjpeg, but I then tried adding: --with-zlib-dir=/usr/include (AND) --with-jpeg-dir=/usr/local/include/ (the header files are there) That ought to be: --with-zlib-dir=/usr --with-jpeg-dir=/usr/local -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with SQL Query String
[snip] $sql = INSERT INTO tblname (USERID,FULLNAME,SSN,STARTDATE) VALUES (trim($row[USERID]),trim($row[FULLNAME]),trim($row[SSNO]),trim($row[STAR TDAT E])); [/snip] Time to quote and concatenate and make pretty... $sql = INSERT INTO tblname (USERID,FULLNAME,SSN,STARTDATE) ; $sql .= VALUES ( ; $sql .= ' . trim($row['USERID']) . ', ; $sql .= ' . trim($row['FULLNAME']) . ', ; $sql .= ' . trim($row['SSNO']) . ', ; $sql .= ' . trim($row['STARTDATE']) . ' ; $sql .= ) ; This will make things easier to maintain as well. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with SQL Query String
You should not just give him the code but rather tell him why. 1. trim() is a php function. MySQL does not know what to do with it. You need to place it 'outside' of the sql. You can also do something like this: $userid = trim($row['USERID']); Then use $userid in your sql. 2. Items in arrays must be in quotes. jzf Jay Blanchard wrote: [snip] $sql = INSERT INTO tblname (USERID,FULLNAME,SSN,STARTDATE) VALUES (trim($row[USERID]),trim($row[FULLNAME]),trim($row[SSNO]),trim($row[STAR TDAT E])); [/snip] Time to quote and concatenate and make pretty... $sql = INSERT INTO tblname (USERID,FULLNAME,SSN,STARTDATE) ; $sql .= VALUES ( ; $sql .= ' . trim($row['USERID']) . ', ; $sql .= ' . trim($row['FULLNAME']) . ', ; $sql .= ' . trim($row['SSNO']) . ', ; $sql .= ' . trim($row['STARTDATE']) . ' ; $sql .= ) ; This will make things easier to maintain as well. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with SQL Query String
[snip] You should not just give him the code but rather tell him why. 1. trim() is a php function. MySQL does not know what to do with it. You need to place it 'outside' of the sql. You can also do something like this: $userid = trim($row['USERID']); Then use $userid in your sql. 2. Items in arrays must be in quotes. [/snip] Ya'll bitch when I make them RTFM, ya'll bitch when I do codewhat's a guy to do? j/k Actually http://dev.mysql.com/doc/mysql/en/string-functions.html shows that MySQL also has a trim function which could be applied thusly; $sql = INSERT INTO tblname (USERID,FULLNAME,SSN,STARTDATE) ; $sql .= VALUES ( ; $sql .= TRIM(' . $row['USERID'] . '), ; $sql .= TRIM(' . $row['FULLNAME'] . '), ; $sql .= TRIM(' . $row['SSNO'] . '), ; $sql .= TRIM(' . $row['STARTDATE'] . ') ; $sql .= ) ; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with SQL Query String
Jay Blanchard wrote: Ya'll bitch when I make them RTFM, ya'll bitch when I do codewhat's a guy to do? j/k Don't get married? ;) -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with SQL Query String
Ave, Thanks a lot folks. I did actually mention that doing something like $userid = trim($row['USERID']); And then using those variables in my SQL statement would work... The only reason I chose to make this post however and not do that was because I wanted to know if it can be done the other way. I do understand though that using the PHP trim() function in an SQL statemnt won't work. However the new snip about mySQL having it's own TRIM() function is also pretty cool. Thanks again all, Rahul S. Johari Coordinator, Internet Administration Informed Marketing Services Inc. 251 River Street Troy, NY 12180 Tel: (518) 266-0909 x154 Fax: (518) 266-0909 Email: [EMAIL PROTECTED] http://www.informed-sources.com On 3/31/05 10:30 AM, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] You should not just give him the code but rather tell him why. 1. trim() is a php function. MySQL does not know what to do with it. You need to place it 'outside' of the sql. You can also do something like this: $userid = trim($row['USERID']); Then use $userid in your sql. 2. Items in arrays must be in quotes. [/snip] Ya'll bitch when I make them RTFM, ya'll bitch when I do codewhat's a guy to do? j/k Actually http://dev.mysql.com/doc/mysql/en/string-functions.html shows that MySQL also has a trim function which could be applied thusly; $sql = INSERT INTO tblname (USERID,FULLNAME,SSN,STARTDATE) ; $sql .= VALUES ( ; $sql .= TRIM(' . $row['USERID'] . '), ; $sql .= TRIM(' . $row['FULLNAME'] . '), ; $sql .= TRIM(' . $row['SSNO'] . '), ; $sql .= TRIM(' . $row['STARTDATE'] . ') ; $sql .= ) ; -- 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] Help with SQL Query String
well...i would have told him to go pound sand...the php manual is great and so is the MySQL manual. People are just lazy. [/snip] Ya'll bitch when I make them RTFM, ya'll bitch when I do codewhat's a guy to do? j/k Actually http://dev.mysql.com/doc/mysql/en/string-functions.html shows that MySQL also has a trim function which could be applied thusly; $sql = INSERT INTO tblname (USERID,FULLNAME,SSN,STARTDATE) ; $sql .= VALUES ( ; $sql .= TRIM(' . $row['USERID'] . '), ; $sql .= TRIM(' . $row['FULLNAME'] . '), ; $sql .= TRIM(' . $row['SSNO'] . '), ; $sql .= TRIM(' . $row['STARTDATE'] . ') ; $sql .= ) ; -- 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] Help with SQL Query String
On 3/31/05 12:45 PM, Joseph Connolly [EMAIL PROTECTED] wrote: well...i would have told him to go pound sand...the php manual is great and so is the MySQL manual. People are just lazy. Ave, Pound sand .. Interesting. And yes, both the manuals are great, and people are extremely lazy and purposely idiotic, nonsensical and absurdly inconclusive of the inadequacies of their lifeless brains. Have an awesome day. PS: Jay.. The code works great... Thanks a ton again! Rahul S. Johari Coordinator, Internet Administration Informed Marketing Services Inc. 251 River Street Troy, NY 12180 Tel: (518) 266-0909 x154 Fax: (518) 266-0909 Email: [EMAIL PROTECTED] http://www.informed-sources.com [/snip] Ya'll bitch when I make them RTFM, ya'll bitch when I do codewhat's a guy to do? j/k Actually http://dev.mysql.com/doc/mysql/en/string-functions.html shows that MySQL also has a trim function which could be applied thusly; $sql = INSERT INTO tblname (USERID,FULLNAME,SSN,STARTDATE) ; $sql .= VALUES ( ; $sql .= TRIM(' . $row['USERID'] . '), ; $sql .= TRIM(' . $row['FULLNAME'] . '), ; $sql .= TRIM(' . $row['SSNO'] . '), ; $sql .= TRIM(' . $row['STARTDATE'] . ') ; $sql .= ) ; -- 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] HELP!
-Original Message- From: [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 30, 2005 11:46 AM To: php-general@lists.php.net Cc: php-general@lists.php.net Why to AND cc? Would somebone give me a example of regulation expression to check account(or money) type which start with $. For example, $65,786.00 Same question was asked yesterday? $str = $65,786.00; if(ereg(^([\$]([0-9]+,)?[0-9]+\.[0-9]+),$str, $pricetag)) print we found a price tag: $pricetag[1]; else print no prices found; This is untested, the ([0-9]+,)? Means that there _may_ be digits and then a komma, but its not necessary, threfore $786.00 and $1.00 matches too. The () around all expressions means, that we save whatever is matched into $pricetag -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper
RE: [PHP] HELP , HELP ,HELP
wangchq mailto:[EMAIL PROTECTED] on Tuesday, March 29, 2005 4:50 PM said: Hi; Hello. I use this regulation expression to check account(money)type, but it does not work. That's regular expression. You were close. :P if(eregi(^\$[0-9]+\,[0-9]+\.[0-9]+,$set,$account)){ $reg_account=$account[1]; } else $reg_account=-1; Give some examples of the data you are feeding your regex so we can see where you are going wrong. Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP , HELP ,HELP
On Tue, March 29, 2005 4:49 pm, wangchq said: if(eregi(^\$[0-9]+\,[0-9]+\.[0-9]+,$set,$account)){ For starters: PHP use \ as an escape character for $ inside of Regex uses \ as an escape character for $ as a literal rather than line-end character. So your \$ should be \\\$, because PHP will eat the \\ and turn that into \ and then PHP will eat the \$ and turn that into $, and then you'll be passing \$ to Regex. As it stands now, your Regular expression is: ^$[0-9+... which is basically an invalid expression, as it has a bunch of crap trailing after the new-line ($) symbol. Disclaimer: I'm *NOT* good at Regex. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! configure Apache as a proxy
[EMAIL PROTECTED] wrote: I configured a Apache server as a proxy. But it's very slow. when I use this server connect internet it is NOT so slow. I think it ss because,my config has some error! Who can help me? This is a PHP programming list, not an Apache list. Ask in the Apache list to get better responses. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! configure Apache as a proxy
On Tue, March 22, 2005 3:30 pm, [EMAIL PROTECTED] said: I configured a Apache server as a proxy. But it's very slow. when I use this server connect internet it is NOT so slow. I think it ss because,my config has some error! Who can help me? WILD GUESS You've got Apache configured to do a reverse DNS lookup to see the domain name of the visitor... Only now it's trying to find a domain name for 192.168.2.100 which is not in your /etc/hosts file and ain't gonna show up in DNS records any time soon... Note that I don't really understand any of this proxy stuff you've done. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with dates
Dear Jochem and all the others who have offered help, Thank you all for your assistance! Thanks to all of you I have been able to reach the next step in the design process! Thanks ever so much! Most sincerely, Kevin Jochem Maas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Kevin wrote: Dear mr. Maas, no need for 'mr' :-) First of all my appologies for taking so long to respond. I had a family death to attend to. my condolences. there is no need to apologise in any case. ... why is OBC relevant, I read later on that you take the start of egyptian civilization as zero. is that not much earlier. Well it's relevant to make a baseline so that I can calculate the difference from then until now. That's the only reason thusfar. whats the structure of the egyptian|rpg calendar? A year consists of 769 days, 13 months of 63 days a month, except for month 13 which has 14 days. Every month has 7 weeks of 9 days, of course month 13 is the exception. A day is 24 hours. a few thoughts: 1. you have a date in both calendars which represent the same day? and/or rather what is day zero in the egyptian calendar in the gregorian calendar? 2. maybe you should store the date internally as number of days since zero, where zero is the first day on the egyptian calendar .. er, checking this thread again, Richard Lynch puts it better than I can so I'll just let you read his answer (again?) and hope it helps! oh one last thing: I notice that in the function you posted you did this: # Calculating the year in Egypt. $yr_Egypt = floor($EgyptianDays / 769); # Calculating the Month in Egypt. $mnt_Egypt = round( ($EgyptianDays-($yr_Egypt*769)) / 63 ); # Calculating the Day in Egypt. $dy_Egypt = round( $EgyptianDays - (($yr_Egypt * 769) + ($mnt_Egypt * 63)) ); # Filling the date array variable with the day, month and year of the Egyptian calendar. $ec_date[Day] = $dy_Egypt; $ec_date[Month] = $mnt_Egypt; $ec_date[Year] = $yr_Egypt; # Returning the Calculated date. return $ec_date; which could be written more succinctly as: /* Calculating the year,month,day in Egypt and returning. */ return array ( Year = ($y = floor( $EgyptianDays / 769 )), Month = ($m = round( ($EgyptianDays - ($y * 769)) / 63 )), Day = round( $EgyptianDays - (($y * 769) + ($m * 63)) ), ); that might inspire you to use less variables in your code, which is a good thing - but in this case completely beside the point. whats less beside the point is that you use floor() for the year and round() for the day and month, I wonder if it helps if you use floor() for all 3? beware of floating point rounding errors, compare: ?php $EgyptianDays = 10345; var_dump( array( Year = ($y = floor( $EgyptianDays / 769 )), Month = ($m = floor( ($EgyptianDays - ($y * 769)) / 63 )), Day = floor( $EgyptianDays - (($y * 769) + ($m * 63)) ), ), array( Year = ($y = floor( $EgyptianDays / 769 )), Month = ($m = round( ($EgyptianDays - ($y * 769)) / 63 )), Day = round( $EgyptianDays - (($y * 769) + ($m * 63)) ), ) ); ? kind regards, Jochem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with dates
Kevin wrote: Dear mr. Maas, no need for 'mr' :-) First of all my appologies for taking so long to respond. I had a family death to attend to. my condolences. there is no need to apologise in any case. ... why is OBC relevant, I read later on that you take the start of egyptian civilization as zero. is that not much earlier. Well it's relevant to make a baseline so that I can calculate the difference from then until now. That's the only reason thusfar. whats the structure of the egyptian|rpg calendar? A year consists of 769 days, 13 months of 63 days a month, except for month 13 which has 14 days. Every month has 7 weeks of 9 days, of course month 13 is the exception. A day is 24 hours. a few thoughts: 1. you have a date in both calendars which represent the same day? and/or rather what is day zero in the egyptian calendar in the gregorian calendar? 2. maybe you should store the date internally as number of days since zero, where zero is the first day on the egyptian calendar .. er, checking this thread again, Richard Lynch puts it better than I can so I'll just let you read his answer (again?) and hope it helps! oh one last thing: I notice that in the function you posted you did this: # Calculating the year in Egypt. $yr_Egypt = floor($EgyptianDays / 769); # Calculating the Month in Egypt. $mnt_Egypt = round( ($EgyptianDays-($yr_Egypt*769)) / 63 ); # Calculating the Day in Egypt. $dy_Egypt = round( $EgyptianDays - (($yr_Egypt * 769) + ($mnt_Egypt * 63)) ); # Filling the date array variable with the day, month and year of the Egyptian calendar. $ec_date[Day] = $dy_Egypt; $ec_date[Month] = $mnt_Egypt; $ec_date[Year] = $yr_Egypt; # Returning the Calculated date. return $ec_date; which could be written more succinctly as: /* Calculating the year,month,day in Egypt and returning. */ return array ( Year = ($y = floor( $EgyptianDays / 769 )), Month = ($m = round( ($EgyptianDays - ($y * 769)) / 63 )), Day = round( $EgyptianDays - (($y * 769) + ($m * 63)) ), ); that might inspire you to use less variables in your code, which is a good thing - but in this case completely beside the point. whats less beside the point is that you use floor() for the year and round() for the day and month, I wonder if it helps if you use floor() for all 3? beware of floating point rounding errors, compare: ?php $EgyptianDays = 10345; var_dump( array( Year = ($y = floor( $EgyptianDays / 769 )), Month = ($m = floor( ($EgyptianDays - ($y * 769)) / 63 )), Day = floor( $EgyptianDays - (($y * 769) + ($m * 63)) ), ), array( Year = ($y = floor( $EgyptianDays / 769 )), Month = ($m = round( ($EgyptianDays - ($y * 769)) / 63 )), Day = round( $EgyptianDays - (($y * 769) + ($m * 63)) ), ) ); ? kind regards, Jochem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP TO GET OUT OF PHP MAILING LIST
I did not subscribe to it in the first place There goes that nefarious PHP-General again, randomly subscribing unsuspecting innocents as part of its evil master plan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with dates
Dear mr. Maas, First of all my appologies for taking so long to respond. I had a family death to attend to. I will respond to the message in message. Yours, Kevin Jochem Maas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] ... Why re-invent the wheel? It's part of a game. In the RPG there are dates which the players would like to be able to convert from our calendar to that one, and back again.. In order to do that I need to find the exact days since the year 0 BC/AD. why is OBC relevant, I read later on that you take the start of egyptian civilization as zero. is that not much earlier. Well it's relevant to make a baseline so that I can calculate the difference from then until now. That's the only reason thusfar. whats the structure of the egyptian|rpg calendar? A year consists of 769 days, 13 months of 63 days a month, except for month 13 which has 14 days. Every month has 7 weeks of 9 days, of course month 13 is the exception. A day is 24 hours. However, the functions php provides only allow up to the unix epoch. Could you guys give me some pointers on how to accomplish this, accurately? Take a look at the MySQL date ranges -- They may have a data type that allows for more than just 1/1/1970 to 3/??/2038 If not, consider using PostgreSQL which has VERY extensive and flexible date support, for ranges MUCH larger than 0 BC/AD. http://postgresql.org I believe PostgreSQL even supports time scales on the order of geological events and for astronomical purposes, though not with day accuracy. +1 on using a DB to calculate and format dates on this one :-) I'm guessing Kevins probably written an SQL statement before and he's already proved he can RTFPM (P for PHP) I am assuming that by accurately you mean to the nearest day since you spoke of exact days, right? Aye.. it's nearest day, and according to calculations should have repeatable results. So what is date X today should also be it tomorrow (after the calculations of course). That's what i've noticed so far. when I add a date and convert it and then convert it back it is a different date. show us some code :-) At the end of the message code will be provided. But you didn't define how far into the future you need to go. Current time? A few years out? Stardates from Star Trek? You have to specify a start date, end date, and accuracy to choose a correct calendar system. It's mostly the past. The RPG is set in Egypt and the beginning of the society in egypt has been taken as year 0. The start date I think is obvious, but I do not understand an end date of a calendar.. Perhaps I'm just blond.. but could you perhaps explain that one? I must be blond, I don't even grok that question :-/ WEll I don't understand why an end date is important or what is meant with accuracy. The term being blond is, at least in the Netherlands a dumb blond, so I made it so that when I am dumb or anything, I'm blond (which in fact I am - dark blond) :-P. rgds, jochem Code: function get_date_ec($EarthDay, $EarthMonth, $EarthYear) { $DayOfYear = 0; # Setting internal date variables. $intDay = intval($EarthDay); $intMonth = intval($EarthMonth); $intYear = intval($EarthYear); $array_MonthDays[1] = intval(31);// January $array_MonthDays[3] = intval(31);// March $array_MonthDays[4] = intval(30);// April $array_MonthDays[5] = intval(31);// May $array_MonthDays[6] = intval(30);// June $array_MonthDays[7] = intval(31);// July $array_MonthDays[8] = intval(31);// August $array_MonthDays[9] = intval(30);// September $array_MonthDays[10] = intval(31); // October $array_MonthDays[11] = intval(30); // November $array_MonthDays[12] = intval(31); // December # Making a few Leap Year Checks $RETURN_CHECK_LEAP_YEAR = check_leap_year($intYear); if ($RETURN_CHECK_LEAP_YEAR == TRUE) { $array_MonthDays[2] = intval(29); // february } else { $array_MonthDays[2] = intval(28); // february }; if ($RETURN_CHECK_LEAP_YEAR == 1) { #check date if leapdate has passed. echo $intYear is a LEAP YEAR br ; if (($intDay = 29) AND ($intMonth = 2)) { echo LEAP DATE HAS PASSED br; for ($n=1 ; $n$intMonth ; $n++) { $DayOfYear = $DayOfYear + $array_MonthDays[$n]; $testje = $array_MonthDays[$n]+$intDay; echo testje: $testje br; }; $DayOfYear = $DayOfYear + $intDay; echo $DayOfYear Br; $intTotalDaysSinceEpoch = ($intYear * 365) + ($intYear / 4) + $DayOfYear; echo $intTotalDaysSinceEpoch = ($intYear*365) + ($intYear /4) + $DayOfYear br; echo $intTotalDaysSinceEpoch = . $intYear*365 . + . ($intYear /4) . + $DayOfYear brbr; } else { echo LEAP DATE HAS NOT YET PASSED..br; for ($n=1 ; $n$intMonth ; $n++) {
Re: [PHP] Help with dates
Mr Lynch, Thanks a lot for your help so far! I will answer or respond in message. Yours, Kevin Richard Lynch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Kevin wrote: Right now I'm working on a script that would calculate dates from one calendar to another. The normal calendar we use and a newly invented one. [shudder] There are already WAY too many calendar systems. Inventing a new one is probably not such a good plan... Why re-invent the wheel? It's part of a game. In the RPG there are dates which the players would like to be able to convert from our calendar to that one, and back again.. In order to do that I need to find the exact days since the year 0 BC/AD. However, the functions php provides only allow up to the unix epoch. Could you guys give me some pointers on how to accomplish this, accurately? Take a look at the MySQL date ranges -- They may have a data type that allows for more than just 1/1/1970 to 3/??/2038 If not, consider using PostgreSQL which has VERY extensive and flexible date support, for ranges MUCH larger than 0 BC/AD. http://postgresql.org I believe PostgreSQL even supports time scales on the order of geological events and for astronomical purposes, though not with day accuracy. I am assuming that by accurately you mean to the nearest day since you spoke of exact days, right? Aye.. it's nearest day, and according to calculations should have repeatable results. So what is date X today should also be it tomorrow (after the calculations of course). That's what i've noticed so far. when I add a date and convert it and then convert it back it is a different date. But you didn't define how far into the future you need to go. Current time? A few years out? Stardates from Star Trek? You have to specify a start date, end date, and accuracy to choose a correct calendar system. It's mostly the past. The RPG is set in Egypt and the beginning of the society in egypt has been taken as year 0. The start date I think is obvious, but I do not understand an end date of a calendar.. Perhaps I'm just blond.. but could you perhaps explain that one? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with dates
... Why re-invent the wheel? It's part of a game. In the RPG there are dates which the players would like to be able to convert from our calendar to that one, and back again.. In order to do that I need to find the exact days since the year 0 BC/AD. why is OBC relevant, I read later on that you take the start of egyptian civilization as zero. is that not much earlier. whats the structure of the egyptian|rpg calendar? However, the functions php provides only allow up to the unix epoch. Could you guys give me some pointers on how to accomplish this, accurately? Take a look at the MySQL date ranges -- They may have a data type that allows for more than just 1/1/1970 to 3/??/2038 If not, consider using PostgreSQL which has VERY extensive and flexible date support, for ranges MUCH larger than 0 BC/AD. http://postgresql.org I believe PostgreSQL even supports time scales on the order of geological events and for astronomical purposes, though not with day accuracy. +1 on using a DB to calculate and format dates on this one :-) I'm guessing Kevins probably written an SQL statement before and he's already proved he can RTFPM (P for PHP) I am assuming that by accurately you mean to the nearest day since you spoke of exact days, right? Aye.. it's nearest day, and according to calculations should have repeatable results. So what is date X today should also be it tomorrow (after the calculations of course). That's what i've noticed so far. when I add a date and convert it and then convert it back it is a different date. show us some code :-) But you didn't define how far into the future you need to go. Current time? A few years out? Stardates from Star Trek? You have to specify a start date, end date, and accuracy to choose a correct calendar system. It's mostly the past. The RPG is set in Egypt and the beginning of the society in egypt has been taken as year 0. The start date I think is obvious, but I do not understand an end date of a calendar.. Perhaps I'm just blond.. but could you perhaps explain that one? I must be blond, I don't even grok that question :-/ rgds, jochem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with dates
Jochem Maas wrote: It's mostly the past. The RPG is set in Egypt and the beginning of the society in egypt has been taken as year 0. The start date I think is obvious, but I do not understand an end date of a calendar.. Perhaps I'm just blond.. but could you perhaps explain that one? I must be blond, I don't even grok that question :-/ rgds, jochem It comes down to the amount of information that you can store in memory. Consider: my start date is 6000 BC. And I believe that the universe will end around, say, 320 Quadrillion AD. And I want accuracy in my calendar (that is I can convert time) to the nearest second. Good luck finding a computer that can easily handle that! Heck, good luck even trying to store all of the seconds of the calendar as bytes on the computer! This problem is related to the Y2K bug. Back when hard drive storage / memory was more expensive they needed to find ways to express more information with less technology. So they traded accuracy for efficiency and dates were stored with two digits in each year. It was ok though because the expected life of the program wasn't supposed to be beyond 2000. So getting back to *this* problem... what exactly is the relevant span of time? Will game time in the RPG extend for thousands of years? Hundreds of thousands? Would it really be ancient Egypt once you make it past 0 BC? So decide on an upper limit for the game calendar. And decide the accuracy you need (nearest day, etc.) and then you can create functions that will do the necessary date conversions. It can be in PHP or in the DB itself... but that's the next step in the decision process. :) -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-generalw=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins signature.asc Description: OpenPGP digital signature
Re: [PHP] Help with dates
Jason Barnett wrote: Jochem Maas wrote: It's mostly the past. The RPG is set in Egypt and the beginning of the society in egypt has been taken as year 0. The start date I think is obvious, but I do not understand an end date of a calendar.. Perhaps I'm just blond.. but could you perhaps explain that one? I must be blond, I don't even grok that question :-/ rgds, jochem It comes down to the amount of information that you can store in memory. Consider: my start date is 6000 BC. And I believe that the universe will end around, say, 320 Quadrillion AD. And I want accuracy in my calendar (that is I can convert time) to the nearest second. Good luck finding a computer that can easily handle that! Heck, good luck even trying to store all of the seconds of the calendar as bytes on the computer! er...grok. thanks Jason :-) This problem is related to the Y2K bug. Back when hard drive storage / memory was more expensive they needed to find ways to express more information with less technology. So they traded accuracy for efficiency and dates were stored with two digits in each year. It was ok though because the expected life of the program wasn't supposed to be beyond 2000. So getting back to *this* problem... what exactly is the relevant span of time? Will game time in the RPG extend for thousands of years? Hundreds of thousands? Would it really be ancient Egypt once you make it past 0 BC? egypt is pre 0BC, even Discovery Channel admits that :-) (0BC is 2005 years ago) So decide on an upper limit for the game calendar. And decide the accuracy you need (nearest day, etc.) and then you can create functions that will do the necessary date conversions. It can be in PHP or in the DB itself... but that's the next step in the decision process. :) -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-generalw=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with dates
Right now I'm working on a script that would calculate dates from one calendar to another. The normal calendar we use and a newly invented one. [shudder] There are already WAY too many calendar systems. Inventing a new one is probably not such a good plan... Why re-invent the wheel? It's part of a game. In the RPG there are dates which the players would like to be able to convert from our calendar to that one, and back again.. You'll be way better off finding an existing calendar that fits your criteria than inventing a new one. But you didn't define how far into the future you need to go. Current time? A few years out? Stardates from Star Trek? You have to specify a start date, end date, and accuracy to choose a correct calendar system. It's mostly the past. The RPG is set in Egypt and the beginning of the society in egypt has been taken as year 0. The start date I think is obvious, but I do not understand an end date of a calendar.. Perhaps I'm just blond.. but could you perhaps explain that one? Here's your IDEAL calendar: Your start date is 0 BC. So let's make that be represented by: 0 Day 1 is, errr, December 26, 0 BC, represented by: 1 Day 2, December 27, 0 BC, represented by: 3 . . . You can now calculate what's 2 billion+ (0x to be precise) days later, and that would be the last date you could conveniently represent in a 32-bit integer. Do you expect the characters/events in your RPG to extend beyond 2 billion days from December 25, 0 BC? If so, then a 32-bit integer, one integer per day, simply won't cut it. If not, then the above is an ideal date system. Now, that was your ideal system. Find a system that comes close to that. http://mysql.com http://postgresql.org PS Historians are ready to shoot me for using 12/25/ as 0 BC, but that's their problem, not mine. It's an RPG. We're not looking for historical accuracy here! -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with dates
Kevin wrote: Right now I'm working on a script that would calculate dates from one calendar to another. The normal calendar we use and a newly invented one. [shudder] There are already WAY too many calendar systems. Inventing a new one is probably not such a good plan... Why re-invent the wheel? In order to do that I need to find the exact days since the year 0 BC/AD. However, the functions php provides only allow up to the unix epoch. Could you guys give me some pointers on how to accomplish this, accurately? Take a look at the MySQL date ranges -- They may have a data type that allows for more than just 1/1/1970 to 3/??/2038 If not, consider using PostgreSQL which has VERY extensive and flexible date support, for ranges MUCH larger than 0 BC/AD. http://postgresql.org I believe PostgreSQL even supports time scales on the order of geological events and for astronomical purposes, though not with day accuracy. I am assuming that by accurately you mean to the nearest day since you spoke of exact days, right? But you didn't define how far into the future you need to go. Current time? A few years out? Stardates from Star Trek? You have to specify a start date, end date, and accuracy to choose a correct calendar system. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with dates
On Sunday 06 March 2005 22:11, Kevin wrote: Right now I'm working on a script that would calculate dates from one calendar to another. The normal calendar we use and a newly invented one. In order to do that I need to find the exact days since the year 0 BC/AD. However, the functions php provides only allow up to the unix epoch. manual Calendar Functions -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with dates
Thank you.. duh... quite useful... not... Where do you think I check first? Yours, Kevin Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sunday 06 March 2005 22:11, Kevin wrote: Right now I'm working on a script that would calculate dates from one calendar to another. The normal calendar we use and a newly invented one. In order to do that I need to find the exact days since the year 0 BC/AD. However, the functions php provides only allow up to the unix epoch. manual Calendar Functions -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with REGEXP please
Hello Shaun, Friday, March 4, 2005, 12:54:34 PM, you wrote: S Please could someone tell me how i can extract the information from S a string that is after 'ID_' and before '_FN' ?php $myString = ID_723456ABc_FN; preg_match(/ID_([a-z0-9]+)_FN/i,$myString, $extracted); echo $extracted[1]; ? This will match any upper or lowercase letter and number. If you have other characters like _ , etc, then you'll need to put those in the [a-z0-9_,] too. -- Leif (TB lists moderator and fellow end user). Using The Bat! 3.0.2.3 Rush under Windows XP 5.1 Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with REGEXP please
Shaun mailto:[EMAIL PROTECTED] on Friday, March 04, 2005 11:55 AM said: Please could someone tell me how i can extract the information from a string that is after 'ID_' and before '_FN' Get the RegExCoach. It'll be your best friend. Try: /ID_(.*)_FN/ Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with REGEXP please
Shaun wrote: Hi, Please could someone tell me how i can extract the information from a string that is after 'ID_' and before '_FN' Thanks for your help. preg_match ( /ID_(.*)_FN/, $string, $result ) The data will be in $result[1] if there is a match. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help Required: How to call .vbs file from .php file?
[snip] I am in desperate need of some help in calling a vbscript file from a php file. [/snip] http://www.php.net/exec -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with adding
Jay Fitzgerald wrote: I have messed with this for a couple of days and cant get it right. Maybe I need sleep :-) The code below is echoing the qty correctly (10, 5, 25) for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; echo $qty . 'br /'; } The question is, how would I take add each of these numbers (10+5+25)? $sum = 0 // init the var for ($i = 1; $i = $sendnum; $i++) { $sum =+ intval($_POST['qty'.$i]); } echo $sumbr /; Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] help with adding
-Original Message- From: Jay Fitzgerald [mailto:[EMAIL PROTECTED] Sent: Thursday, February 24, 2005 9:39 AM To: php-general@lists.php.net Subject: [PHP] help with adding I have messed with this for a couple of days and cant get it right. Maybe I need sleep :-) The code below is echoing the qty correctly (10, 5, 25) for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; echo $qty . 'br /'; } The question is, how would I take add each of these numbers (10+5+25)? Any help is appreciated. $total = 0; for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; echo $qty . 'br /'; $total = $total + $qty; } Hope that helps. Jesse R. Castro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with adding
for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; $total = $total + $qty; echo $qty . 'br /'; } echo Total $total; ?php /* Stephen Johnson c | eh The Lone Coder http://www.thelonecoder.com [EMAIL PROTECTED] 562.924.4454 (office) 562.924.4075 (fax) continuing the struggle against bad code */ ? From: Jay Fitzgerald [EMAIL PROTECTED] Organization: Bayou Internet Reply-To: [EMAIL PROTECTED] Date: Thu, 24 Feb 2005 09:39:16 -0600 To: php-general@lists.php.net Subject: [PHP] help with adding The code below is echoing the qty correctly (10, 5, 25) for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; echo $qty . 'br /'; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with adding
Hello Jay, Thursday, February 24, 2005, 8:39:16 AM, you wrote: J I have messed with this for a couple of days and cant get it right. J Maybe I need sleep :-) J The question is, how would I take add each of these numbers (10+5+25)? for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; $tot += $qty; echo $qty . ' --- Total so far is: ' . $tot . 'br /'; } -- Leif (TB lists moderator and fellow end user). Using The Bat! 3.0.2.3 Rush under Windows XP 5.1 Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with adding
You could try: for ($i = 1; isset( $_POST['qty'.$i] ); $i++) { $qty = $_POST['qty'.$i]; $total .= $qty; echo $qty . 'br /'; } echo $total; Dan T On Feb 24, 2005, at 8:39 AM, Jay Fitzgerald wrote: I have messed with this for a couple of days and cant get it right. Maybe I need sleep :-) The code below is echoing the qty correctly (10, 5, 25) for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; echo $qty . 'br /'; } The question is, how would I take add each of these numbers (10+5+25)? Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with adding
Try this: $num=0; for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; $num=$num+ $qty ; } echo $num; Jay Fitzgerald wrote: I have messed with this for a couple of days and cant get it right. Maybe I need sleep :-) The code below is echoing the qty correctly (10, 5, 25) for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; echo $qty . 'br /'; } The question is, how would I take add each of these numbers (10+5+25)? Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with adding
Jay Fitzgerald wrote: I have messed with this for a couple of days and cant get it right. Maybe I need sleep :-) The code below is echoing the qty correctly (10, 5, 25) for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; echo $qty . 'br /'; } The question is, how would I take add each of these numbers (10+5+25)? Search http://php.net for variable variables (Yes, really.) It will let you turn 'qty' . $i into a new variable and get its value. You probably should be using an ARRAY for qty anyway, though... input name=qty[product_id_47] input name=qty[product_id_83] input name=qty[product_id_99] Then you can use $_POST['qty'] as an array, and not mess around with variable variables. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help Required: How to call .vbs file from .php file?
lef1 wrote: I am in desperate need of some help in calling a vbscript file from a php file. I have searched high and low and have come up with nothing that will do it. I have found one example of a html file, which will call a vbscript file when the html file is double-clicked, but wont work if the file is viewd from the http://localhost. I really need a solution to this problem, any help you could offer would be appreciated greatly. If the VBSCript is in a web-server, you could use http://php.net/file to read its results. If it's using SSL or needs Cookies to authenticate, use http://php.net/curl If reading the results alone is insufficient, you may be able to compile the VBSCript into a COM object, and use PHP's COM extension to work with that. Finally, there's a fairly new Delphi4PHP or PHP4Delphi thingie and, like, maybe Delphi can call VBSCript somehow... I really don't know much about this one at all. Of course, re-writing the VBScript in PHP would probably be easiest... :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with adding
Hi there! I guess $sum =+ intval($_POST['qty'.$i]); should be $sum += intval($_POST['qty'.$i]); /G @varupiraten.se Jay Fitzgerald wrote: I have messed with this for a couple of days and cant get it right. Maybe I need sleep :-) The code below is echoing the qty correctly (10, 5, 25) for ($i = 1; $i = $sendnum; $i++) { $qty = $_POST['qty'.$i]; echo $qty . 'br /'; } The question is, how would I take add each of these numbers (10+5+25)? $sum = 0 // init the var for ($i = 1; $i = $sendnum; $i++) { $sum =+ intval($_POST['qty'.$i]); } echo $sumbr /; Any help is appreciated. -- 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] Help Required: How to call .vbs file from .php file?
Okay: You need to be explain yourself in a MUCH CLEARER manner. You want to 'call' a 'vbscript' from a php file. What exactly do you mean? Do you want to run server-side vbscript, or do you want to run client-side vbscript. Do you want to use asp-style vbscript to generate html, or do you want to use vbscript to manipulate the html that is already loaded. Iy looks like, since you are 'double-clicking' on a html file, that what you want is client-side vbscript. In this case, 'calling' the vbscript would be the same way as 'calling' javascript, or Jscript. Simply put it in script type=text/vbscript/script tags, and it would be 'called' similarly to javascript. Bare in mind that you cannot generally 'double-click' on a php file. You generally have to load it through a web server(eg apache, or IIS). As above, you need to restate your question. On Thu, 24 Feb 2005 14:05:21 +, lef1 [EMAIL PROTECTED] wrote: Hi, I am in desperate need of some help in calling a vbscript file from a php file. I have searched high and low and have come up with nothing that will do it. I have found one example of a html file, which will call a vbscript file when the html file is double-clicked, but wont work if the file is viewd from the http://localhost. I really need a solution to this problem, any help you could offer would be appreciated greatly. Thanks, Laura -- 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] help with adding
[EMAIL PROTECTED] wrote: Hi there! I guess $sum =+ intval($_POST['qty'.$i]); should be $sum += intval($_POST['qty'.$i]); yuo are corerct. ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help me
K Karthik wrote: i'd like to get a date from my database(mysql).and then show a combobox of calendar(date-month-year) with the retrieved data selected. can you help me doing this?? am new to php. http://www.google.com/search?q=PHP+date+combobox -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] help me
This is how I would do it, don't know if it is the best way. A. get the date out of the database Let's say $maindate is that date you retrieved from the database B. split up the date into several parts for day month and year The day as a number (dd): $day=date (j, strtotime($maindate)); The month as a number (mm): $month= date (m, strtotime($maindate)); The month as a number (yy): $year= date (Y, strtotime($maindate)); C. Now in your combobox you must do something like: select name=comboday ?PHP for($aday=01;$aday32;$aday++) //fill the combobox with the numbers 1-31 { echo('option value='.$aday.''); if($day==$aday) { //if the day from the database equals this aday then echo selected so that //day is selected in the combobox echo( selected); } echo(''.$aday.'/option'); } ? /select That should do the trick Greetz Reinhart -Oorspronkelijk bericht- Van: K Karthik [mailto:[EMAIL PROTECTED] Verzonden: woensdag 23 februari 2005 13:41 Aan: php-general@lists.php.net Onderwerp: [PHP] help me dear sir, i'd like to get a date from my database(mysql).and then show a combobox of calendar(date-month-year) with the retrieved data selected. can you help me doing this?? am new to php. thanks, karthikeyan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help me
http://www.php.net/date On Fri, 18 Feb 2005 12:07:14 +0530, K Karthik [EMAIL PROTECTED] wrote: i am so surprised for the immediate reply.thank you so much. i'll be thank ful again if you could help me finding the current date and time using php. thanks, karthik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Pablo M. Rivas. http://www.pmrivas.com http://www.r3soft.com.ar --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with SQL statement
On Thu, 2005-02-17 at 23:21, Jacques wrote: How can I determine which users have signed in and are still on-line during the first minute after they have signed in? My sql statement currently reads: SELECT * FROM tblusers WHERE usignedin = yes AND utimesignedin = (time() - 60) Hoe does one indicate seconds in a SQL statement? Can I use the time() function or should I use the now() function rather? Thanks Jacques I almost do not know where to begin. What database are you using? The functions you need to be looking at are going to be executed by the dbms not php. Look in the dbms docs for the time functions available. Are you really interested in users who logged in exactly 60 seconds ago ( you are using = afterall )? if course this also depends on what type of data is stored in utimesignedin if it is a timestamp with the resolution in seconds then you should be good to go with the whatever_database_function_returns_the_current_timestamp() - 60 deal. Bret -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help me
On Thu, 2005-02-17 at 19:11 +0530, K Karthik wrote: can u help me to use $_SERVER['remote_addr'] to find the IP address ? i am new to php. i also want to find what page of my site he is viewing ? print_r($_SERVER); what do you see? -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting Development * --- Now hosting Ruby on Rails Apps --- / -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with a query please - unable to error check!
Shaun wrote: I have a problem with a query, I get the following error message: 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 '' at line 23 If I echo the query to the screen and run the query to the database via SSH it executes correctly. Does anyone have any ideas on what else I can check for here? Check for the actual query you're using. If Query X gives the above error when run in PHP, then copy and pasting it into the command line will give the same error. Maybe you're not echoing/running the right query? Errors like that are normally caused by a variable being empty. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with a query please - unable to error check!
Shaun mailto:[EMAIL PROTECTED] on Wednesday, February 16, 2005 1:15 PM said: I have a problem with a query, I get the following error message: 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 '' at line 23 If I echo the query to the screen and run the query to the database via SSH it executes correctly. Does anyone have any ideas on what else I can check for here? Probably a typo somewhere. Please send code! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with a query please - unable to error check!
Could it be a quote-escaping problem? It would be easier to tell if you could show us the query and the code you're using. /Mattias Shaun wrote: Hi, I have a problem with a query, I get the following error message: 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 '' at line 23 If I echo the query to the screen and run the query to the database via SSH it executes correctly. Does anyone have any ideas on what else I can check for here? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help-regarding-file_get_contents
Does the server support passive FTP connections? Extracted from the PHP Manual: PHP 3, PHP 4, PHP 5. ftps:// since PHP 4.3.0 * ftp://example.com/pub/file.txt * ftp://user:[EMAIL PROTECTED]/pub/file.txt * ftps://example.com/pub/file.txt * ftps://user:[EMAIL PROTECTED]/pub/file.txt Allows read access to existing files and creation of new files via FTP. If the server does not support passive mode ftp, the connection will fail. See http://docs.php.net/en/wrappers.html. -Guillermo On Mon, 7 Feb 2005 12:46:25 -0800 (PST), vijayaraj nagarajan [EMAIL PROTECTED] wrote: hi john i am a php user... one help from you.. i could download the contents of an url from http:// sitesbut when i tried downloading the contents from an ftp site... i get this error... Warning: file_get_contents(): php_hostconnect: connect failed in /var/www/html/get.php on line 3 Warning: file_get_contents(ftp://ftp.ncbi.nih.gov/genbank/gbrel.txt): failed to open stream: FTP server reports 229 Entering Extended Passive Mode (|||50334|) in /var/www/html/get.php on line 3 This is the content of the retreived file... could you suggest me how to go about this... thanks for spending your valuable time... --- John Holmes [EMAIL PROTECTED] wrote: From: vijayaraj nagarajan [EMAIL PROTECTED] i would like to fetch the content of a url. and then would like to put in my page... dynamically refreshing it once in a day... is it possible to do this in php. i have used perl get url option and then parse the file, with the date and time function...to do this. $file = file_get_contents('http://www.domain.com/page.php'); Save $file locally and you have your copy. use cron to run the command once per day. __ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail -- 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] help needed on imagettftext()
Hi Marek Kilimajer, Thank You Marek it worked for me also. -Harish Rao K -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED] Sent: Thursday, January 27, 2005 9:19 PM To: Harish Rao K Cc: php-general@lists.php.net Subject: Re: [PHP] help needed on imagettftext() Harish Rao K wrote: Hello, While working with some CAPTCHA stuff I get the following error: Fatal error: Call to undefined function imagettftext(). I have compiled with GD support and all the supporting libraries (Freetype, TTF, jpeg, X11R6 etc). What am I missing? Below is the configure command that I have used. './configure' '--with-gd' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-pgsql' '--with-jpeg-dir=/usr/local/jpeg-6b' '--with-zlib-dir=/usr/local/zlib-1.2.1' '--enable-gd-native-ttf' '--with-png' '--with-ttf' '--with-freetype-dir=/usr/local/freetype-2.1.9' '--with-xpm-dir=/usr/X11R6' Thanks Regards, Harish Rao K, make clean make make install this helped me. I guess there are wrong dependencies in the Makefiles -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Nous Infosystems This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual(s) or entity(ies) named in the e-mail address. If you are not the intended recipient, please reply to the [EMAIL PROTECTED], so that arrangements can be made for proper delivery, and then please delete all copies and attachments.Any disclosure, copying, distribution, or reliance upon the contents of this e-mail, by any other than the intended recipients, is strictly prohibited. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with references?
Jon wrote: This script only outputs the top level. i.e. that script has syntax errors. ... $arFiles = array( array['file1']( array( ['path] = array( [0] = 'folder1', [1] = 'subfolder1' [2] = 'file1.ext' ), ['length'] = 5464, ['size'] = 8765 ), array['file2']( array( ['path] = array( [0] = 'folder2', [1] = 'subfolder2' [2] = 'file2.ext' ), ['length'] = 5464, ['size'] = 8765 ), array['file3']( array( ['path] = array( [0] = 'folder3', [1] = 'subfolder3' [2] = 'file3.ext' ), ['length'] = 5464, ['size'] = 8765 ) ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with references?
Here is one that does not throw an error but does not produce the desired results class dir { var $name; var $subdirs; var $files; var $num; var $prio; function dir($name,$num,$prio) { $this-name = $name; $this-num = $num; $this-prio = $prio; $this-files = array(); $this-subdirs = array(); } function addFile($file) { $this-files[] = $file; return $file; } function addDir($dir) { $this-subdirs[] = $dir; return $dir; } function findDir($name) { foreach($this-subdirs as $v){ if($v-name == $name) return $v; } return false; } function draw($parent) { echo('d.add('.$this-num.','.$parent.','.$this-name.\,.$this-prio.);\n); foreach($this-subdirs as $v) { $v-draw($this-num); On Sat, 2005-01-29 at 04:20 +0100, Jochem Maas wrote: Jon wrote: This script only outputs the top level. i.e. that script has syntax errors. ... $arFiles = array( array['file1']( array( ['path] = array( [0] = 'folder1', [1] = 'subfolder1' [2] = 'file1.ext' ), ['length'] = 5464, ['size'] = 8765 ), array['file2']( array( ['path] = array( [0] = 'folder2', [1] = 'subfolder2' [2] = 'file2.ext' ), ['length'] = 5464, ['size'] = 8765 ), array['file3']( array( ['path] = array( [0] = 'folder3', [1] = 'subfolder3' [2] = 'file3.ext' ), ['length'] = 5464, ['size'] = 8765 ) ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with references? again
OK, THIS one doesn't throw a syntax error ;) class dir { var $name; var $subdirs; var $files; var $num; var $prio; function dir($name,$num,$prio) { $this-name = $name; $this-num = $num; $this-prio = $prio; $this-files = array(); $this-subdirs = array(); } function addFile($file) { $this-files[] = $file; return $file; } function addDir($dir) { $this-subdirs[] = $dir; return $dir; } function findDir($name) { foreach($this-subdirs as $v){ if($v-name == $name) return $v; } return false; } function draw($parent) { echo('d.add('.$this-num.','.$parent.','.$this-name.\,.$this-prio.);\n); foreach($this-subdirs as $v) { $v-draw($this-num); } foreach($this-files as $v) if(is_object($v)) { echo(d.add(.$v-num.,.$this-num., \.$v-name.\,.$v-prio.);\n); } } } class file { var $name; var $prio; var $size; var $num; function file($name,$num,$size,$prio) { $this-name = $name; $this-num = $num; $this-size = $size; $this-prio = $prio; } } $arFiles = array ( 0 = array ( 'path' = array ( 0 = 'folder1', 1 = 'subfolder1', 2 = 'file1.ext' ), 'length' = 5464, 'size' = 8765 ), 1 = array ( 'path' = array ( 0 = 'folder2/', 1 = 'subfolder2/', 2 = 'file2.ext' ), 'length' = 5464, 'size' = 8765 ), 2 = array ( 'path' = array ( 0 = 'folder3/', 1 = 'subfolder3/', 2 = 'file3.ext' ), 'length' = 5464, 'size' = 8765 ) ); $prio = array(); for($i=0;$icount($arFiles);$i++) $prio[$i] = -1; $dirnum = count($arFiles); $tree = new dir(/,$dirnum,isset($prio[$dirnum])?$prio[$dirnum]:-1); foreach( $arFiles as $filenum = $file) { $depth = count($file['path']); $branch = $tree; for($i=0; $i $depth; $i++){ if ($i != $depth-1){ $d = $branch-findDir($file['path'][$i]); if($d) $branch = $d; else{ $dirnum++; $d = $branch-addDir(new dir($file['path'][$i], $dirnum, (isset($prio[$dirnum])?$prio[$dirnum]:-1))); $branch = $d; } }else $branch-addFile(new file($file['path'][$i]. (.$file['length'].),$filenum,$file['size'], $prio[$filenum])); } } $tree-draw(-1); On Sat, 2005-01-29 at 04:20 +0100, Jochem Maas wrote: Jon wrote: This script only outputs the top level. i.e. that script has syntax errors. ... $arFiles = array( array['file1']( array( ['path] = array( [0] = 'folder1', [1] = 'subfolder1' [2] = 'file1.ext' ), ['length'] = 5464, ['size'] = 8765 ), array['file2']( array( ['path] = array( [0] = 'folder2', [1] = 'subfolder2' [2] = 'file2.ext' ), ['length'] = 5464, ['size'] = 8765 ), array['file3']( array( ['path] = array( [0] = 'folder3', [1] = 'subfolder3' [2] = 'file3.ext' ), ['length'] = 5464, ['size'] = 8765 ) ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help needed on imagettftext()
Harish Rao K wrote: Hello, While working with some CAPTCHA stuff I get the following error: Fatal error: Call to undefined function imagettftext(). I have compiled with GD support and all the supporting libraries (Freetype, TTF, jpeg, X11R6 etc). What am I missing? Below is the configure command that I have used. './configure' '--with-gd' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-pgsql' '--with-jpeg-dir=/usr/local/jpeg-6b' '--with-zlib-dir=/usr/local/zlib-1.2.1' '--enable-gd-native-ttf' '--with-png' '--with-ttf' '--with-freetype-dir=/usr/local/freetype-2.1.9' '--with-xpm-dir=/usr/X11R6' Thanks Regards, Harish Rao K, make clean make make install this helped me. I guess there are wrong dependencies in the Makefiles -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help needed on imagettftext()
Harish Rao K wrote: While working with some CAPTCHA stuff I get the following error: Fatal error: Call to undefined function imagettftext(). I have compiled with GD support and all the supporting libraries (Freetype, TTF, jpeg, X11R6 etc). What am I missing? Check the log files from in the PHP source directory -- Often configure will seem to work fine, but have error messages buried in that zillion lines of output... And, as always, you might have forgotten to re-start apache. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with file not writing
Hi Marek, I don't see anything in the docs located http://us3.php.net/fopen to help. I changed it to w only but that made no difference. Can you please provide a more specific answer. THanks Code looks liks this: % class counter { var $log_file = 'counters/google_log.txt'; var $file = 'counters/google_counter.txt'; function counter() { $this-readFile(); $this-writeFile(); $this-writeLog(); } function readFile() { $hiti = fopen($this-file, r); while(!feof($hiti)){ $this-$hits .= fgets($hiti,128); } $this-$hits=1+$this-$hits; echo $this-$hits; fclose($hiti); } function writeFile() { $hito = fopen($this-file,w+); fputs($hito,$this-$hits); fclose($hito); } function writeLog() { $ip_address=$GLOBALS['HTTP_SERVER_VARS']['REMOTE_ADDR']; $date_stamp=date(F j, Y, g:i a); $log_entry=$date_stamp . : . $ip_address . \n ; echo TEST- . $log_entry ; $log = fopen($this-log_file,a); fputs($log,$this-$log_entry ); fclose($log); } } % -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with file not writing
Joey wrote: Hi Marek, Me? I did not send you anything :) Member variables in classes are NOT used this way: $this-$hits But this way: $this-hits I don't see anything in the docs located http://us3.php.net/fopen to help. I changed it to w only but that made no difference. Can you please provide a more specific answer. THanks Code looks liks this: % class counter { var $log_file = 'counters/google_log.txt'; var $file = 'counters/google_counter.txt'; function counter() { $this-readFile(); $this-writeFile(); $this-writeLog(); } function readFile() { $hiti = fopen($this-file, r); while(!feof($hiti)){ $this-$hits .= fgets($hiti,128); I also think you want just = above (no append) } $this-$hits=1+$this-$hits; echo $this-$hits; fclose($hiti); } function writeFile() { $hito = fopen($this-file,w+); fputs($hito,$this-$hits); fclose($hito); } function writeLog() { $ip_address=$GLOBALS['HTTP_SERVER_VARS']['REMOTE_ADDR']; $date_stamp=date(F j, Y, g:i a); $log_entry=$date_stamp . : . $ip_address . \n ; echo TEST- . $log_entry ; $log = fopen($this-log_file,a); fputs($log,$this-$log_entry ); fclose($log); } } % -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with file not writing
Joey wrote: $this-$hits .= fgets($hiti,128); Do global search and replace for '-$' and change it to '-' $this-$hits=1+$this-$hits; echo $this-$hits; fputs($hito,$this-$hits); fputs($log,$this-$log_entry ); cuz none of those are gonna work. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with file not writing
Actually writing to the counter file works fine, I just can't get it to write to the log file. -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 25, 2005 1:30 PM To: Joey Cc: PHP Subject: RE: [PHP] Help with file not writing Joey wrote: $this-$hits .= fgets($hiti,128); Do global search and replace for '-$' and change it to '-' $this-$hits=1+$this-$hits; echo $this-$hits; fputs($hito,$this-$hits); fputs($log,$this-$log_entry ); cuz none of those are gonna work. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with file not writing
Sorry I forgot to mention that I tried that anyway and no change in the result. fputs($log,$this-log_entry ); -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 25, 2005 1:30 PM To: Joey Cc: PHP Subject: RE: [PHP] Help with file not writing Joey wrote: $this-$hits .= fgets($hiti,128); Do global search and replace for '-$' and change it to '-' $this-$hits=1+$this-$hits; echo $this-$hits; fputs($hito,$this-$hits); fputs($log,$this-$log_entry ); cuz none of those are gonna work. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with file not writing
I Thought I sent a second email that mentioned I did try what you ask and that didn't make a difference. Also note the the write to the counter file works perfectly, but the log file write does not. Thanks, Joey PS No error messages. -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 25, 2005 7:44 PM To: Joey Subject: RE: [PHP] Help with file not writing I'll say it again. Every place that you have -$ you should have just - It's really that simple. Honest. Joey wrote: Sorry I forgot to mention that I tried that anyway and no change in the result. fputs($log,$this-log_entry ); -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 25, 2005 1:30 PM To: Joey Cc: PHP Subject: RE: [PHP] Help with file not writing Joey wrote: $this-$hits .= fgets($hiti,128); Do global search and replace for '-$' and change it to '-' $this-$hits=1+$this-$hits; echo $this-$hits; fputs($hito,$this-$hits); fputs($log,$this-$log_entry ); cuz none of those are gonna work. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with file not writing
On Tue, 2005-01-25 at 07:53, Joey wrote: I'm not too good with classes, in the below class I can get the hit counter to write to the hit counter file, but I can't get it to write the log file, I know security is done correctly on the file because it's the same as the counter log file, but I can't figure out why the other file isn't being written to. Also while the IP address works within the code prior to calling the class function writeLog() { $ip_address=$REMOTE_ADDR; $date_stamp=date(F j, Y, g:i a); $log_entry=$date_stamp . : . $ip_address . \n ; echo TEST- . $log_entry ; $log = fopen($this-log_file,w+); fputs($log,$this-$log_entry ); fclose($log); you set $log_entry but write $this-log_entry which does not exist. try fputs($log,$log_entry ); HTH Bret -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with file not writing
That was it Bret, thanks for pointing out my blindess... Joey -Original Message- From: Bret Hughes [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 26, 2005 12:34 AM To: php general list Subject: Re: [PHP] Help with file not writing On Tue, 2005-01-25 at 07:53, Joey wrote: I'm not too good with classes, in the below class I can get the hit counter to write to the hit counter file, but I can't get it to write the log file, I know security is done correctly on the file because it's the same as the counter log file, but I can't figure out why the other file isn't being written to. Also while the IP address works within the code prior to calling the class function writeLog() { $ip_address=$REMOTE_ADDR; $date_stamp=date(F j, Y, g:i a); $log_entry=$date_stamp . : . $ip_address . \n ; echo TEST- . $log_entry ; $log = fopen($this-log_file,w+); fputs($log,$this-$log_entry ); fclose($log); you set $log_entry but write $this-log_entry which does not exist. try fputs($log,$log_entry ); HTH Bret -- 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] help with nl2br
Phillip S. Baker wrote: Due to style sheet stuff I need to modify the nl2br (IE create or use a different function). I am pulling data from a database and using nl2br, which does the standard. some text copybr / br / Some more copybr / What I want instead is pSome text copy/p psome more text copy/p Again this is because of css and the designer I am workign with. Is there a built in function that can do something like this or another function out there. So far I cannot see anything. Or is there a way to view the coding of the nl2br function so I can create a new function modifying how it does it. Just asking so I do not have to create something from scratch. Thanks. //Maybe you just want: function nl2p($text){ return str_replace(\n, /P\nP, $text); } //Or, perhaps: function nl2p($text){ $result = str_replace(\n\n, /PP, $text); $result = nl2br($result); return $result; } But it might be worse than that, and you want to replace 2 OR MORE \n with P tags, at which point you probably want something like: function nl2p($text){ $result = preg_replace(/[\n]{2,}/, /PP, $text); //$result = nl2br($result); //Maybe uncomment... return $result; } All depends on how the original data was typed in, and what your designer is aiming for. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] help with nl2br
[snip] some text copybr / br / Some more copybr / What I want instead is pSome text copy/p psome more text copy/p [/snip] What you want to do is start with a p, then when you run into 2 \n\n you want to replace it with /pp and then end with a /p http://www.php.net/preg_replace -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] help with nl2br
You might check out http://photomatt.net/scripts/autop Call this function on the text you want to convert. Think of this code like nl2br on steroids. This is basically a cross-platform set of regular expressions that takes text formatted only by newlines and transforms it into text properly marked up with paragraph and line break tags. The line break part can also be turned off if you want. It's really clean and useful Sam D [snip] some text copybr / br / Some more copybr / What I want instead is pSome text copy/p psome more text copy/p [/snip] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with nl2br
Hey, I would just suggest that you Explode the data based on \n and then walk through it adding p /p and br / tags as necessary.. shouldn't be too diffcult. hth -K On Fri, 21 Jan 2005 14:19:38 -0800, Phillip S. Baker [EMAIL PROTECTED] wrote: Greetings all, Due to style sheet stuff I need to modify the nl2br (IE create or use a different function). I am pulling data from a database and using nl2br, which does the standard. some text copybr / br / Some more copybr / What I want instead is pSome text copy/p psome more text copy/p Again this is because of css and the designer I am workign with. Is there a built in function that can do something like this or another function out there. So far I cannot see anything. Or is there a way to view the coding of the nl2br function so I can create a new function modifying how it does it. Just asking so I do not have to create something from scratch. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with nl2br
Phillip S. Baker wrote: Greetings all, Due to style sheet stuff I need to modify the nl2br (IE create or use a different function). I am pulling data from a database and using nl2br, which does the standard. ... .html: div class=ParaFakeOrWhatEver some text copybr / br / Some more copybr / /div ... .css: .ParaFakeOrWhatEver { color: #c0c0c0; line-height: 1.5em; margin: 2em; } What I want instead is pSome text copy/p psome more text copy/p Again this is because of css and the designer I am working with. Is there a maybe something as trivial as a extra few pixels between paragraphs may be time better spent on other parts of the system? this is web not print. and if 'designers' would get that then we wouldn't have to live in table width=100% border=0 cellspacing=0 cellpadding=0 tr td colspan=5img src=/images/spacer.gif width=1 height=1/td /tr tr td valign=topimg src=/images/header/yyy.gif width=192 height=61/td tdimg src=/images/spacer.gif width=1 height=1/td td valign=topa href=target=_blankimg src=/images/header/xxx.gif width=66 height=61 style=border: none;/a/td tdimg src=/images/spacer.gif width=1 height=1/td td width=100%nbsp;/td /tr /table hell any longer, clean simple layout thats not pushed by print media expectations. built in function that can do something like this or another function out there. So far I cannot see anything. Or is there a way to view the coding of the nl2br function so I can create a new function modifying how it does it. I'm guess that if you could program C that you would have already downloaded the source and started hacking... so the answer is. yes and probably not at this point in time, my utmost apologies if I am wrong! Just asking so I do not have to create something from scratch. Thanks. preg_replace(); -- Blessed Be Phillip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with encryption
Here is a class that uses mcrypt that might be helpful: Tom - this class is awesome. Took 5 seconds to add to my site and worked like a charm on the first try. THANKS!! :) - Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help with encryption
Greg Donald wrote: On Thu, 13 Jan 2005 13:53:30 -0800, Brian Dunning [EMAIL PROTECTED] wrote: Could anyone point me to a web page or other documentation that shows a SIMPLE example of encryption? I know absolutely nothing about encryption. There are like 6 people in the entire world who know something about it, but sadly.. I'm not one of them. Good luck in your quest. Now, who was it that said you didn't have a sense of humor? :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with encryption
Michael Sims wrote: Greg Donald wrote: On Thu, 13 Jan 2005 13:53:30 -0800, Brian Dunning [EMAIL PROTECTED] wrote: Could anyone point me to a web page or other documentation that shows a SIMPLE example of encryption? I know absolutely nothing about encryption. There are like 6 people in the entire world who know something about it, but sadly.. I'm not one of them. Good luck in your quest. Now, who was it that said you didn't have a sense of humor? :) i THINK thats aimed at me, and I must admit he made me chuckle with that one! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help please!!
[snip] Thanks guys for any help troubleshooting this. [/snip] Is the drive full? Enough memory? An unusual number of connections? Any other applications added to the system? what do you see when you run top? Have you looked at a MySQL process list? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with encryption
Hi, Friday, January 14, 2005, 7:53:30 AM, you wrote: BD Howdy all - BD I have RTFM and STFW and I still can't get encryption to work. What I BD finally ended up with from the PHP documentation is long, unwieldy, BD confusing, and doesn't work. I give up. I threw my big mess away and BD would like to start from scratch. BD Could anyone point me to a web page or other documentation that shows a BD SIMPLE example of encryption? I need two-way encryption decryption, BD not a one-way hash. I'll be using this to obfuscate get parameters. BD Any pointers appreciated. Thanks all, BD - Brian Here is a class that uses mcrypt that might be helpful: class encrypt_class{ var $secret; function encrypt_class(){ $this-secret = 'put pass string here'; } Function encode($id){ $eid = $iv = 0; $len = strlen($id); $id = $len.'-'.$id; //encode the string length for trimming later $td = mcrypt_module_open(MCRYPT_TripleDES, , MCRYPT_MODE_ECB, ); $key = substr($this-secret, 0, mcrypt_enc_get_key_size ($td)); $iv = pack(a.mcrypt_enc_get_iv_size($td),$iv); mcrypt_generic_init ($td, $key, $iv); $eid = base64_encode(mcrypt_generic ($td, $id)); mcrypt_generic_deinit($td); return $eid; } Function decode($eid){ $id = $iv = 0; $td = mcrypt_module_open (MCRYPT_TripleDES, , MCRYPT_MODE_ECB, ); $key = substr($this-secret, 0, mcrypt_enc_get_key_size ($td)); $iv = pack(a.mcrypt_enc_get_iv_size($td),$iv); mcrypt_generic_init ($td, $key, $iv); $id = mdecrypt_generic ($td, base64_decode($eid)); $len = strtok($id,'-'); $id = substr($id,(strlen($len)+1),$len); mcrypt_generic_deinit($td); return $id; } } //useage $str = Hello World; $enc = new encrypt_class(); $estr = $enc-encode($str); echo $estrbr; $dstr = $enc-decode($estr); echo $dstrbr; -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with encryption
Brian Dunning wrote: Howdy all - I have RTFM and STFW and I still can't get encryption to work. What I good man! (for trying that is) bummer its not working yet... finally ended up with from the PHP documentation is long, unwieldy, confusing, and doesn't work. I give up. I threw my big mess away and you could have lived with the 'long, unwieldy, confusing' part no doubt! would like to start from scratch. does that mean you tried using the mcrypt extension? I guess it must do. Could anyone point me to a web page or other documentation that shows a SIMPLE example of encryption? I need two-way encryption decryption, this tutorial (2 parts) at webmonkey does quite a good job of taking you thru it step by step: http://webmonkey.wired.com/webmonkey/programming/php/tutorials/tutorial1.html also there has just been a thread on this list which might help you (in case you hadn't seen/read it) subject: Data Encryption started by: [EMAIL PROTECTED] started on: 12-Jan-2005 AFAIKT though proper encryption and SIMPLE just don't go hand in hand. on the other hand encryption and ''brainfreeze' were made for each other :-) if you ask me. not a one-way hash. I'll be using this to obfuscate get parameters. do you just want to obfuscate or is it important that content is actually secure? I can imagine that the issue is compounded in your case by the fact that the GET params are pushed over the wire (which may garbble the encrypted strings - can anyone confirm/deny that hypothesis?) in which case use of url_encode()/url_decode() may need to be used to protect the integrity of the strings. --- If the parameters are taken from a fixed list of values - e.g. columnnames for instance then maybe one-way encryption will work for you. for instance say you have a sortby GET param, you could take the columnnames of your table and hash them with md5sum() or sha1() and stick them into the relevant urls - then if/when a url comes back to the server the hash in the GET param could be checked against the hashes of the columnnames until you find a match - if you find a match you know which column was requested. The example is contrived but hopefully you understand what I mean and you can determine whether this is a possibility for you. --- Lastly you may have to ask yourself if it's necessary/feasable to do GET param encryption (in bang for buck kind of way). Unfortunately I can imagine that such a decision may have been made for you by some non-tehnical manager (it wouldn't be the first time!) in which case arm yourself with a good argument and go batter him with it ;-) Any pointers appreciated. Thanks all, - Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with encryption
On Thu, 13 Jan 2005 13:53:30 -0800, Brian Dunning [EMAIL PROTECTED] wrote: Could anyone point me to a web page or other documentation that shows a SIMPLE example of encryption? I know absolutely nothing about encryption. There are like 6 people in the entire world who know something about it, but sadly.. I'm not one of them. Good luck in your quest. -- Greg Donald Zend Certified Engineer http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help please!!
I would check what hitting the machine from the network. At the most basic level, just try netstat 1 on the command line. Also try iostat 1 to see what load the machine has. It may not be PHP or Apache but something else, maybe a denial of service attack. On Jan 13, 2005, at 10:02 PM, Brent Clements wrote: Having a very frustrating problem and I can't seem to figure out why it's happening. 1. As of last week, all of our applications have started to work intermittingly. The codebase has not changed. 2. Sometimes the application will display, sometimes it won't. The browsers loading progress bar will move for about 25% then just stop. No timeout or 401 errors occur. 3. There are no errors message in any of the logs files. To test if it's our application we have done the following in our main php file which runs the rest of the application ?php echo Step 0 br; --Segment of our code is here-- echo Step 1 br; --Segment of our code is here-- echo Step 2 br; ? Sometimes it doesn't even get to the first line of php code which is the first echo statement, sometimes it gets to step 0 and step 1 and sometimes it gets to all steps. The code between each of these steps is nothing major, nothing calls mysql or anything like that. It's mainly just variable initialization. Again, the entire application runs fine every couple of refreshes. Then sometimes it'll just stop completely. I have turned on all sorts of debugging and nothing. I have reinstalled apache, mysql, and php 2 times. We have also optimize both apache and mysql for for than enough client connections as well are using persistant db connections. But like I said, the application works sometimes, sometimes it doesn't. And the data is pretty static. I am running RHEL 3 U3 with RH php version php-4.3.2-19.ent, RH mysql server version mysql-server-3.23.58-2.3, and RH apache version httpd-2.0.46-44.ent Thanks guys for any help troubleshooting this. -Brent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Brent Baisley Systems Architect Landover Associates, Inc. Search Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with pack unpack functions
What is strange is that I can always get the char data[] structure member, and sometimes I get meaningful data in a few of the shorts, but never all of the structure's members at the same time. Do you consistently get the same problems on the FIRST record returned? Anything after that is suspect, as you may be so far off-sequence that the rest are meaningless. What data do you actually get for the first record? Also, call me crazy, but, like, aren't you THROWING AWAY most of your buffer?... Or, in this case, reading only HALF (roughly) of a record at a time. You read 2048 bytes. You trim it (probably a bad idea)... You try to unpack all 2048 bytes as if it was a single record. You ignore anything after that in the buffer, and loop to get 2048 more bytes. But each record you receive is supposedly: short+short+short+short+REPLY_MSG_SIZE+1 bytes long. 2 + 2 + 2 + 2 + 4000 + 1 4009 bytes for a single record. I think you want something more like this: $socket_buffer = ''; $parse_buffer = ''; $format = @0/sval0/@1/sval1/@2/sval2/@3/sval3/@4/sval4/@5/sval5/@6/C*; while ($socket_buffer = socket_read($msgsock, 2048, PHP_BINARY_READ)){ if (false == $little_buffer){ //Your $ret was not defined... echo Failed socket read , socket_strerror(socket_last_error($msgsock)); //If you are gonna keep going, clear the socket error. socket_clear_error($msgsock); break 2; } $parse_buffer .= $socket_buffer; $socket_buffer = ''; //Now parse whatever we've got so far, leaving behind any partial record, //but only if we've got at least one full record to start with. while (strlen($parse_buffer) = 4009)){ $record = unpack($format, $parse_buffer); print_r($record); $parse_buffer = substr($parse_buffer, 4009); //4010? } } The point being that you can't expect to get a full record when you only read 2048 bytes at a time, and then you can't expect to find record boundaries if you then parse only half of a record and move on to the next record when you only got half a record, and then at that point you're getting just under half of the first record, plus a little bit of the second record... Actually, since you know each record is exactly 4009 bytes long, you might wanna change your buffer size from 2048 to 4009 (or 4010 if that's what works) and simplify the code a lot. Course, if they ever re-define #define REPLY_MSG_SIZE 4000 then you'll have to adjust, so you probably should express everything in terms of your own REPLY_MSG_SIZE as well, using a http://php.net/define and then writing things like REPLY_MSG_SIZE + 8 or REPLY_MSG_SIZE + 8 + 1 for the places where you need to add to get to the byte you want. Hope all of that makes sense and is of some use... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with pack unpack functions
First, let me say thanks for responding. My other responses are embedded within your reply: What is strange is that I can always get the char data[] structure member, and sometimes I get meaningful data in a few of the shorts, but never all of the structure's members at the same time. Do you consistently get the same problems on the FIRST record returned? Yes. Anything after that is suspect, as you may be so far off-sequence that the rest are meaningless. What data do you actually get for the first record? Depends on what formatting I use with the unpack, but I've been able to get one of the shorts to contain an expected value. I kept the description short and didn't include the fact that most of the server responses are much less than the 4K buffer size. But in all cases I seem to get the char data that appears in the 4K buffer. Also, call me crazy, but, like, aren't you THROWING AWAY most of your buffer?... Well, the code snippet is from a proof of concept. I could easily write a C-lang client, call it from a PHP exec() call, etc, etc... BUT, that doesn't help us determine if we can use PHP for this purpose. So, at this point I don't really care, but I see why you would question my logic. Or, in this case, reading only HALF (roughly) of a record at a time. You read 2048 bytes. You trim it (probably a bad idea)... This was robbed from a prior example on www.php.net, but I can remove it to see if it helps. You try to unpack all 2048 bytes as if it was a single record. You ignore anything after that in the buffer, and loop to get 2048 more bytes. But each record you receive is supposedly: short+short+short+short+REPLY_MSG_SIZE+1 bytes long. 2 + 2 + 2 + 2 + 4000 + 1 4009 bytes for a single record. I think you want something more like this: $socket_buffer = ''; $parse_buffer = ''; $format = @0/sval0/@1/sval1/@2/sval2/@3/sval3/@4/sval4/@5/sval5/@6/C*; while ($socket_buffer = socket_read($msgsock, 2048, PHP_BINARY_READ)){ if (false == $little_buffer){ //Your $ret was not defined... echo Failed socket read , socket_strerror(socket_last_error($msgsock)); //If you are gonna keep going, clear the socket error. socket_clear_error($msgsock); break 2; } $parse_buffer .= $socket_buffer; $socket_buffer = ''; //Now parse whatever we've got so far, leaving behind any partial record, //but only if we've got at least one full record to start with. while (strlen($parse_buffer) = 4009)){ $record = unpack($format, $parse_buffer); print_r($record); $parse_buffer = substr($parse_buffer, 4009); //4010? } } The point being that you can't expect to get a full record when you only read 2048 bytes at a time, and then you can't expect to find record boundaries if you then parse only half of a record and move on to the next record when you only got half a record, and then at that point you're getting just under half of the first record, plus a little bit of the second record... Makes some sense, I just didn't see it to be a problem at this point, but maybe it is... I also think that the server is NULL padding the buffer up to the 4K limit after all of the text is stored in it. (I'll have to check to validate my theory here). Actually, since you know each record is exactly 4009 bytes long, you might wanna change your buffer size from 2048 to 4009 (or 4010 if that's what works) and simplify the code a lot. Course, if they ever re-define #define REPLY_MSG_SIZE 4000 then you'll have to adjust, so you probably should express everything in terms of your own REPLY_MSG_SIZE as well, using a http://php.net/define and then writing things like REPLY_MSG_SIZE + 8 or REPLY_MSG_SIZE + 8 + 1 for the places where you need to add to get to the byte you want. Always a good idea for production code...They in this case is ME anyway! So I'll have no one to blame but myself should this ever occur. Hope all of that makes sense and is of some use... Make sense, don't know if it'll help yet, but I'm fixin to try some of your suggestions. Thanks again. -- Scott E. Young Area Mgr - NMA Software Solutions [EMAIL PROTECTED] (713) 567-8625 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with code
karl james wrote: I have since updated it. And I am having issues with a function I suppose. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site38/fst/var/www/html/php/wrox_php/movie_details.php on line 119 http://www.theufl.com/php/wrox_php/movie_details.php This error (obviously) means that there is a problem with your query, which is why mysql_query() did not return a result resource. http://www.php.net/mysql_error is your friend. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] help in reversing an array
I am having some trouble reversing the order of an array. [snip] Which function amongst the available should I use? rsort() is what you're looking for. http://us2.php.net/manual/en/function.rsort.php -M -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help in reversing an array
Mike wrote: I am having some trouble reversing the order of an array. [snip] Which function amongst the available should I use? rsort() is what you're looking for. http://us2.php.net/manual/en/function.rsort.php -M what's wrong with array_reverse()? http://www.php.net/manual/en/function.array-reverse.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with code
karl james said: Team, Can you tell me why this code is not working? I get a query is empty at the moment. http://www.theufl.com/php/wrox_php/movie_details.phps We need some information on the errors that you are getting. -Robby -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting Development *--- Now supporting PHP5 --- / -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php