Re: [PHP] displaying certain number of character
Hey Philip you can use this function function cuttext($text, $maxChars = 20, $tail = '') { $arrWords = explode( , $text); $temp = ; for ($i=0; $icount($arrWords); $i++) { $temp = ($i == 0 ? $arrWords[$i] : . $arrWords[$i] ); if (strlen($temp) $maxChars) { $returnStr = $temp; } else { return $returnStr.$tail; } } return $returnStr; } Usage: echo cuttext(Please visit my site, 15, $tail = '..'); This will echo Please visit On 8/31/05, Philip Hallstrom [EMAIL PROTECTED] wrote: $words= If length is given and is negative, then that many characters will be omitted from the end of string (after the start position has been calculated when a start is negative). If start denotes a position beyond this truncation, an empty string will be returned. ; echo substr($words, 0, 50); ? I have been using this but how can I make sure I do not split a word in half? - Finishing on a space would probably do it. You could use wordwrap() to wrap lines at 50 characters and then just take the first line http://us3.php.net/wordwrap -philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- *** phpgurru.com http://phpgurru.com [A php resource provider] *** \\\|/// \\ - - // ( @ @ ) PHP is too logical for my brain +---oOOo-(_)-oOOo--+ | Mian Shafiq ur Rehman | phpgurru.com http://phpgurru.com [A php resource provider] | 107 B, New Town, Multan Road | Lahore Pakistan | | Mobile: 0300 423 9385 | | ooo0 http://www.phpgurru.com | ( ) 0ooo E-Mail: [EMAIL PROTECTED] +---\ (( )--+ \_) ) / (_/
[PHP] Re: security while building online store
[EMAIL PROTECTED] wrote: kat Dzesi momak ;) I think you know PHP enough to make your code secure. Just take care (as Christian wrote)about sql-injections and register_globals. The biggest problem could be Linux/Apache/MySQL server security threat... --- avast! Antivirus: Outbound message clean. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: security while building online store
You must read the articles by shiflet http://www.phpgurru.com/index.php?acion=pagingchid=www.shiflett.orgoffset=10 On 8/31/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: kat Dzesi momak ;) I think you know PHP enough to make your code secure. Just take care (as Christian wrote)about sql-injections and register_globals. The biggest problem could be Linux/Apache/MySQL server security threat... --- avast! Antivirus: Outbound message clean. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- *** phpgurru.com http://phpgurru.com [A php resource provider] *** \\\|/// \\ - - // ( @ @ ) PHP is too logical for my brain +---oOOo-(_)-oOOo--+ | Mian Shafiq ur Rehman | phpgurru.com http://phpgurru.com [A php resource provider] | 107 B, New Town, Multan Road | Lahore Pakistan | | Mobile: 0300 423 9385 | | ooo0 http://www.phpgurru.com | ( ) 0ooo E-Mail: [EMAIL PROTECTED] +---\ (( )--+ \_) ) / (_/
[PHP] Re: (Yet another) I'm blind ... post
Martin S [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In this code, I'm not getting the value of $list passed to the Mailman page. I've checked this umpteen times by now, but fail to see the error. I've $list is not to be found in this code sample. $lista is though. beaten myself suitably with a steel ruler -- but it didn't help. Nor does the cold I'm coming down with I suppose. Anyone see the error, and feel like pointing it out to me? Martin S ?php print H2BJoin the lists/b/H2; print FORM Method=POST ACTION='http://www.bollmora.org/mailman/subscribe/' . $lista . 'br'; print Your E-mail address: INPUT type=\Text\ name=\email\ size=\30\ value=\\br; print Your Name (optional): INPUT type=\Text\ name=\fullname\ size=\30\ value=\\brbr; print Lista: select name=\lista\ /; print option value=\tvl_bollmora.org\Tävling/option; print option value=\jpg_bollmora.org\JGP/option; print option value=\styrelse_bollmora.org\Styrelse/option; print /selectbr; print You may enter a privacy password below. This provides only mild security, but shouldbr prevent others from messing with your subscription. bDo not use a valuable password/b as itbr will occasionally be emailed back to you in cleartext.brbr If you choose not to enter a password, one will be automatically generated for you, and it willbr be sent to you once you've confirmed your subscription. You can always request a mail-backbr of your password when you edit your personal options.brbr; print Would you like to receive list mail batched in a daily digest? (You may choose NoMail after you join.)BRbr; print input type=radio name=\digest\ value=\0\ CHECKED No input type=radio name=\digest\ value=\1\ Yesbrbr; print INPUT type=\Submit\ name=\email-button\ value=\Subscribe\; print /FORM; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] (Yet another) I'm blind ... post
In this code, I'm not getting the value of $list passed to the Mailman page. I've checked this umpteen times by now, but fail to see the error. I've beaten myself suitably with a steel ruler -- but it didn't help. Nor does the cold I'm coming down with I suppose. Anyone see the error, and feel like pointing it out to me? Martin S Hi Martin, Try checking for the value in $_POST['lista'] on your subscribe page. Failing that, try the following: print_r($_POST); This should give you all the variables and values being sent by the form to the page being used to process that form. Hope this helps. Much warmth, Murray --- Lost in thought... http://www.planetthoughtful.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mktime strange
Hello, I've got a problem with mktime. It's a very strange behaviour, I don't know if is a bug: echo date (M-d-Y, mktime (0,0,0,07,07,2005)); - Jul-07-2005 (right) echo date (M-d-Y, mktime (0,0,0,08,07,2005)); - Dec-07-2004 (?) Can anyone help me to solve this question? Is it a bug? Regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mktime strange
On 8/31/05, Hal 9001 Consulting [EMAIL PROTECTED] wrote: Hello, I've got a problem with mktime. It's a very strange behaviour, I don't know if is a bug: echo date (M-d-Y, mktime (0,0,0,07,07,2005)); - Jul-07-2005 (right) echo date (M-d-Y, mktime (0,0,0,08,07,2005)); - Dec-07-2004 (?) Can anyone help me to solve this question? Is it a bug? Numbers with leading zeros are octal. 08 is not a valid octal number, and is interpreted as 0. The solution is to not use leading zeros... echo date (M-d-Y, mktime (0,0,0,8,7,2005)); - Aug-07-2005 -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] stupid (HTML) question
Embarrassed to ask but how to vertically align a table to a middle of a page? Forgot... ...didn't even find it with even Dreamweaver... :-0 -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] stupid (HTML) question
[snip] Embarrassed to ask but how to vertically align a table to a middle of a page? [/snip] Use CSS. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stupid (HTML) question
I don't think you can do a vertical centering. but you can specify a margin-top value to your table... fx Embarrassed to ask but how to vertically align a table to a middle of a page? Forgot... ...didn't even find it with even Dreamweaver... :-0 -Will -- François-Xavier LACROIX http://www.clever-age.com Clever Age - conseil en architecture technique GSM: +33 6 11 03 23 77 - Tél: +33 1 53 34 66 10 Clever Age vous invite à ses petits-déjeuners du Jeudi http://www.clever-age.com/actualites/petits-dejeuners/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] String format problem
hi i have a problem when i am formating a string the problem is it converts the \n in the string to a new line here is the code ? $Text = D:\AppServ\www\intranet\admin\store\nodirectory\sub; $Replace = D:\AppServ\www\intranet\admin\store; $with = http://localhost/bank/admin/store;; //$doc = str_replace ($Replace, $with, $Text); $doc = str_replace( '\\', '/', str_replace( $Replace, $with, $Text ) ); echo $doc; //i need $Doc to look like this http://localhost/bank/admin/store/nodirectory/sub //but it outputs http://localhost/bank/admin/store odirectory/sub ? can any one help me with that plz thanks in advance -- Ahmed Abdel-Aliem Web Developer www.SafariStudio.net +20101108551 registered Linux user number 382789 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] time zone problem
Hi! I some problem: I have visitor's IP, country and city. I need to define his GMT offset. Have you such database GMT's offsets. I found many such list in Google but many countries has different GMT's (Russia - 7!). Any idea? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String format problem
On 8/31/05, Ahmed Abdel-Aliem [EMAIL PROTECTED] wrote: hi i have a problem when i am formating a string the problem is it converts the \n in the string to a new line here is the code ? $Text = D:\AppServ\www\intranet\admin\store\nodirectory\sub; $Replace = D:\AppServ\www\intranet\admin\store; $with = http://localhost/bank/admin/store;; Don't use double quotes if you don't want escape sequences to be expanded. $Text = 'D:\AppServ\www\intranet\admin\store\nodirectory\sub'; $Replace = 'D:\AppServ\www\intranet\admin\store'; $with = 'http://localhost/bank/admin/store'; -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] (Yet another) I'm blind ... post
Martin S wrote: In this code, I'm not getting the value of $list passed to the Mailman page. I've checked this umpteen times by now, but fail to see the error. I've beaten myself suitably with a steel ruler -- but it didn't help. Nor does the cold I'm coming down with I suppose. Anyone see the error, and feel like pointing it out to me? Martin S ?php print H2BJoin the lists/b/H2; print FORM Method=POST ACTION='http://www.bollmora.org/mailman/subscribe/' . $lista . 'br'; snip $list or $lista? -- 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] stupid (HTML) question
An easy way to center a table, is to put it in another table: table border=1 width=100% height=100% tr td align=center valign=middle table border=1trtdHello/tdtdworld/td/tr/table /td /tr /table /Jesper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SPL Countable count() not being called
Justin Francis wrote: I have not been able to get count() to be called when I pass my Countable class to the count function. I am using PHP 5.1 Release Candidate 1. I am not sure if it is a bug, so I am posting here to see if anyone can help. -- class Collection implements Countable { public function count() { return 200; } } $c = new Collection(); echo(count($c)); This code prints 1 out with no errors, when it should print out 200. Any ideas? In case anyone was wondering, I downloaded the latest cvs snapshot, and this bug has been fixed. Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: SPL Countable count() not being called
[snip] This code prints 1 out with no errors, when it should print out 200. Any ideas? In case anyone was wondering, I downloaded the latest cvs snapshot, and this bug has been fixed. [/snip] Bug? There is no bug. You counted 1 (one) item, not 200. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[suspicious - maybe spam] [PHP] [suspicious - maybe spam] RE: [suspicious - maybe spam] PHP/MySQL/XmlHTTPRequest
there is a book coming out in October I guess, do a search on amazon under AJAX. Also, at www.phparch.com the August issue deals with AJAX between other things. You can buy a digital copy (PDF) for only 3.45 dlls. Regards, Chicolinux -Original Message- From: Death Gauge [mailto:[EMAIL PROTECTED] Sent: Martes, 30 de Agosto de 2005 02:51 p.m. To: php-general@lists.php.net Subject: [suspicious - maybe spam] PHP/MySQL/XmlHTTPRequest Where do I go learn about XmlHTTPRequest? I've done googles and all I've found was stuff about toolkits no tutorials or documents telling how to use it. --Death Gauge How do you gauge your death?! _ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos. This message is for the sole use of the person or entity to whom it is being sent. Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law. If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited. If you received this document by mistake please notify immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may be used or reproduced in any manner whatsoever. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stupid (HTML) question
Will As suggested by Monsieur Jay, a bit of CSS... style type=text/css .centerTable { text-align: center; } .centerTable table { position: absolute; top: 50%; left: 50%; width: tableWidth; height: tableHeight; margin-left: -(tableWidth/2)px; margin-top: -(tableHeight/2)px; } /style . div class=centerTable table border=1 tr td1/td td2/td /tr tr td3/td td4/td /tr /table /div HTH Raz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Writing to a text file
I have 2 servers; one running *nix w/ PHP4, and one running Windows 2k w/ PHP5; neither of which give me read permissions to write/create text files. Apparently, the *nix server has PHP in Power Mode, but I'm still getting no love from fopen, and chmod via PHP doesn't work. Any adivce? Code skrait from the docs: // Let's make sure the file exists and is writable first. if(is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'w')) { echo(Cannot open file ($filename)br /); exit; } $somecontent = ; // Write $somecontent to our opened file. if(fwrite($handle, $somecontent) === FALSE) { echo(Cannot write to file ($filename)br /); exit; } echo(Success, wrote ($somecontent) to file ($filename)br /); fclose($handle); } else { echo The file $filename is not writablebr /; if (!chmod($filename, 0666)) { echo Cannot change the mode of file ($filename)br /; exit; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String format problem
hi i have a problem when i am formating a string the problem is it converts the \n in the string to a new line here is the code ? $Text = D:\AppServ\www\intranet\admin\store\nodirectory\sub; $Replace = D:\AppServ\www\intranet\admin\store; $with = http://localhost/bank/admin/store;; //$doc = str_replace ($Replace, $with, $Text); $doc = str_replace( '\\', '/', str_replace( $Replace, $with, $Text ) ); echo $doc; //i need $Doc to look like this http://localhost/bank/admin/store/nodirectory/sub //but it outputs http://localhost/bank/admin/store odirectory/sub Replace your double quotes with single quotes... that is: $Text = 'D:\AppServ\www\intranet\admin\store\nodirectory\sub'; $Replace = 'D:\AppServ\www\intranet\admin\store'; $with = 'http://localhost/bank/admin/store'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String format problem
To elaborate on Philip's response (which is correct)... Anything in double quotes ( ) will be interpreted by PHP before figuring out what the actual value is. Items like \n, \t, etc are therefore converted to a newline (\n) or a tab (\t) before assigning to the variable. Variables within the double quotes are also evaluated before assigning. So.. $firstname = Bob; $lastname = Smith; $varname = $firstname $lastname told me to find the file in folder C:\newtext\; echo $varname; Will yield: Bob Smith told me to find the file in folder C: ewtext; Actually it'll give you an error because the double quotes aren't properly terminated.. \ is also interpreted. Whereas.. $varname = '$firstname $lastname told me to find the file in folder C:\newtext\'; echo $varname; Yields.. $firstname $lastname told me to find the file in folder C:\newtext\ In this case, you have two options to get what you want: $varname = $firstname $lastname told me to find the file in folder C:\\newtext\\; ..or.. $varname = $firstname . ' ' . $lastname told me to find the file in folder C:\newtext\'; I've read never use double quotes unless you have to because it could potentially speed up PHP a little because it won't be trying to interpret every string. I'm not sure exactly how much savings this is going to give you so I drop this in the whatever your style dictates category. I prefer double quotes because I think it visually delineates the code better and I think $firstname $lastname looks tidier than $firstname . ' ' . $lastname even though I do consider it slightly looser coding practices. One's better for the human, one's better for the machine (imo) and since I'm a human. I think. :) -TG = = = Original message = = = hi i have a problem when i am formating a string the problem is it converts the \n in the string to a new line here is the code ? $Text = D:\AppServ\www\intranet\admin\store\nodirectory\sub; $Replace = D:\AppServ\www\intranet\admin\store; $with = http://localhost/bank/admin/store;; //$doc = str_replace ($Replace, $with, $Text); $doc = str_replace( '\\', '/', str_replace( $Replace, $with, $Text ) ); echo $doc; //i need $Doc to look like this http://localhost/bank/admin/store/nodirectory/sub //but it outputs http://localhost/bank/admin/store odirectory/sub Replace your double quotes with single quotes... that is: $Text = 'D:\AppServ\www\intranet\admin\store\nodirectory\sub'; $Replace = 'D:\AppServ\www\intranet\admin\store'; $with = 'http://localhost/bank/admin/store'; ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] running process in the background
Hi, I'm experiencing strange behavior when trying to run background process in PHP. Code : //Run_check.php foreach ($_POST as $kid){ `php run.php param1 param2 /dev/null `; } In this case PHP waits all the instances of the process to complete. I don't understand why. I have a workaround here, but anyway i don't understand why the above example doesn't work. If i don't run the cycle here , but run other file and there run the cycle that runs the the background processes everything is OK. /*This file gets $_POST , implodes it , and passes the string to the other script */ //Run_check.php $ids=implode(',',$_POST); ` php run1.php $ids`; /*This script takes the input , explodes it and runs a cycle that runs the background process*/ //run1.php : $kwid=explode(',',$argv[1]); foreach ($kwid as $kid){ `php run.php param1 param 2 /dev/null `; } Everything is OK. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload file - clients path to file?
Interaction to write to a input file type is denied in browsers not to read the value so you can can get the full path using JavaScript like any other input in the form(document.formname.inputname.value) and pass it to other input field lets say input fullpath using something like document.formname.fullpath = document.formname.inputname.value -- all using javascript So yes you can get the fullpath however you should redirect your question to a JavaScript List or perhaps a javascript-php list. Regards Angelo - Original Message - From: Jasper Bryant-Greene [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tuesday, August 30, 2005 7:14 AM Subject: Re: [PHP] upload file - clients path to file? [EMAIL PROTECTED] wrote: I havent found an answer after looking at the manual. I'm trying to find out if it possible to find the path of the file on the clients pc once a form has been submitted with the file upload form. I know its possible to get the file name but I need the whole path. is this possible? Not with pure PHP. Maybe with some JavaScript, but most browsers heavily limit any interaction with input type=file controls from JavaScript. So probably not at all. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ If you find my advice useful, please consider donating to a poor student! You can choose whatever amount you think my advice was worth to you. http://tinyurl.com/7oa5s -- 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] String format problem
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] To elaborate on Philip's response (which is correct)... [] I've read never use double quotes unless you have to because it could potentially speed up PHP a little because it won't be trying to interpret every string. I once did some trials with thousand repetitions of segments of code with different alternatives, so let me go through all of them since I have the numbers anyway. The original was in Spanish so I'll just give the results. The question started with using echo or print and, as the manual says, echo is, indeed, faster: echo uno $f tres : 3.04 print uno $f tres : 3.70 The numbers after the colons are the execution times of one against the other for a lot of repetitions, anyhow, they should be read as relative to one another. Next, most people don't know that echo accepts multiple arguments separated by commas. Separating the arguments with commas is faster. echo 'uno ' . ' dos ' . ' tres ': 1.32 echo 'uno ' , ' dos ' , ' tres ': 0.94 In fact, this is a poor example since the difference gets larger with longer string and more arguments. When you use dots, the interpreter has to actually concatenate the string, looking for memory to do so and freeing it up afterwards. This takes time. With commas, each argument is sent to the output stream as soon as it is found, no further processing is needed in between. Then the single vs. double quotes: echo 'uno ' , ' dos ' , ' tres ': 0.94 echo uno , dos , tres : 6.76 Once again, these are relative times but it means using double quotes is 7 times slower than single quotes Several different alternatives with variables involved: echo 'uno ' . $f . ' tres ': 7.38 echo 'uno ' , $f , ' tres ': 0.80 echo uno $f tres : 3.04 echo EOT uno $f tres EOT: 3.29 Notice that when variables are involved, the difference in between echoing with arguments separated with commas and separated with dots is more than 9 times faster for the commas.Using double quotes with variable expansion is almost 4 times slower than the commas, but is still faster than concatenating them externaly with dots. Using heredoc-style strings is not so bad compared to double quotes. So, if you are sending out the rule would be: Use echo, not print. Separate arguments with commas. Now, if you are not using echo, for example, concatenating to a variable, the best is to use variable expansion inside double quoted or heredoc strings. Concatenating with dots is more than twice as slow. Satyam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] weird results from imagettfbbox()
I have an array of strings in which I am passing to imagettfbbox() in order to calculate the height of the text box for each string. I am then subtracting the height from the y position in order to deviate the pivot point form the top left corner to the bottom left corner when I used imagettftext() to draw the text on an image. I am giving both commands a fontsize of 50, an angle of 0 and I am using the font ARIAL. I am having an issue where the first string comes back with a height of 50 and the next comes back with 47. Then 50 again for the next following string and then 47 again for the next one foloowing that. It keeps going on and on like this and I do not understand why. I am using the same font, font size, and angle for each string so shouldnt they all come back as the same size? Here's a snippet of what I am doing: $file = this can be any file; $im = imagecreatefromjpeg($file); $textcolor = imagecolorallocate($im, 0, 0, 0); $fontfile = arial.ttf; $fontsize = 50; $arr = split(CR, $_GET['text']); $boxes = count($arr); if (preg_match('/[0-9]/', $boxes)){ for($c=0;$c$boxes;$c++){ $text = stripslashes($arr[$c]); $y = $fontsize * $c; $bbox = imagettfbbox($fontsize, 0, $fontfile, $text); $dy = $bbox[7] - $bbox[1]; $py = $y-$dy; imagettftext($im, $fontsize, 0, 1, $py, $textcolor, $fontfile, $text); } } header(Content-type: image/jpeg); imagejpeg($im, ,95); imagedestroy($im); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running process in the background
Oh wait... you are not specifying your $_POST variable. you need to use the key for $_POST. just do a print_r($_POST) to find the key from the $_POST array that you are looking for. also, i would not pass a $_POST variable directly to your shell without escaping it somehow, first... foreach ($_POST[$key] ... Jordan Did you try also sending stderr to /dev/null rather than stdout only? I think the syntax is to add a 21: foreach ($_POST as $kid){ `php run.php param1 param2 /dev/null 21 `; } This should put each process in the background and suppress all errors and output. Does that work? Jordan On Aug 31, 2005, at 11:44 AM, Georgi Ivanov wrote: foreach ($_POST as $kid){ `php run.php param1 param2 /dev/null `; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: time zone problem
Go to: http://www.timeanddate.com/worldclock/custom.html?cities=51,31,1038,224,179 The numbers at the end are my personal selection of cities I care about, but you can change it and the cities database is a long one. It is updated for daylight savings when applicable. Satyam Sergey [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi! I some problem: I have visitor's IP, country and city. I need to define his GMT offset. Have you such database GMT's offsets. I found many such list in Google but many countries has different GMT's (Russia - 7!). Any idea? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Making Text [not the background] transparent
How do I make the text transparent over the background ? In my web app, I want to to put a layer BEHIND the image to control the color of the php-created text So, the layer color in the web app shows thru the text php creates Would like to use alpha transparency so the color looks clean :) how would I amend the below script to do this ? many thanks g header(Content-type:.$mime); //$mime = image/png $im = imagecreatetruecolor(200, 16); //use to draw a text box imageAlphaBlending($im, true); imageSaveAlpha($im, true); $left= 5; //add a little pad to the left edge $color = imagecolorallocate($im, 255, 255, 255); $fontSize = 11; // choose a font $fontPath = /home/siren/fonts/; $defaultFont = tahomabd.ttf; $fontName = arial.ttf; $font = $fontPath.$fontName ; if (! file_exists($font)) { $font = $fontPath.$defaultFont ; } $text= background color shows through the text // Add the text imagettftext($im, $fontSize, 0, 10, 13, $color, $font, $text); imagepng($im); readfile($im); imagedestroy($im); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] weird results from imagettfbbox()
I have an array of strings in which I am passing to imagettfbbox() in order to calculate the height of the text box for each string. I am then subtracting the height from the y position in order to deviate the pivot point form the top left corner to the bottom left corner when I used imagettftext() to draw the text on an image. I am giving both commands a fontsize of 50, an angle of 0 and I am using the font ARIAL. I am having an issue where the first string comes back with a height of 50 and the next comes back with 47. Then 50 again for the next following string and then 47 again for the next one foloowing that. It keeps going on and on like this and I do not understand why. I am using the same font, font size, and angle for each string so shouldnt they all come back as the same size? Is each line of the file the same? It's going to vary depending on what letters are in the string (ascenders and descenders for letters like qygpi, etc.). maybe that's it? Here's a snippet of what I am doing: $file = this can be any file; $im = imagecreatefromjpeg($file); $textcolor = imagecolorallocate($im, 0, 0, 0); $fontfile = arial.ttf; $fontsize = 50; $arr = split(CR, $_GET['text']); $boxes = count($arr); if (preg_match('/[0-9]/', $boxes)){ for($c=0;$c$boxes;$c++){ $text = stripslashes($arr[$c]); $y = $fontsize * $c; $bbox = imagettfbbox($fontsize, 0, $fontfile, $text); $dy = $bbox[7] - $bbox[1]; $py = $y-$dy; imagettftext($im, $fontsize, 0, 1, $py, $textcolor, $fontfile, $text); } } header(Content-type: image/jpeg); imagejpeg($im, ,95); imagedestroy($im); -- 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] String format problem
hi i have a problem when i am formating a string the problem is it converts the \n in the string to a new line here is the code ? $Text = D:\AppServ\www\intranet\admin\store\nodirectory\sub; $Replace = D:\AppServ\www\intranet\admin\store; $with = http://localhost/bank/admin/store;; Use single quotes instead of double quotes: $Text = 'D:\AppServ\www\intranet\admin\store\nodirectory\sub'; $Replace = 'D:\AppServ\www\intranet\admin\store'; $with = 'http://localhost/bank/admin/store'; JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Nested IFs Problem
I have the following nested ifs: if ($row['date'] '2005-10-02') { if ($row['time'] '12:00') { if ($row['field'] == 'P5' ) { echo td class=\tabletextbluebg\Success; } } } else { echo td class=\tabletextred\Failed; } /td Whenever the 3 if statements are true, I always get the correct Success to echo. However, if any or all of the if statements are false, I never get Failed to echo. I know it's something simple, but I just can't see it at the moment. TIA Albert Padley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested IFs Problem
why not rewrite it to be more concise... i can't see a problem at the moment. are you sure you can do a comparison operator on the '12:00' and '2005-10-02' string?? Maybe if you are using 24 hr format you could just get rid of the : on both sides of the operator to have the properly evaluated... do the same for the date comparison. just try each if statement individually. then, when you find the problem, rewrite like this: if ((putFirstExpressionHere) (putSecondExpressionHere) (putThirdExpressionHere)) { // success } else { // failure } Jordan On Aug 31, 2005, at 3:05 PM, Albert Padley wrote: if ($row['date'] '2005-10-02') { if ($row['time'] '12:00') { if ($row['field'] == 'P5' ) { echo td class=\tabletextbluebg\Success; } } } else { echo td class=\tabletextred\Failed; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Nested IFs Problem
I have the following nested ifs: if ($row['date'] '2005-10-02') { if ($row['time'] '12:00') { if ($row['field'] == 'P5' ) { echo td class=\tabletextbluebg\Success; } } } else { echo td class=\tabletextred\Failed; } /td Whenever the 3 if statements are true, I always get the correct Success to echo. However, if any or all of the if statements are false, I never get Failed to echo. I know it's something simple, but I just can't see it at the moment. TIA Albert Padley Just shooting from the hip here, you will never get the Failed echo unless the FIRST if is false. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [SPAM] - [PHP] Nested IFs Problem - Bayesian Filter detected spam
Albert Padley wrote: I have the following nested ifs: if ($row['date'] '2005-10-02') { if ($row['time'] '12:00') { if ($row['field'] == 'P5' ) { echo td class=\tabletextbluebg\Success; } } } else { echo td class=\tabletextred\Failed; } /td Whenever the 3 if statements are true, I always get the correct Success to echo. However, if any or all of the if statements are false, I never get Failed to echo. Once the first if statement is evaluated as true, the else statement will never be executed -- regardless of the outcome of the two nested ifs. I am not sure what you are trying to accomplish here, but perhaps all three of your if conditions should be combined into one if condition ANDed () together? Or maybe the if...elseif...else structure is what you need. Hope this helps. Justin I know it's something simple, but I just can't see it at the moment. TIA Albert Padley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested IFs Problem
Albert Padley wrote: Whenever the 3 if statements are true, I always get the correct Success to echo. However, if any or all of the if statements are false, I never get Failed to echo. I know it's something simple, but I just can't see it at the moment. The code is doing exactly what you told it to do. To make it do what you what you seem to want it to do, get rid of the nested IFs and place all three tests within a single IF. -- == Eric Gorr === http://www.ericgorr.net === Government is not reason, it is not eloquence, it is force; like fire, a troublesome servant and a fearful master. - George Washington == Insults, like violence, are the last refuge of the incompetent... === -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [SPAM] - [PHP] Nested IFs Problem - Bayesian Filter detected spam
Justin Jordan, Thanks. The was what I needed. Albert Padley On Aug 31, 2005, at 2:27 PM, Justin Francis wrote: Albert Padley wrote: I have the following nested ifs: if ($row['date'] '2005-10-02') { if ($row['time'] '12:00') { if ($row['field'] == 'P5' ) { echo td class=\tabletextbluebg\Success; } } } else { echo td class=\tabletextred\Failed; } /td Whenever the 3 if statements are true, I always get the correct Success to echo. However, if any or all of the if statements are false, I never get Failed to echo. Once the first if statement is evaluated as true, the else statement will never be executed -- regardless of the outcome of the two nested ifs. I am not sure what you are trying to accomplish here, but perhaps all three of your if conditions should be combined into one if condition ANDed () together? Or maybe the if...elseif...else structure is what you need. Hope this helps. Justin I know it's something simple, but I just can't see it at the moment. TIA Albert Padley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nested IFs Problem
Jim Moseby [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have the following nested ifs: if ($row['date'] '2005-10-02') { if ($row['time'] '12:00') { if ($row['field'] == 'P5' ) { echo td class=\tabletextbluebg\Success; } // This, if there was anything, would be executed if the date and the time condition is true and the field is false } // this would be executed if the date condition is true and the time is false, regardless of what the field condition is } else { // this would be executed only if the date condition is false, regardless of the other conditions echo td class=\tabletextred\Failed; } /td So, you better put all the conditions in a single if, joined by 'and' or : if ($row['date'] '2005-10-02' $row['time'] '12:00' $row['field'] == 'P5' ) { That would do what you want -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ID based on position?
Hi there! Is there any function in PHP that gives an ID from a MySQL-db based on which position the record has in the table? Let's say, there's a table like this: 1. Record1 ID 33 2. Record2 ID 76 3. Record3 ID 100 If I know position 2, I want to get ID 76. Is the only way to loop through the recordset? /G @varupiraten.se -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ID based on position?
Gustav Wiberg wrote: Hi there! Is there any function in PHP that gives an ID from a MySQL-db based on which position the record has in the table? Let's say, there's a table like this: 1. Record1 ID 33 2. Record2 ID 76 3. Record3 ID 100 If I know position 2, I want to get ID 76. Is the only way to loop through the recordset? Why don't you use MySQL's LIMIT clause? Example: SELECT * FROM myTable LIMIT 1,1 will retrieve the second row from myTable. You could combine that with WHERE clauses or whatever. Note that the LIMIT syntax is LIMIT [rowcount] or LIMIT [offset],[rowcount] and the offset starts at 0. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ If you find my advice useful, please consider donating to a poor student! You can choose whatever amount you think my advice was worth to you. http://tinyurl.com/7oa5s -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ID based on position?
You could LIMIT your query to the record number you are looking for, and grab the last element in the array from your result set. But this is a serious hack, and I am really wondering why you need to do what your asking, it seems (without knowing more) that you are tackling the problem in the wrong direction, Jason On 8/31/05, Gustav Wiberg [EMAIL PROTECTED] wrote: Hi there! Is there any function in PHP that gives an ID from a MySQL-db based on which position the record has in the table? Let's say, there's a table like this: 1. Record1 ID 33 2. Record2 ID 76 3. Record3 ID 100 If I know position 2, I want to get ID 76. Is the only way to loop through the recordset? /G @varupiraten.se http://varupiraten.se -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ZCE Reccommendations
Chris Shiflett wrote: hitek wrote: I'm taking my ZCE exam soon and would like general advice on what to study up on. This is a good resource: http://zend.com/store/education/certification/zend-php-certification-objectives.php You picked a good month to take the exam, since it's $125 this month (normally $200). Chris Thanks for the tip. For the record, I passed :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ID based on position?
Auugh!! Why would you want to do this? You're flying in the face of relational database theory and practice. Position of a record in the table is, or should be irrelevant. What if you have twenty thousand records, or two hundred, and the 45th record in the table is deleted? Fetching an ID from anything beyond that record, based on the order of insertion (position), is instantly broken. Please rethink what you want to do, and if you are not familiar with relational databases read some of the excellent tutorials available on the 'Net about them and their design. It's pretty straightforward, common sense stuff -- but you can back yourself into an awkward corner. Regards - Miles At 07:54 PM 8/31/2005, Gustav Wiberg wrote: Hi there! Is there any function in PHP that gives an ID from a MySQL-db based on which position the record has in the table? Let's say, there's a table like this: 1. Record1 ID 33 2. Record2 ID 76 3. Record3 ID 100 If I know position 2, I want to get ID 76. Is the only way to loop through the recordset? /G @varupiraten.se -- 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] ZCE Reccommendations
On 8/31/05, hitek [EMAIL PROTECTED] wrote: For the record, I passed :) Congrats. -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php