Re: [PHP] Static utility class?
On 13-09-04 03:25 PM, Micky Hulse wrote: I want to have a utility class that contain utility methods which should have the option of being called multiple times on a page. This sounds simply like a library of functions that are implemented using objects. You can use the standard require_once in your various PHP source files so you only deal with loading the library file in the first file in which it is needed. It would not be loaded from other files. Instantiate your static variables in the library file. Again, so that only happens once. -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Static utility class?
On 13-09-04 05:09 PM, Micky Hulse wrote: Thank you so much for the quick and very informative/educational replies Stephen and David, I really appreciate it! :) On Wed, Sep 4, 2013 at 12:36 PM, Stephen stephe...@rogers.com wrote: This sounds simply like a library of functions that are implemented using objects. Instantiate your static variables in the library file. Again, so that only happens once. functions implemented using objects sounds like exactly what I want. Just out of curiosity, and sorry in advance for my ignorance, but does the code I posted fit that type of pattern? If not, what would I need to modify and how would I call it? Actually, I should probably spend some time Googling before I ask you for more details. :D Well, your code does not take advantage of the features of classes, but the syntax is correct. Global, static variables are not consistent with the design concepts of OOP. But as a first step in moving from procedural code to OOP, which is learning the syntax, go for it. -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP vs JAVA
On 13-08-20 10:00 AM, Tedd Sperling wrote: Hi guys: A teacher at my college made the statement that JAVA for Web Development is more popular than PHP. Where can I go to prove this right or wrong -- and/or -- what references do any of you have to support your answer? (sounds like a teacher, huh?) Here are my two references: http://w3techs.com/technologies/details/pl-php/all/all http://w3techs.com/technologies/history_overview/programming_language/ms/y But I do not know how accurate they are. I think you can use w3techs.com as a very reliable source. But your teacher may have been talking about javascript which is not the same thing as java despite the similarity in their names. Javascript is part of the web page, and executes in the users browser. It is very common and may rival PHP in frequency of use. -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP vs JAVA
On 13-08-20 10:19 AM, Tedd Sperling wrote: On Aug 20, 2013, at 10:04 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Is he possibly getting confused with Javascript? Thanks, Ash No, this guy is smarter than that -- he's pretty sharp -- so I listen to what he has to say. Here's an interesting link: http://www.sitepoint.com/best-programming-language-of-2013/ But the link does not divide languages between Web and Other -- other than Android Java, which I do not believe is also included in the above Java number. I think there is more going on here than what I know. For example, my college has numerous (over 3) JAVA classes filled to the max, whereas my PHP class was canceled due to lack of students. Granted the college could have advertised my PHP class more, but still there is an overwhelming demand for Java Programmers. My questions is Why? I think that the overwhelming majority of Android apps are written in JAVA. That explains its popularity. -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strlen ?
On 13-07-05 02:50 PM, Jim Giner wrote: Now the question is - how the heck did I put that in there? Certainly not intentionally. The data is captured from a d/e screen I wrote and it simply grabs the post value and inserts a new record with that value along with some other values. And I don't see anything concatenating a LF to my string. Is this a browser being used for input? Never assume what a browser will do. It is good practice to validate and condition data before inserting into a database. Consider trimming the data before doing the INSERT. -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] browser rendering
On 13-06-02 09:09 AM, georg wrote: Possibly this issue is for other fora, which you might direct me, anyways; I have been dablling making my own little webpages, however having gotten a nice result jon fireforx, I realize picture sizes gets treated very differntly on different browsers !!! so the looks of the pages get very strange from smaller (Opera) and much bigger (Explorer) brower !!! img src=smiley.gif alt=Smiley face height=42 width=42 The img tag supports specifying the height and width. -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for a good working PDO and/or mysqli database class to get started with OOP
On 13-05-30 09:36 PM, dealTek wrote: Hi all, Thanks for your help... I'm looking for a very good, pre made, working PDO and/or mysqli database class (in a wrapper) - to get started with, that has all the basic needs like UPDATE - INSERT - DELETE - QUERY etc. That would be very helpful. I'm also trying to learn OOP, and creating my own class to start out is over my head, so one that is recommended here would be a good start. Hmmm. PDO **IS** an OOP implementation. Why would you want to encapsulate it? Accessing a database requires SQL with arguments dependant on YOUR database schema. You have to do that work; there is no way around it. -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random
On 13-05-23 04:51 PM, Last Hacker Always onpoint wrote: Hey I need code for random number 1-30 for my site. http://php.net/manual/en/function.rand.php -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Is BBCode Installed
On 13-04-12 02:28 AM, shiplu wrote: On Fri, Apr 12, 2013 at 4:24 AM, Stephen stephe...@rogers.com mailto:stephe...@rogers.com wrote: Now I have to install on my home development machine! You can install it by following command pecl install bbcode Note: root privilege is necessary to install Thank you. Very easy! I will add that an entry must be added to php.ini to be able to utilise this module. When the command has completed execution, the entry is shown in the command window. -- Stephen
[PHP] Re: Is BBCode Installed
On 13-04-10 10:05 PM, Stephen wrote: I ran phpinfo() on my host and searched for BBCode. Not found. Does this mean that the extension is not installed? If not, how can I tell? Thanks I am quite impressed with my host, hostpapa.ca I put in a ticket, and in 8 hours then enabled bbcode for my account! And I am on a shared server. When enabled, it does show up on phpinfo() Now I have to install on my home development machine! -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is BBCode Installed
I ran phpinfo() on my host and searched for BBCode. Not found. Does this mean that the extension is not installed? If not, how can I tell? Thanks -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Is BBCode Installed
On 13-04-10 10:59 PM, David Robley wrote: I ran phpinfo() on my host and searched for BBCode. Not found. Does this mean that the extension is not installed? If not, how can I tell? Thanks BBCode isn't a php extension, but may be implemented using php or other languages. See http://www.bbcode.org/ for more info. Thank you for replying, but: http://php.net/manual/en/book.bbcode.php Introduction This extension aims to help parse BBCode text in order to convert it to HTML or another markup language. It uses one pass parsing and provides great speed improvement over the common approach based on regular expressions. Further more, it helps provide valid HTML by reordering open / close tags and by automatically closing unclosed tags. -- Stephen
Re: [PHP] Lasting syntax error when there's none
You first step is to check the log files. No matter how sure we are that there is no syntax error, always start with the logs. It could be a file permission problem. Stephen On 13-04-09 11:00 AM, fr...@me.com wrote: Hi everyone, I have some weird problem with PHP compiler or something of this sort of things. We have some PHP files which are generated during the first request to the site. These files are normally executed via PHP then. For some reason PHP thinks that they contain syntax errors (verified using HTTP request, or `php -l`). I've found out it is extremely easy to resolve this issue manually when developing - simply renaming or touching that file resolves the issue. So, apparently those generated PHP files don't contain any syntax error. However, PHP thinks they do even across different SAPIs (CLI and FPM). Since fixing the issue in this manner doesn't seam reasonable even by some script on production, I'd like to know whether do you have any suggestion what settings to tweak or what might be the problem. Here is some information about the environment (feel free to ask for more): - PHP version: 5.3.10-1ubuntu3.6 - SAPI: FPM and CLI - OS: Ubuntu 12.04 - Software: Ubuntu packages only (updated) - HTTP request handling: nginx load balancer ? PHP FPM daemon - Machine: VMware Fusion (managed by Vagrant) hosted on OS X 10.8.3 Thanks, -- Stephen
Re: [PHP] Complex MySQL query for lowest price
While complex, this is standard SQL. But this is a PHP list :( The way to construct the statement is to use a nested select. Something like this SELECT blah with variable blah WHERE ( SELECT value within dates and assign to variable) To go further I would need to play, and I don't have the database. I suggest you visit the great web site sitepoint.com. There are great SQL people to help you there. Stephen On 13-01-31 02:21 PM, Angela Barone wrote: Hello, I have a formula that says, if 'specialprice' is not empty and it is lower than 'unitprice', use 'specialprice', otherwise use 'unitprice': ?php $result = mysql_query(SELECT LEAST(unitprice,ifnull(specialprice,'')) AS used_price FROM catalog WHERE itemid='WB1836C',$db); printf('bfont color=#55Your Price:/font $%s/bbr /', number_format(mysql_result($result,0,used_price),2)); ? What I'd like is to add a starting and ending date and if today's date is between those dates, then do the above formula, otherwise if today's date is not between those dates, then just use 'unitprice'. This is starting to get too complex for me, so I need some help. ;) Hopefully this makes sense. If I need to be clearer, please let me know. Thanks! Angela -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP programming a members only access site
Can anyone point me to good tutorials/documentation on the subject? I want to add this functionality to one of my sites. I know there are existing solutions for this, but the ones I have found are complex, turnkey and don't really facilitate learning. I consider myself strong in php programming and using MySQL. But I have never used sessions or cookies, and want to learn and do it properly. And I am interested in the security of logins and credentials. Things like detecting sharing of credentials and the appropriate action to take. Also what logs to keep and how to audit them. And, of course, having sample code for functions like creating a new account, sending the confirmation email, handling the response. Dealing with forgotten passwords. I don't want to re-invent the wheel, but I don't want to have to dissect the code for, say, phpBB to see how it is done there, either. Thanks in advance for suggestions! -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Boolean type forced on string assignment inside if statement
On 13-01-02 10:53 AM, Marc Guay wrote: Hi folks, if ($a = foo $b = bar){ echo $a.br /.$b; } Returns: 1 bar I expect: foo bar Is this documented? takes precedence over = http://php.net/manual/en/language.operators.precedence.php You may want to use brackets -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable placeholders in a text file
Yes! Easy standard stuff. $title = 'Mr.; $user_name = 'John Doe'; $message = Hello $title $user_name Just define the value for the variables before defining the value for the message. Note that $message has to use double quotes for the expansion. Also consider using HEREDOC instead of the double quotes. You may want to put your message in a text file and using the include function. On 12-12-31 02:39 PM, Nelson Green wrote: Hello, I have created a simple function that prints a personalized greeting by reading the greeting contents from a file. I pass the user's name to the function, and the function reads the file contents into a string variable. I am then using str_replace to replace the word USER in the string with the user's name that was passed to the function. Then the function correctly prints the personalized greeting as I wish. My question is, is there another way to do something similar, such as embedding a variable name directly into the text file? In other words, instead of my text file reading: Hello USER ... Can I do something like this: Hello $user_name ... and then write my function to replace $user_name with the passed parameter prior to printing? The reason I ask is because I am going to want to do three substitutions, and I'd rather not do three str_replace calls if I don't have to. Plus the latter seems to be a more robust way of making the changes. Thanks, and apologies if this has been asked before and I missed it. I'm just not sure how to phrase this for a search engine. Nelson -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable placeholders in a text file
On 12-12-31 03:37 PM, Nelson Green wrote: On Mon, 31 Dec 2012 14:47:20 Stephen D wrote: Yes! Easy standard stuff. $title = 'Mr.; $user_name = 'John Doe'; $message = Hello $title $user_name Just define the value for the variables before defining the value for the message. Note that $message has to use double quotes for the expansion. Also consider using HEREDOC instead of the double quotes. You may want to put your message in a text file and using the include function. Hi Stephen, My message is in a text file, but I'm using fopen and fread in a self-defined function, so message is actually defined as (GREETER_FILE is a defined constant): function print_greeting($user_name) { $handle = fopen(GREETER_FILE, r); $message = fread($file_handle, filesize(GREETER_FILE)); $msg_text = str_replace(USER, $user_name, $message); print($msg_txt); } And my text file is simply: $cat greet.txt Hello USER. How are you today? If I change USER to $user_name in the text file and change the print function parameter to $message, $user_name gets printed verbatim. In other words the greeting on my page becomes: Hello $user_name. How are you today? I want to pass the name Nelson to the function, and have it output: Hello Nelson. How are you today? after the function reads in text file input that contains a variable placeholder for the user name. I actually had a HEREDOC in the function, and that worked. But by reading a file instead, I can make things more flexible. I'd rather be changing a text file instead of a code file. The reason you get $user_name printed is because of the way you are populating the variable $message. You need to have $user_name embedded in double quotes or a HEREDOC when PHP parses $messsage. And $user_name has to have already been defined. Here is a sample from one of my sites. It is a simple one for the contact page. =contact.php ?php $thispage = Contact; $contenttop = p$thispage/p; $contentbody = HEREDOC pstep...@roissy.ca/p HEREDOC; require_once include.php; require_once utilities.php; echo $header . $markup; = The common stuff for every page is defined in the file include.php. I define the variable $markup in that file. Here is the definition for $markup $markup=HEREDOC body div id=all div id=top img src=$titlepng alt=$title / /div div id=main div id=mainrow div id=left $leftimage div id=mainnav ul $menu /ul /div /div div id=content div id=content-top $contenttop /div div id=content-body $contentbody /div div id=content-bottom /div /div /div /div div id=footer $copyright /div /div /body /html HEREDOC; There is lots more code, but this is the important stuff. By using require_once instead of fopen and fread, I have simpler code and PHP evaluates the embedded variables in $markup without any need to use string functions. In your case, I would make the file greeter.php =greeter.php=== $message = Hello $user_name. How are you today? === You replace the fopen and fread stuff with a require_once function and $message gets included and the user name resolved all in one line of code. Hope this helps -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQLi
I read about the subject in another thread. Where does PDO fit? That is what I have used for sometime. Am I good? -- Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Compiling the SQLite3 Package on Windows
I'm new to PHP and need some help with compiling packages . I'm trying to install the php-sqlite3 class file (php-sqlite3.php) using a source files from PECL. The instructions say 1. unzip untar the package 2. run phpize 3. run ./configure --with-sqlite3=c:\sqlite3 4. make make install 5. (optionally) copy DB/sqlite3.php to /path/to/php/lib/php/DB/sqlite3.php The PHP development environment is installed on Windows Vista. The sqlite3 sources reside under c:\php-sdk\php53dev\vc9\x86\php-5.3.10\ext\sqlite3-0.5 And I'm running the phpize, configure commands directly under sqlite3-.0.5. I'm getting the following error during step 3... configure -with Error: Must be run from the root of the extension source. I'm pretty sure that I'm getting this error because the sqlite3 package that I downloaded is missing the config.w32 file and I'm not sure why this file is missing from the package. Stephen Landry SAP Release Engineering 245 First Street 16th Floor Cambridge, Mass 02139 Phone: 617-715-7437 Cell: 603-247-8722
Re: [PHP] Strange foreach reference issue
I cut and pasted your code and got the same result. I flipped the two foreach blocks and got the expected results. I deleted the first block and copied the second, then updated the string. I got this. I can't explain. ?php $row_list = array( array( 'Title' = 'Title #1', ), array( 'Title' = 'Title #2', ), array( 'Title' = 'Title #3', ) ); printRows are: . print_r($row_list, true); foreach ($row_list as $idx = $row) { print Title A $idx: {$row['Title']}\n; } printRows are now: . print_r($row_list, true); foreach ($row_list as $idx = $row) { print Title B $idx: {$row['Title']}\n; } Rows are: Array ( [0] = Array ( [Title] = Title #1 ) [1] = Array ( [Title] = Title #2 ) [2] = Array ( [Title] = Title #3 ) ) Title A 0: Title #1 Title A 1: Title #2 Title A 2: Title #3 Rows are now: Array ( [0] = Array ( [Title] = Title #1 ) [1] = Array ( [Title] = Title #2 ) [2] = Array ( [Title] = Title #3 ) ) Title B 0: Title #1 Title B 1: Title #2 Title B 2: Title #3 On 12-01-07 06:29 PM, Tim Behrendsen wrote: Hello, This sure looks like a bug, but maybe there's some subtlety going on that I don't understand, so I would appreciate some insight. After much debugging, I tracked down a bug in my code to this test program. My PHP version is 5.3.3, running under Fedora Linux. ?php $row_list = array( array( 'Title' = 'Title #1', ), array( 'Title' = 'Title #2', ), array( 'Title' = 'Title #3', ) ); printRows at start: . print_r($row_list, true); foreach ($row_list as $idx = $row) { print Title A $idx: {$row['Title']}\n; } printRows are now: . print_r($row_list, true); foreach ($row_list as $idx = $row) { print Title B $idx: {$row['Title']}\n; } ? When you run the program, it gives the following output: -- Rows at start: Array ( [0] = Array ( [Title] = Title #1 ) [1] = Array ( [Title] = Title #2 ) [2] = Array ( [Title] = Title #3 ) ) Title A 0: Title #1 Title A 1: Title #2 Title A 2: Title #3 Rows are now: Array ( [0] = Array ( [Title] = Title #1 ) [1] = Array ( [Title] = Title #2 ) [2] = Array ( [Title] = Title #3 ) ) Title B 0: Title #1 Title B 1: Title #2 Title B 2: Title #2 -- Note that the second foreach repeats the second row, even though the index is correct and the print_r shows things as correct. Now, if you change the name of the reference variable from '$row' to '$rowx' (for example), things will work. So clearly there's some issue with $row being previously used as a reference that's contaminating the subsequent use of $row in the foreach. If there's some logic to this, it's escaping me. Any insight on this would be appreciated. Regards, Tim Behrendsen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange foreach reference issue
On 12-01-07 07:30 PM, Tim Behrendsen wrote: When you use an ampersand on the variable, that creates a reference to the array elements, allowing you to potentially change the array elements themselves (which I'm not doing here). http://www.php.net/manual/en/control-structures.foreach.php I do notice in the manual that it says, Reference of a $value and the last array element remain even after the foreach loop. It is recommended to destroy it by unset(). But that doesn't really explain why it contaminates the next foreach loop in such an odd way. You would think that the $row in the second loop would be assigned a non-reference value. Tim Tim, You are using the $variable in an unintended (by PHP designers), and I suggest undefined manner. So the outcome cannot, but definition be explained. Was this intended, and what were you trying to accomplish? Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Syntax problem PDO and bindvalue
So I am getting this SQL error: Error selecting photographs: SQLSTATE[42000]: Syntax error or access violation: 1064 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 ''4'' at line 2 My code is: function updatephotos($dbh, $x) { echo $x['number'] . br /; this echo is 4 $sql = SELECT * FROM photographs WHERE photo_filename LIKE '%2%' LIMIT 0, :q;; $stmt = $dbh-prepare($sql); try { $stmt-bindValue( ':q', $x['number'], PDO::PARAM_INT ); $stmt-execute(); } catch (PDOException $e) { return 'Error selecting photographs: ' . $e-getMessage(); } while ( list( $id, $name, $alt, $caption) = $stmt-fetch(PDO::FETCH_NUM)) { echo $name . br /; } return test worked ; } If I hard code the SQL as: $sql = SELECT * FROM photographs WHERE photo_filename LIKE '%2%' LIMIT 0, 4; all works well. Can anyone see what is wrong? How can I see the prepared SQL statement before it is executed? Thanks Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about best practice for coding sql statements
On 11-11-12 06:30 AM, tamouse mailing lists wrote: I'm curious how others feel about this. When I'm creating an SQL string, either for a non-prepared or prepared execution, I build it in a variable and then pass the variable to the query or prepare function. This lets me easily add something to view the SQL statement, and also if there's an error, emit the SQL statement. Thus: $sql = SELECT * FROM TABLE WHERE id=$id; if ($debug) error_log($sql. from .__FILE__.' at '.__LINE__' in '__FUNCTION__.PHP_EOL); // just an example $rslt = $db-query($sql) or die(Could not get result from $sql: .$db-errno.: .$db-error...PHP_EOL); and so on... While I am not a big fan of OOP, I do like PDO, and recommend its use. This is a sample function I have to maintain a record based on POSTed changes: function updatecategory($dbh, $x) { $sql = UPDATE gallery_category SET category_name = :name, category_description = :description WHERE category_id = :id; $catname = fieldcheck($x['catname']); $catdescription = textfieldcheck($x['catdescription']); $stmt = $dbh-prepare($sql); try { $stmt-bindParam(':name', $catname); $stmt-bindParam(':description', $catdescription); $stmt-bindParam(':id', $x['cid']); $stmt-execute(); } catch (PDOException $e) { return 'Error updating category orders: ' . $e-getMessage(); } return Maintained category . $catname; } PDO is very efficient when you are looping through updates, and the error handling is simple to code. Using a disciplined format keeps everything readable and easy to use as a template for additional work. Cheers Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create file after form completion
On 11-10-29 12:38 PM, Pau wrote: Dear all, I am looking for information on how to have a file created after a user has hit a submit on a registration form. This is a subject that will take a bit of your time to understand. This web site is a good place to start: http://www.tizag.com/phpT/examples/formex.php You need to create an HTML form in your web page. The form specifies the PHP file that is the form handler. When the user clicks submit, their web browser calls your file that is the form handler and passes to it the data that they entered. Exactly what your form handler does is up to you. You can: Respond to the user Save the data in a file or database Email the data Good luck Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seeking strategy/algorithm for maintaining order of records
On 11-10-16 04:10 PM, Jim Giner wrote: Stephen: What you describe is a multistep problem. There are many ways to show pictures (images) in any order you want. * So far, the OP has only asked how to keep his categories in order. Curious, yes, but he hasn't even asked how to display the images in order - maybe he doesn't care about that.. Well, I want to deal with one part of the design at a time :) Thanks to all who replied. This is a collective response. Displaying in an order is easy when you have a field called order. SELECT descriptions FROM categories ORDER by order; My issue is, say I have three records: ID CategoryOrder 1BW1 2Landscapes 2 3Nudes 3 I am looking for the best way to be able to change the values to ID CategoryOrder 1BW3 2Landscapes 2 3Nudes 1 Dynamically building a form, entering the new order value, and then looping through the post, with a SQL UPDATE is the best I can come up with. A future issue will be doing the same to the table category-photograph ID Category_id photo_id order This table is needed to allow a photograph to be in more than one category. Cheers Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Seeking strategy/algorithm for maintaining order of records
I am building a site for my photography. The photographs are displayed by category. The category table has a field for order In my control panel I want to be able to change the order of the categories by changing the values in the category field. I can dynamically build a form of all categories and have a field for new order number, Then loop through the POST and update the values. The field is not unique, so I am not worried about DB errors. But I wonder if there is a better way. Thoughts please? Thank you Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Processing newlines in a text area field
On 11-10-14 04:25 PM, Richard Quadling wrote: On 14 October 2011 03:49, Stephenstephe...@rogers.com wrote: I have a web page with a form with a text area. I enter: foo bar PHP processes the POST and inserts the record into MySQL. The database field is text. I use PDO For testing I have removed any processing of the text area content. Now, no matter how many blank rows I have between foo and bar, in the database record, I always get a single newline character. I am using Firefox 7.0.1. Is this normal behaviour? I want to be able to enter more than 1 newline. Thanks Stephen What is the wrap attribute set to on the textarea? I do not have a wrap attribute. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Processing newlines in a text area field
On 11-10-13 10:49 PM, Stephen wrote: I have a web page with a form with a text area. I enter: foo bar PHP processes the POST and inserts the record into MySQL. The database field is text. I use PDO For testing I have removed any processing of the text area content. Now, no matter how many blank rows I have between foo and bar, in the database record, I always get a single newline character. Found the problem. I was not passing the record key properly to the SQL UPDATE transaction. So I had WHERE id = Valid SQL so no error. But no record update :( Thanks all Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Processing newlines in a text area field
I have a web page with a form with a text area. I enter: foo bar PHP processes the POST and inserts the record into MySQL. The database field is text. I use PDO For testing I have removed any processing of the text area content. Now, no matter how many blank rows I have between foo and bar, in the database record, I always get a single newline character. I am using Firefox 7.0.1. Is this normal behaviour? I want to be able to enter more than 1 newline. Thanks Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php.ini setting
On 11-10-02 12:12 PM, Jim Giner wrote: Spoke to quickly - still having issues. While the .ini file in each of my appl. folders has magic quotes set to Off, my scripts are still escaping my input - obviously following the server's .ini file settings. Waiting for my hosters to get back to me. You could refer them to: http://php.net/manual/en/security.magicquotes.php Indicate that magic quotes have deprecated, and ask them to turn them off. But they will say no, because of all the other users on the server that you use. In the end, you will be left with stripping the slashes on your own: ?php if (get_magic_quotes_gpc()) { $process = array($_GET, $_POST, $_COOKIE, $_REQUEST); while (list($key, $val) = each($process)) { foreach ($val as $k = $v) { unset($process[$key][$k]); if (is_array($v)) { $process[$key][stripslashes($k)] = $v; $process[] = $process[$key][stripslashes($k)]; } else { $process[$key][stripslashes($k)] = stripslashes($v); } } } unset($process); } ? I know it is not the answer you are looking for, but it does work, and used by thousands of coders. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini setting
On 11-10-01 11:57 AM, Jim Giner wrote: I'm trying to set magic quotes Off as my reading tells me that it's not good to have it defaulted to On. http://php.net/manual/en/security.magicquotes.disabling.php Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Integers
On 10-06-30 10:02 PM, David McGlone wrote: Hi again I'm trying to learn about octal numbers and I don't understand this: Binary: 00100010 breakdown: (001)= 1 (000)= 0 (101)=5 (111)=7 I know it's similar to unix permissions, but I'm not understanding where for example: 111 = 7 In base 10, which you use every day, we go 0 1 2 3 4 5 6 7 8 9 10 The number 10 is the number of distinct digits we use. In binary we only us two, 0 and 1, so 10 is 2 decimal So we go 0 = 0 decimal 1 = 1 important 10 = 2 important 11 = 3 100 = 4 important 101 = 5 110 = 6 111 = 7 So binary 111 is 4 + 2 + 1 = 7 Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variables in tmp
Thanks Gerardo. I send a large dump.sql file to my /tmp dir and filled up the remaining space so PHP was not able to write any more session variable. Took me a little while to figure that one out. Thanks for your response. On Tue, 08 Jun 2010 12:00:23 -0400, Gerardo Benitez gerardobeni...@gmail.com wrote: Hi Stephen, you can try setting the session path using session_save_path http://www.php.net/manual/en/function.session-save-path.php. Gerardo www.webseficientes.com.ar On Sat, Jun 5, 2010 at 2:18 AM, Stephen Sunderlin stephen.sunder...@verizon.net wrote: trying out a CentOS release 5.2 (Final) V4_1_0 on AWS. Was working fine and now it seems that php has stopped writing any session variable to /tmp. I was cleaning up the user table in mysql and limiting permissions. Not sure that this would have anything to do with it. Restarted apache/mysql. tmp is set to drwxrwxrwt 4 root root 4096 Jun 5 00:46 tmp PHP 5.2.4 MySQL 5.0.45 any thought on where else to look. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [Bulk] [PHP] Inserting rows with missing IDs
Andre Polykanine wrote: Hello everyone, It's not a strictly PHP question, however since I use that with PHP, I'm asking it there. How can I accomplish the task of inserting rows into MySql database with missing IDs? Say, I have rows with IDs 1, 2, 3, 5, 9, 12, 17, and 195. How do I make the check that allows to insert firstly the missing IDs and only then apply the auto-increment? Thanks Almost certainly you should not want to. The ID should simply be unique, and have no inherent meaning. Why do you care if there are gaps? But if you must, just select the IDs, put them in an array, and query the elements. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math Question....
Dan Joseph wrote: I want to take a group of items, and divide them into equal groups based on a max per group. Example. 1,252,398 -- divide into equal groups with only 30 items per group max. 1,252,398 DIV 30 = 41,746 groups of 30. 1,252,398 MOD 30 = 18 items in last group Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP MySQL Insert Statements
Martine Osias wrote: My insert statements on this web page don't execute. The select statements do work. This tells me that the database connection is working. The username and password are the administrator's. What else could prevent the insert statements from executing? Most likely syntax of the insert statement. Do your insert statements work if used in MySQL Query Browser? What is MySQL returning? Are you using OOP or old functions? Have you tried having PHP echo your insert statement so you can see exactly what you are sending MySQL? Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What method is best for generating thumbnails in PHP from PDF's?
--- On Thu, 11/12/09, Chris Payne chris_pa...@danmangames.com wrote: I have been asked to create thumbnails from the first page of a PDF document on the fly with PHP, I have looked online but am confused as there doesn't seem 1 simple solution. Go to sitepoint.com and search for photo gallery in minutes Excellent article. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IRC and English
Paul M Foster wrote: I'm sorry, but is anyone else annoyed by people who attempt to use IRC jargon on mailing lists? For example, substituting u for you. Oddly enough, I'm seeing this primarily in foreign language posters, not in native English speakers. It's often accompanied by English so broken I don't even bother trying to decypher it, and sometimes an *attitude* (after which, I blacklist the poster). Am I the only one? It's okay if I am. Just wondering. IRC ?? I haven't used that in years. :) More likely it is the habits learned in texting carrying over to email. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDO - Nested selects allowed?
For my photography website, I have a photo gallery, and the user first sees a list of categories. They can click down to see thumbnails, and again to see individual photographs. I want to enhance this to, with the category listing, show the first thumbnail. I have a category table, a photo table and the photos and thumbnails are files. The photo table has a category_id column and a filename column. Now, I Googled a bit, and it is not clear that i) Select the categories ii) Loop through the result set iii) Within the loop select the filename will work Does the select within the loop clobber the result set of the category selection? I saw suggestions to fetch the entire result set into a PHP array, or to use |$dbh-setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); The queries I have created are: $categoryquery = 'SELECT c.category_id, c.category_name, c.category_description, COUNT(photo_id) FROM gallery_category as c LEFT JOIN gallery_photos as p ON p.photo_category = c.category_id GROUP BY c.category_id ORDER BY c.category_order'; $catthumbquery = 'SELECT photo_filename FROM gallery_photos WHERE photo_category=:cid ORDER BY photo_order LIMIT 1'; and the PHP code I have drafted is: try { $stmt = $dbh-prepare($categoryquery); $stmt-execute(); while ($row = $stmt-fetch(PDO::FETCH_ASSOC)) { $id = $row['category_id']; $name= $row['category_name']; $description = $row['category_description']; $count = $row['COUNT(photo_id)']; $stmt2 = $dbh-prepare($catthumbquery); $stmt2-bindParam(':cid', $id, PDO::PARAM_STR); $stmt2-execute(); $result_array[] = \t\tdiv class=\categoryname\\n . \t\t\ta href=\viewgallery.php?cid= . $id . \ . $name . /a ($count)\n\t\t/div\n \t\tdiv class=\categorydescription\ . \n\t\t\t$description\n\t\t/div; } } catch (PDOException $e) { echo Building category list failed: . $e-getMessage(); } Thanks to those who can help! Stephen | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Forms validation and creation- easier solution?
Tony Marston wrote: Your ideas are similar to mine, but I have a much more advanced implementation which involves the use of a Data Dictionary. After building a database table I import the structure into my data dictionary, then export it to create a database table class and a table structure file. Still using the data dictionary I can then build the family of transactions to maintain that database table. This uses a standard set of page controllers and XSL templates to build the HTML. So within 5 minutes I can run the transactions to list, search, add, enquire, delete and update that database table without having to write a single line of SQL or HTML. In most cases I don't even have to write a single line of PHP. Is your method as fast as that? All this functionality exists within the Radicore framework, so you can download it and try it for yourself. Thank you! I am moving out of do it hand to learn how it is done into how can I get this work done quickly and well and you point me to Radicore! Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] product listing columns
PJ wrote: I am about to bust my donkey again trying to set up a dynamic product listing for a web page using mysql, php CSS (the donkey ride). What better place to ask than here in guru heaven: 1. What's a good list/forum to ask for help on CSS - it just is too illogical. I suggest you take a look at sitepoint.com, for all aspects of web building and design. 2. With mysql, is the best way to populate list columns with ul and li or would just a simple column work fine? I have done this with a left navigation column and could repeat such columns next to each other with the final column with input fields for quantities ordered. Background could just be an image to fill the container div. Does that sound about right? Thanks for any suggestions. It seems to me that you are actually building a table and should use html tables. With css for the layout and formatting, of course. :) Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSS tables
Nathan Rixham wrote: tedd wrote: At 7:48 PM -0400 5/16/09, Stephen wrote: PJ wrote: I know of no better place to ask. This may not be strictly a PHP issue, but... I am busting my hump trying to format rather large input pages with CSS and trying to avoid tables; but it looks to me like I am wasting my time as positioning with CSS seems an impossibly tortuous exercise. CSS 2.1 makes layout easy ans IE8 passes ACID2. I have some javascript that detects the browser and warns users of IE 8 that they need to upgrade. Maybe bleeding edge for commercial sites, but helping the user upgrade is going them a favour. Stephen Stephen: Browser sniffing is a losing battle. Cheers, tedd agreed - complete and utter waste of time If someone wants to mask their browser, so be it. They will see a false warning, or miss a useful one. Standards exist for a reason. Web designers have wasted eons of man years accommodating Microsoft's incompetence. Finally getting things right takes some people to start, and it is those of us without a commercial need to be friendly to IE 8. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSS tables
PJ wrote: I know of no better place to ask. This may not be strictly a PHP issue, but... I am busting my hump trying to format rather large input pages with CSS and trying to avoid tables; but it looks to me like I am wasting my time as positioning with CSS seems an impossibly tortuous exercise. CSS 2.1 makes layout easy ans IE8 passes ACID2. I have some javascript that detects the browser and warns users of IE 8 that they need to upgrade. Maybe bleeding edge for commercial sites, but helping the user upgrade is going them a favour. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSS tables
Robert Cummings wrote: On Sat, 2009-05-16 at 19:48 -0400, Stephen wrote: PJ wrote: I know of no better place to ask. This may not be strictly a PHP issue, but... I am busting my hump trying to format rather large input pages with CSS and trying to avoid tables; but it looks to me like I am wasting my time as positioning with CSS seems an impossibly tortuous exercise. CSS 2.1 makes layout easy ans IE8 passes ACID2. I have some javascript that detects the browser and warns users of IE 8 that they need to upgrade. Maybe bleeding edge for commercial sites, but helping the user upgrade is going them a favour. Stephen Tell that to government... many, and in some departments most, are still using IE6. I'm quite sure they won't appreciate me telling them it's time to upgrade. On the plus side though, MediaWiki is breaking ground :) Cheers, Rob. My sites are still viewable, and can be navigated. They just look strange. Government workers are used to strange :) Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to deal with identical fields in db
PJ wrote: I'm coming up with a bit of a quandry: how to enter and retrieve an identical book title with different authors. It is rather unbelievable what contortions one finds as authors :-( like editors, associations and then the unknowns and anon y mouses. I suppose one has to get really creative... Anyone for tea? You should have a title_id field in your titles table, and this field should be unique. Probably auto assigned and auto increment. If you search for a book title, and there are two books with that title, you should get two records back! Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help me debug this
Patrick Moloney wrote: I've tried their help forum, but they keep telling me to create an empty database. Have you tried creating an empty database? Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Simple XML in PHP
HI all, How would a get this video from XML. /***Example i want to View***/ media:content url=http://video-cdn.abcnews.com/090324_gma_leamy.flv; lang=en width=424 height=318 type=video/x-flv / /**/ /**XML CODE***/ titleInvestigating Toxic Drywall/title linkhttp://feedproxy.google.com/~r/AbcNews_Health_Videos/~3/d5ewEbco-js/playerIndex/link descriptionChina-made drywall could be leaching noxious gases into homes.lt;img src=http://feeds2.feedburner.com/~r/AbcNews_Health_Videos/~4/d5ewEbco-js; height=1 width=1/gt;/description pubDateTue, 24 Mar 2009 10:20:04 -0400/pubDate live:origReleaseDateTue, 24 Mar 2009 10:20:04 -0400/live:origReleaseDate media:titleInvestigating Toxic Drywall/media:title media:descriptionChina-made drywall could be leaching noxious gases into homes./media:description media:keywordsdrwall, toxic, china, building, house, health/media:keywords media:ratingnonadult/media:rating media:thumbnail url=http://a.abcnews.com/images/GMA/abc_gma_leamy_090324_mn.jpg; width=320 height=240 / media:thumbnail url=http://a.abcnews.com/images/GMA/abc_gma_leamy_090324_mc.jpg; width=100 height=75 / media:thumbnail url=http://a.abcnews.com/images/GMA/abc_gma_leamy_090324_mv.jpg; width=264 height=198 / media:content url=http://video-cdn.abcnews.com/090324_gma_leamy.flv; lang=en width=424 height=318 type=video/x-flv / media:categoryHealth/media:category /*PHP CODE EXAMPLE**/ $cnt = count($xml-channel-item); for($i=0; $i$cnt; $i++) { $url= $xml-channel-item[$i]-link; $title = $xml-channel-item[$i]-title; $desc = $xml-channel-item[$i]-description; $pubDate = $xml-channel-item[$i]-pubDate; echo ' '.$url.' '.$title.' '; echo br /; echo $desc; echo br /; echo $pubDate; echo br /; echo br /; } -- View this message in context: http://www.nabble.com/Simple-XML-in-PHP-tp22690831p22690831.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Intermittent problem sending mail with PHP
thanks Jim - I change over to SwiftMailer and its working well. Jim Lucas li...@cmsws.com wrote in message news:49ae0375.2040...@cmsws.com... Stephen Hutchison wrote: I'll check with my ISP but if is that then it's a very low limit. I'm finding it's only allowing two or three through before hanging. Is there something i can put in my code so that it at least fails gracefully? It's not a good look just hanging like that. Thanks Stephen Chris dmag...@gmail.com wrote in message news:49ada6ab.5060...@gmail.com... Stephen Hutchison wrote: This appears to by a problem with the mail function. When I comment out the lines: if (mail($recipient, $subject, $message, $headers)) echo 'Succeededbr'; else echo 'Error - please check your e-mail addressbr'; More likely a mail server issue rather than the mail function itself. Do they have any restrictions on how often you can send email? (Some hosts only let you send say 50 emails an hour). Log everything you're trying to do in php (log when it works, when it doesn't) and include a timestamp - then get your host to look at their mail server logs for the failure times and see what shows up. -- Postgresql php tutorials http://www.designmagick.com/ I would recommend getting away from using the mail() function altogether. I would look into using something like phpmailer or SwiftMailer. They are SMTP mail classes that let you build and email and send it directly to your SMTP server. Also allows you to log into the mail server with a valid email account and send using that account. That last part might get you around the X/minute email limit or whatever else it might be. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Intermittent problem sending mail with PHP
I've set up a small website which allows users to create a form letter and email it to their local candidates in the upcoming state election. The user enters their email address, town/suburb and message into an html form and clicks the Send button. The site then sends an email to each candidate for their area. The email is plain text and only about 3k in size. The problem I'm having is that it works fine for the first few tests but any messages after that it just hangs for 5 minutes before giving a time-out message. When it's working it goes through without any delay. If I leave for say anther half an hour its back working again. I send a couple more test messages its all good, but and then it hangs again. How can I troubleshoot this intermittent problem? My ISP is running PHP on an IIS server. It seems like a server issue. Thanks Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Intermittent problem sending mail with PHP
This appears to by a problem with the mail function. When I comment out the lines: if (mail($recipient, $subject, $message, $headers)) echo 'Succeededbr'; else echo 'Error - please check your e-mail addressbr'; and replace them with: echo $recipient . 'brbr'; echo $subject . 'brbr'; echo $message . 'brbr'; echo $headers . 'brbr'; it displays to the screen perfectly every time. Here's the output (ignore the hyperlinks, my news reader created those, in the browser they are plain text): candid...@someparty.org message subject message body blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah From: steph...@qcoss.org.au Reply-To: steph...@qcoss.org.au X-Mailer: PHP/ 5.1.1 Cc: steph...@qcoss.org.au, takeact...@qcoss.org.au thanks Stephen Hutchison steph...@qcoss.org.au wrote in message news:bc.e4.19118.b059d...@pb1.pair.com... I've set up a small website which allows users to create a form letter and email it to their local candidates in the upcoming state election. The user enters their email address, town/suburb and message into an html form and clicks the Send button. The site then sends an email to each candidate for their area. The email is plain text and only about 3k in size. The problem I'm having is that it works fine for the first few tests but any messages after that it just hangs for 5 minutes before giving a time-out message. When it's working it goes through without any delay. If I leave for say anther half an hour its back working again. I send a couple more test messages its all good, but and then it hangs again. How can I troubleshoot this intermittent problem? My ISP is running PHP on an IIS server. It seems like a server issue. Thanks Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Intermittent problem sending mail with PHP
I'll check with my ISP but if is that then it's a very low limit. I'm finding it's only allowing two or three through before hanging. Is there something i can put in my code so that it at least fails gracefully? It's not a good look just hanging like that. Thanks Stephen Chris dmag...@gmail.com wrote in message news:49ada6ab.5060...@gmail.com... Stephen Hutchison wrote: This appears to by a problem with the mail function. When I comment out the lines: if (mail($recipient, $subject, $message, $headers)) echo 'Succeededbr'; else echo 'Error - please check your e-mail addressbr'; More likely a mail server issue rather than the mail function itself. Do they have any restrictions on how often you can send email? (Some hosts only let you send say 50 emails an hour). Log everything you're trying to do in php (log when it works, when it doesn't) and include a timestamp - then get your host to look at their mail server logs for the failure times and see what shows up. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [Bulk] [PHP] Creating A Unique List With Table Query
revDAVE wrote: I would like to be able to query a table, and return only the unique values from a particular field. For example: to get all contents from the category field from the contacts table: Query = SELECT Category FROM contacts But this will produce many duplicates. Question : How do I filter the query to only produce unique values? Check out the DISTINCT keyword in the SELECT documentation. Also, do you have a Category table? Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] long echo statement performance question
I have been reading this thread with interest ... and amusement. FWII for my web sites I have 1) Most PHP code in files outside of the document root 2) Site specific variables (constants, really) in an include.php file 3) All HTML is also in this include file and is the content a variable. 4) Nested in the HTML code are variables for the content, like the menu and body text 5) All presentation is done using CSS 6) Each page just has PHP code (mostly function calls) where the content variables are built 7) Finally the content variable is echoed. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
Don Collier wrote: I am just learning PHP from the O'Reilly Learning PHP 5 book and I have a question regarding the formatting of text. Actually it is a couple of questions. First, when I use the \n and run the script from the command line it works great. When I run the same code in a browser it does not put the newline in and the text runs together. I know that I can use br/ to do the same thing, but why is it this way? The second question is closely related to the first. When formatting text using printf the padding works great when running from the command line but not at all when in a browser. Here is the code that I am working with: Browsers **only** support HTML. They do not understand things like \n to be anything special, so they just print as it is sent to the browser. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
Paul M Foster wrote: If you want exact layout (columns lined up, etc.), the simplest solution is to use HTML tables. The horror. Do not use tables for layout. Use CSS. Especially now that Microsoft, just this week, is sending out IE 8 which seems to be fully CCS standards compliant. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
Boyd, Todd M. wrote: The horror. Do not use tables for layout. Use CSS. Especially now that Microsoft, just this week, is sending out IE 8 which seems to be fully CCS standards compliant. Your high horse--get off of it. Dude! Did you read what I wrote? I wrote do not use tables for layout! Are you not familiar with div-itis? If I need to represent data in a grid-style layout, I am going to use a table every time instead of making tons of div elements and tying them into the appropriate CSS. It you have tabular data to present, use HTML tables! That is what they are for. But use CSS to format the table. Finally, just because IE8 is (supposed to be) fully CSS standards compliant doesn't mean anything for IE7, IE6, IE5, etc. Microsoft is pushing IE 8 with their bug fix process. Not a bad idea to include a little JS to warm users with IE8 to upgrade. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Captha Image Matching the Session Value.
Hi all, My captha code is working but the session code is not matching image code(captha code). How do i get them to match each other. PHP CAPTHA session_start(); $fontArray = array('arial.tff' , 'impact.tff' , 'tahoma.tff' , 'tunga.tff' , 'verdana.tff'); $fontOne = md5(rand(0,50)); $fontTwo = md5(rand(0,50)); $fontThree = md5(rand(0,50)); $fontFour = md5(rand(0,50)); //Let's generate a totally random string using md5 $md5_hashOne = md5(rand(0,999)); $md5_hashTwo = md5(rand(0,999)); $md5_hashThree = md5(rand(0,999)); $md5_hashFour = md5(rand(0,999)); //We don't need a 32 character long string so we trim it down to 5 $wordOne = substr($md5_hashOne, 15, 1); $wordTwo = substr($md5_hashTwo, 15, 1); $wordThree = substr($md5_hashThree, 15, 1); $wordFour = substr($md5_hashFour, 15, 1); //Set the image width and height $width = 400; $height = 150; //Create the image resource $image = @imagecreatefromjpeg(CapthaBack.jpg); $grey = imagecolorallocate($image, 255, 255, 255); imagettftext($image,20, rand(0,70), 30, 30, $grey , 'impact.ttf' , $wordOne); imagettftext($image,20, rand(0,70), 70, 30, $grey , 'impact.ttf' , $wordTwo); imagettftext($image,20, rand(0,70), 110, 30, $grey , 'impact.ttf' , $wordThree); imagettftext($image,20, rand(0,70), 150, 30, $grey , 'impact.ttf' , $wordFour); session_unset($_SESSION[security_code]); $_SESSION[security_code] = $wordOne . . $wordTwo . . $wordThree . . $wordFour; header(Content-Type: image/jpeg); //Output the newly created image in jpeg format ImageJpeg($image); //Free up resources ImageDestroy($image); HTML CODE session_start(); table tr td/td td colspan=2input type=text name=captha value=?php echo Test:.$_SESSION[security_code] ?/td /table Thanks, Stephen -- View this message in context: http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21650616.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Captha Image Matching the Session Value.
Hi ash, Thanks for your reply but the image does change when i refresh the page but the session value is one before the image value. If this is a cache problem how would i prevent this? Thanks, Stephen -- View this message in context: http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21650839.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Captha Image Matching the Session Value.
Hey Richard, Thanks for your reply but the Captcha php code is a seperate file to the html code but the code is working but the values are not matching. Thanks, Stephen -- View this message in context: http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21651034.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Captha Image Matching the Session Value.
Hey Ash, Is I have but the Session Value is one before the Captha Image Value. Regards, Stephen -- View this message in context: http://www.nabble.com/Captha-Image-Matching-the-Session-Value.-tp21650616p21651258.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP webhosting - USA
Martin Zvarík wrote: - my client stopped receiving orders, he called me after a week something is wrong. I found out that Powweb changed a MySQL settings, which nobody informed me about - they restricted a JOIN limit max to 3, the mysql_query SQL thus did not work and orders were not storing for 7 days! You are hosting a business website, that processes orders, on a shared server? That is very false economy. You want a dedicated server that has only you as root. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php and CSS where to put it
Terion Miller wrote: I have this code and the css seems to not work in IE at all, do I need to put it somewhere different on the page maybe? link rel=stylesheet type=text/css href=inc/styles.css ?php include 'inc/dbconnOpen.php' ; I don't see the html headers. Nor a body. Get that fixed and see what happens. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Editing in a text area field
c...@l-i-e.com wrote: Rule #1. Never, ever, ever, alter the user's input, EXCEPT for sanitizing/filtering. Specifically, do NOT add br / tags in place of newlines. Store the newlines. Upon OUTPUT, you can use nl2br() to get br / tags. Or str_replace if you want /p instead. This is crucial as a habit, down the road, when you later want to put their stuff out as non-HTML such as RSS or PDF or other output mechanisms. Consider their input as sacrosanct (except for dangerous/evil input) How do you suggest dealing with a need to allow italics, bold, underlines, etc? I see forum web sites that allow the user to enter [b]bold text[/b] for example. I would like to do this. Anyone have a function to convert this kind of thing to HTML? Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Editing in a text area field
I have a form to accept free text in a textarea field. The entry is stored in a database. If the user enters: abc def ghi I want it to finally display like that. If they enter abc def ghi I want it to display with the line gaps. I use CSS so in the first case I would store as pabcbr /defbr /ghi/p In the second pabc/ppdefp/pghi/p I also have an edit form, that takes the data out of the database, and allows the user to change it, then update the database. Preparing the existing data before an edit is proving difficult. I have to strip the html and make it format properly in the form. Then put back html before saving again. I keep ending up with stray characters Has anyone done this? Is there a tutorial on the web somewhere? Thanks Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Editing in a text area field
Daniel Brown wrote: I want it to display with the line gaps. Why not store it as plain text in the database, then run it through nl2br() when you SELECT it from the database for display? Thank you! That is the way I will do this. I may want to change br /br / to /pp but that should be easy. Cheers Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Posting Data?
Hi all, I have my own register system and I want to Post my values from my register system and post those values into the punbb register form. I do not want to register my values from the punbb form but rather from my login system. How would i be able to do this? Below is the example of the punbb register form: form class=frm-form id=afocus method=post accept-charset=utf-8 action=http://www.punbb.co.za/Forums/register.php?action=register; div class=hidden input type=hidden name=form_sent value=1 / input type=hidden name=csrf_token value=ad31a4b11b12bbedcc3a4ad7963cd9e0bb96f430 / /div div class=frm-group group1 div class=sf-set set1 div class=sf-box text required label for=fld1Username em(Required)/em smallBetween 2 and 25 characters./small/labelbr / input type=text id=fld1 name=req_username value= size=35 maxlength=25 / /div /div div class=sf-set set2 div class=sf-box text required label for=fld2Password em(Required)/em smallMinimum 4 characters. Case sensitive./small/labelbr / input type=password id=fld2 name=req_password1 size=35 / /div /div div class=sf-set set3 div class=sf-box text required label for=fld3Confirm password em(Required)/em smallRe-enter your password exactly as before./small/labelbr / input type=password id=fld3 name=req_password2 size=35 / /div /div div class=sf-set set4 div class=sf-box text required label for=fld4E-mail em(Required)/em smallA current valid e-mail address./small/labelbr / input type=text id=fld4 name=req_email1 value= size=35 maxlength=80 / /div /div div class=sf-set set5 div class=sf-box select label for=fld5Your timezone/labelbr / select id=fld5 name=timezone option value=-12(UTC-12:00) International Date Line West/option option value=-11(UTC-11:00) Niue, Samoa/option option value=-10(UTC-10:00) Hawaii-Aleutian, Cook Island/option option value=-9.5(UTC-09:30) Marquesas Islands/option option value=-9(UTC-09:00) Alaska, Gambier Island/option option value=-8(UTC-08:00) Pacific/option option value=-7(UTC-07:00) Mountain/option option value=-6(UTC-06:00) Central/option option value=-5(UTC-05:00) Eastern/option option value=-4(UTC-04:00) Atlantic/option option value=-3.5(UTC-03:30) Newfoundland/option option value=-3(UTC-03:00) Amazon, Central Greenland/option option value=-2(UTC-02:00) Mid-Atlantic/option option value=-1(UTC-01:00) Azores, Cape Verde, Eastern Greenland/option option value=0 selected=selected(UTC) Western European, Greenwich/option option value=1(UTC+01:00) Central European, West African/option option value=2(UTC+02:00) Eastern European, Central African/option option value=3(UTC+03:00) Moscow, Eastern African/option option value=3.5(UTC+03:30) Iran/option option value=4(UTC+04:00) Gulf, Samara/option
[PHP] Posting Data?
Hi all, I have my own register system and I want to Post my values from my register system and post those values into the punbb register form. I do not want to register my values from the punbb form but rather from my login system. How would i be able to do this? Below is the example of the punbb register form: form class=frm-form id=afocus method=post accept-charset=utf-8 action=http://www.punbb.co.za/Forums/register.php?action=register; div class=hidden input type=hidden name=form_sent value=1 / input type=hidden name=csrf_token value=ad31a4b11b12bbedcc3a4ad7963cd9e0bb96f430 / /div div class=frm-group group1 div class=sf-set set1 div class=sf-box text required label for=fld1Username em(Required)/em smallBetween 2 and 25 characters./small/labelbr / input type=text id=fld1 name=req_username value= size=35 maxlength=25 / /div /div div class=sf-set set2 div class=sf-box text required label for=fld2Password em(Required)/em smallMinimum 4 characters. Case sensitive./small/labelbr / input type=password id=fld2 name=req_password1 size=35 / /div /div div class=sf-set set3 div class=sf-box text required label for=fld3Confirm password em(Required)/em smallRe-enter your password exactly as before./small/labelbr / input type=password id=fld3 name=req_password2 size=35 / /div /div div class=sf-set set4 div class=sf-box text required label for=fld4E-mail em(Required)/em smallA current valid e-mail address./small/labelbr / input type=text id=fld4 name=req_email1 value= size=35 maxlength=80 / /div /div div class=sf-set set5 div class=sf-box select label for=fld5Your timezone/labelbr / select id=fld5 name=timezone option value=-12(UTC-12:00) International Date Line West/option option value=-11(UTC-11:00) Niue, Samoa/option option value=-10(UTC-10:00) Hawaii-Aleutian, Cook Island/option option value=-9.5(UTC-09:30) Marquesas Islands/option option value=-9(UTC-09:00) Alaska, Gambier Island/option option value=-8(UTC-08:00) Pacific/option option value=-7(UTC-07:00) Mountain/option option value=-6(UTC-06:00) Central/option option value=-5(UTC-05:00) Eastern/option option value=-4(UTC-04:00) Atlantic/option option value=-3.5(UTC-03:30) Newfoundland/option option value=-3(UTC-03:00) Amazon, Central Greenland/option option value=-2(UTC-02:00) Mid-Atlantic/option option value=-1(UTC-01:00) Azores, Cape Verde, Eastern Greenland/option option value=0 selected=selected(UTC) Western European, Greenwich/option option value=1(UTC+01:00) Central European, West African/option option value=2(UTC+02:00) Eastern European, Central African/option option value=3(UTC+03:00) Moscow, Eastern African/option option value=3.5(UTC+03:30) Iran/option option value=4(UTC+04:00) Gulf, Samara/option
[PHP] Online Members
Hi all, What is the best way to pick up all the members online on a website? Regards, Stephen -- View this message in context: http://www.nabble.com/Online-Members-tp21180855p21180855.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image Resizing
Hi all, What is the best way in PHP to Resize an Image to a specific width. For Example I have images in the following sizes: (1) 200px width and 350px height (2) 125px width and 220px height (3) 166px width and 455px height I want all the images to resize to 100px width but the height adjusts automatically. Regards, Stephen -- View this message in context: http://www.nabble.com/Image-Resizing-tp21108753p21108753.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML Get Value of Node DOMXPath
Hello all, Need help to get the value of the node. We know how to get the value of the city , item and itemPrice nodes below. How do we get the value of NumberOfRooms? $hotelElements = $xpath-query( '', $searchReponseElement ); foreach( $hotelElements as $hotelElement ) { $city = $xpath-query( 'City' , $hotelElement ); $item = $xpath-query( 'Item' , $hotelElement ); $itemPrice = $xpath-query( 'ItemPrice' , $hotelElement ); $confirmation = $xpath-query( 'Confirmation' , $hotelElement ); } Here is an example of the XML Response: Hotel HasExtraInfo=true City Code=AMS![CDATA[ Amsterdam ]]/City Item Code=JAN![CDATA[ JAN LUYKEN HTL AND RESIDENCE]]/Item LocationDetails Location Code=G1![CDATA[ Central ]]/Location /LocationDetails StarRating4/StarRating HotelRooms HotelRoom Code=SB NumberOfRooms=1 / HotelRoom Code=TB ExtraBed=true NumberCots=1 NumberOfExtraBeds=2 NumberOfRooms=1 SharingBedding=true / /HotelRooms Thanks -- View this message in context: http://www.nabble.com/XML-Get-Value-of-Node-DOMXPath-tp21015877p21015877.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php client
idan72 wrote: Hi, I am new to PHP. I want to write a web client in PHP that will data to a server written in Java. I want that the client will send an object to the server. What is the best way to do that? Where can I find an example for doing that ? JAVA is on the client side. That is, it runs in the users browser. PHP is on the server side, and there is no direct interaction between PHP and the user. It seems from what you write that you need a form in a web page, and a PHP script to process the data the user enters and submits from the form. You may not need JAVA at all. If this is what you want to go, Google, PHP forms Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can GD make a JPG thumbnail of a PDF?
I think you want something like this : exec(convert -density 360x360 -enhance $pdfFile $pdfFile.gif); On 12/10/08 4:48 PM, Brian Dunning [EMAIL PROTECTED] wrote: I've spent most of the last week trying to get ImageMagick working on my Windows PHP installation. I gather that since I'm going to be converting PDFs to JPEGs, I need Ghostscript. Well, I've got ImageMagick installed: http://printhq2.com/info.php I ran a Ghostscript installer, but it didn't seem to do very much. Some site advised me to test my installation like this: ?php echo pre; system(convert -version); echo /pre; ? But it just returns blank. Can anyone help me get ImageMagick working on my server? On Nov 20, 2008, at 4:41 PM, Stephen Johnson wrote: No but you can use imagemagicks convert to convert the pdf to an image and then make a thumbnail of it. -- Stephen Johnson The Lone Coder http://www.ouradoptionblog.com *Join us on our adoption journey* [EMAIL PROTECTED] http://www.thelonecoder.com *Continuing the struggle against bad code* -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Guidance on enhancing functionality
I want to enhance my web site’s display of photographs. I currently have a Gallery menu selection and that leads to a PHP script that, based on parameters will 1) Display all categories of photos 2) Display the thumbnails of a selected category 3) Display a selected picture I have a table (MySQL) for the categories and a table for the pictures. Now, I want to add additional menu items that will have their own functionality, the same as the gallery. I am trying to decide what the best approach is. And I suspect I might want the functionality to be different for the menu items at some time in the future. 1) Add logic to identify the menu item, and use the same tables and script, just adding a menu selection field 2) Clone the script and tables with new names 3) Some other strategy. I will also need to enhance my control panel, of course . I don’t have enough experience to decide which is the better long term solution. Thoughts? Thanks Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
Kevin Waterson wrote: Only a barbarian would call it Sequel or anything other than My S. Q. L MY ESS KEW ELL I have never heard that product SQL Server referred to as anything other than seequel server. Guess that proves your point :) Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Model Web Site
My prime hobby is photography and the next is web site building. So now I have a young model (18+) asking me about getting a web site. The idea is members can see content, that will include, photos, her blog and a discussion forum. I like the idea of building it, but it includes a lot of things I have no experience in. Can someone point me to documentation/tutorials/scripts or anything that might help. I don't want a turnkey solution. I want to learn how to do this. Thank you! Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Model Web Site
Boyd, Todd M. wrote: http://www.w3schools.com/html http://www.w3schools.com/xhtml http://www.w3schools.com/css http://www.w3schools.com/js http://www.w3schools.com/php http://www.w3schools.com/sql http://www.php.net http://www.mysql.com most important link: http://www.google.com Get comfortable with programming; with algorithms; with data structures; with databases; with client-server relationships. HTH, Thanks . but ... ouch! I have been doing HTML sites for 5 years. CSS for four and PHP/MySQL for three. What is new to me is controlling access based on being a member. And making it tough for hackers. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can GD make a JPG thumbnail of a PDF?
No but you can use imagemagicks convert to convert the pdf to an image and then make a thumbnail of it. On 11/20/08 4:39 PM, Brian Dunning [EMAIL PROTECTED] wrote: Well can it? -- Stephen Johnson The Lone Coder http://www.ouradoptionblog.com *Join us on our adoption journey* [EMAIL PROTECTED] http://www.thelonecoder.com *Continuing the struggle against bad code* -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random number generator
On Thu, 11/6/08, WEISD [EMAIL PROTECTED] wrote: That is strange. I get pretty balanced results on this computer. ?php $histogram = array_fill(1, 10, 0); $iterations = 20; for ($i = 0; $i $iterations; ++$i) { ++$histogram[round(rand(1, 10))]; } print_r($histogram); ? Andrew Simple code, ?php $number = rand(1, 10); include(footer$number.html); ? You can see it in action here at the bottom of the page there is a footer. Each footer is the same right now except I have numbered them for testing. As I refresh the page, I get footer10 almost always with an occasional 2 or 4 here and there... http://www.weisd.com/store2/WINHD-9022.php Computer functions to generate random numbers are not designed to do what their name suggests. Software testing requires repeatability, and this includes random number generation. Without knowing how PHP seeds the generator it is difficult to predict what it will do. I still think taking the last digit of the current time is your best solution. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random number generator
On a php web page I want to generate a random number between say 1 and 10 and then use that number to reference a particular file in an include tag. ?php include('GeneratedNumber.html'); ? Is there an easy way to do this? Get the time and use the last digit converting 0 to 10. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change tracking
-- On Fri, 10/31/08, Mike Smith [EMAIL PROTECTED] wrote: [INVENTORY_TABLE] fieldsexample data part 1027P serial543221-K qty 120 location G-5 I'd like to record what changed. Let's say they change the serial. One way would be a static changes table: Another way is to never change a record, but to add new ones. You also need to add an effectivity date field. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Required files not being parsed properly...
Hey hey hey ... LOL This is all VERY old code...I admit that... The site needed to be closed since it was completely broken. I figured out the reason .. The new php.ini file had the use short tags turned off... So I turned that on and it works now. On 10/7/08 7:32 AM, Jim Lucas [EMAIL PROTECTED] wrote: Eric Butera wrote: On Mon, Oct 6, 2008 at 7:28 PM, Stephen Johnson [EMAIL PROTECTED] wrote: OK .. I am upgrading to PHP5 on a clients box, and after doing so I have run into the problem that files that get brought in by a require statement, or include, end up just getting dumped to the browser as text.. For instance : require(/home/tnr/incs/tnr_db.php); $db = new mysql(); Produces what you see here : http://www.thumbnailresume.com/index.html?allow=1 Any one have any thoughts on what is going on? -- Stephen Johnson c | eh The Lone Coder office: 562.366.4433 fax: 562.278.0133 http://www.thelonecoder.com continuing the struggle against bad code http://www.fortheloveofgeeks.com I¹m a geek and I¹m OK! -- $user_id = $_COOKIE['user_id']; $logFile = /home/tnr/query_logs/tnr..$user_id..query.log; uh oh... Did you scare the OP or something? The page isn't available any longer... :) -- Stephen Johnson The Lone Coder http://www.ouradoptionblog.com *Join us on our adoption journey* [EMAIL PROTECTED] http://www.thelonecoder.com *Continuing the struggle against bad code* -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Required files not being parsed properly...
OK .. I am upgrading to PHP5 on a clients box, and after doing so I have run into the problem that files that get brought in by a require statement, or include, end up just getting dumped to the browser as text.. For instance : require(/home/tnr/incs/tnr_db.php); $db = new mysql(); Produces what you see here : http://www.thumbnailresume.com/index.html?allow=1 Any one have any thoughts on what is going on? -- Stephen Johnson c | eh The Lone Coder office: 562.366.4433 fax: 562.278.0133 http://www.thelonecoder.com continuing the struggle against bad code http://www.fortheloveofgeeks.com I¹m a geek and I¹m OK! --
Re: [PHP] Math problems (No not high school math!)
Jason Pruim wrote: So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... Consider adding a column for the total hours and calculate it when saving the record. It should make everything that follows easier. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Google Checkout
I'm looking at using this myself for an upcoming project.. Do you know if they force customers to sign up with a google account before processing or can they just put in card details and be done with it? Thanks, Steve On Wed, Sep 24, 2008 at 10:59 AM, Richard Heyes [EMAIL PROTECTED] wrote: Hi, As a follow up, I've just switched from Paypal to Google Checkout. Setup was quick and pain free (easily less than 2 hours), and I would recommend it (so far). Like other people have said though, it's just UK and USA at the moment. -- Richard Heyes HTML5 Graphing for FF, Chrome, Opera and Safari: http://www.phpguru.org/RGraph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Stephen Wellington 07956 042387 01865 28 ext 12438 [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] -- Stephen Wellington 07956 042387 01865 28 ext 12438 [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Calculation assistance.. :)
OK.. Math is NOT my forte ... I am converting a site from ASP to PHP ... And this calc is in the ASP Code : $nMonthlyInterest = $nRate / (12 * 100) //' Calculate monthly payment $nPayment = $nPrincipal * ( $nMonthlyInterest / (1 - (1 + $nMonthlyInterest) ^ -$iMonths)) Which then gives me in PHP 0.00104167 = 1.25 / (12 * 100); -2.170138889 = 25000 * ( 0.00104167 / (1 - (1 + 0.00104167) ^ -12)) :: ^ is the problem ... The solution SHOULD be 2,097.47 ... Not 2.17 Would be willing to help correct this and make it valid in PHP? -- Stephen Johnson c | eh The Lone Coder http://www.thelonecoder.com continuing the struggle against bad code http://www.fortheloveofgeeks.com I¹m a geek and I¹m OK! --
Re: [PHP] Calculation assistance.. :)
Right ... But that is producing even funkier results... doing pow( (1-(1+$nMonthlyInterest)) , ($iMonths*-1) ) ; Gives me : 4.2502451372964E-35 = 25000 * (0.00104167 / 6.1270975733019E+35); -- Stephen Johnson c | eh The Lone Coder http://www.thelonecoder.com continuing the struggle against bad code http://www.fortheloveofgeeks.com I¹m a geek and I¹m OK! -- From: Eric Gorr [EMAIL PROTECTED] I believe what you are looking is: http://us2.php.net/manual/en/function.pow.php number pow ( number $base , number $exp ) Returns base raised to the power of exp On Sep 19, 2008, at 3:34 PM, Stephen Johnson wrote: OK.. Math is NOT my forte ... I am converting a site from ASP to PHP ... And this calc is in the ASP Code : $nMonthlyInterest = $nRate / (12 * 100) //' Calculate monthly payment $nPayment = $nPrincipal * ( $nMonthlyInterest / (1 - (1 + $nMonthlyInterest) ^ -$iMonths)) Which then gives me in PHP 0.00104167 = 1.25 / (12 * 100); -2.170138889 = 25000 * ( 0.00104167 / (1 - (1 + 0.00104167) ^ -12)) :: ^ is the problem ... The solution SHOULD be 2,097.47 ... Not 2.17 Would be willing to help correct this and make it valid in PHP? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculation assistance.. :)
Eric ... I LOVE YOU... Thanks -- Stephen Johnson c | eh The Lone Coder http://www.thelonecoder.com continuing the struggle against bad code http://www.fortheloveofgeeks.com I¹m a geek and I¹m OK! -- From: Eric Gorr [EMAIL PROTECTED] Date: Fri, 19 Sep 2008 16:13:49 -0400 To: Stephen Johnson [EMAIL PROTECTED] Cc: PHP list - not junk php-general@lists.php.net Subject: Re: [PHP] Calculation assistance.. :) You originally had: $nPrincipal * ( $nMonthlyInterest / (1 - (1 + $nMonthlyInterest) ^ - $iMonths)) which, translate to in PHP $nPrincipal * ( $nMonthlyInterest / (1 - pow( ( 1 + $nMonthlyInterest ), -$iMonths ) ) ) On Sep 19, 2008, at 3:48 PM, Stephen Johnson wrote: Right ... But that is producing even funkier results... doing pow( (1-(1+$nMonthlyInterest)) , ($iMonths*-1) ) ; Gives me : 4.2502451372964E-35 = 25000 * (0.00104167 / 6.1270975733019E +35); From: Eric Gorr [EMAIL PROTECTED] I believe what you are looking is: http://us2.php.net/manual/en/function.pow.php number pow ( number $base , number $exp ) Returns base raised to the power of exp On Sep 19, 2008, at 3:34 PM, Stephen Johnson wrote: OK.. Math is NOT my forte ... I am converting a site from ASP to PHP ... And this calc is in the ASP Code : $nMonthlyInterest = $nRate / (12 * 100) //' Calculate monthly payment $nPayment = $nPrincipal * ( $nMonthlyInterest / (1 - (1 + $nMonthlyInterest) ^ -$iMonths)) Which then gives me in PHP 0.00104167 = 1.25 / (12 * 100); -2.170138889 = 25000 * ( 0.00104167 / (1 - (1 + 0.00104167) ^ -12)) :: ^ is the problem ... The solution SHOULD be 2,097.47 ... Not 2.17 Would be willing to help correct this and make it valid in PHP? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CSV output.
It sounds like you simply need to number format the data to ensure that PHP does not truncate http://php.net/number_format If excel, or whatever your using to view the csv file, is truncating then you will need to properly format that cell. -- Stephen Johnson c | eh The Lone Coder http://www.thelonecoder.com continuing the struggle against bad code http://www.fortheloveofgeeks.com I¹m a geek and I¹m OK! -- From: Tom Shaw [EMAIL PROTECTED] Date: Mon, 8 Sep 2008 15:53:58 -0500 To: PHP list - not junk php-general@lists.php.net Subject: [PHP] CSV output. I'm outputting a bunch of numerical values for a spreadsheet to calculate total sales among other things on a client shopping cart. I'm running into problems with values that contain zeros after the decimal. If a value is 234.55 the value outputs fine to the CSV file but if the value is 234.00 only 234 shows up. Is there any way to force the zeros into the spreadsheet? Thanks Tom Shaw [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Google Chrome
Wow, didn't notice the GoogleUpdate.exe, thanks for the heads up on that. Agreed about programs adding items in our startup. On Thu, Sep 4, 2008 at 2:23 PM, Boyd, Todd M. [EMAIL PROTECTED] wrote: -Original Message- From: Ovidiu Rosoiu [mailto:[EMAIL PROTECTED] Sent: Thursday, September 04, 2008 12:56 PM To: Richard Heyes Cc: php-general@lists.php.net Subject: Re: [PHP] Google Chrome Richard Heyes wrote: Hi, Is it just me, or is everyones disk thrshing more since installing (if you have) Chrome? Oh, and to keep it in-line with list, isn't PHP great? :-) I uninstalled it precisely beacause of this behaviour. The disk was running crazy every time chrome was started. And I don't know how to do lsof | grep chrome on Windows to see what's going on. You can at least track memory + cpu usage through the Task Manager (Ctrl-Alt-Del + T on most distros). In the Task Manager, I also noticed that GoogleUpdate.exe is running even when Chrome.exe is not. This made me a bit curious, so I went into msconfig (the Microsoft GUI utility for modifying startup programs, services, and system INI files) and saw that GoogleUpdate.exe had been added to the list of programs to run on Windows startup. I hate, hate, HATE it when programs install resident agents that eat my memory and perform background network activity. Rrgh! Points taken away from Google for this app's EULA and its methods. Slick otherwise, though (aside from the lack of XMLDOM instantiation support for Javascript)... Todd Boyd Web Programmer -- 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] Semi-ADVERT, OT
On 8/20/08 6:57 AM, tedd [EMAIL PROTECTED] wrote: Seriously, I saw a new invention recently. The inventor made underwear with three leg holes. The idea was to rotate the underwear as needed. What people won't invent. Cheers, tedd -- That is disturbing. -- Stephen Johnson The Lone Coder http://www.ouradoptionblog.com *Join us on our adoption journey* [EMAIL PROTECTED] http://www.thelonecoder.com *Continuing the struggle against bad code* -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Does this seem wrong to anyone else?
I am debugging someone else¹s code, and this is what they have : 1055function mkdir_recursive($pathname, $mode) 1056{ 1057is_dir(dirname($pathname)) || mkdir_recursive(dirname($pathname), $mode); 1058return is_dir($pathname) || @mkdir($pathname, $mode); 1059} The part that bothers me is that mkdir_recursive calls itself from within itself. I am not an expert on this particular type of thing, and maybe that is allowed, but it seems wrong to me, and this error is being generated: Fatal error: Call to undefined function mkdir_recursive() in x.php on line 1057 -- Stephen Johnson c | eh The Lone Coder http://www.thelonecoder.com continuing the struggle against bad code http://www.fortheloveofgeeks.com I¹m a geek and I¹m OK! --
Re: [PHP] Does this seem wrong to anyone else?
Thanks everyone ... It was a brain fart ... Long bad day today, and I am not paying proper attention ... :) -- Stephen Johnson c | eh The Lone Coder http://www.thelonecoder.com continuing the struggle against bad code http://www.fortheloveofgeeks.com I¹m a geek and I¹m OK! -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Kill Magic Quotes
Dave M G wrote: PHP List, I found this solution after a web search. I can't attribute the author, but would like to if I could. I have a routine like this: if (isset($_POST['choice'])) { if (get_magic_quotes_gpc() ){ stripslashes_arrays( $_POST ); } $choice = $_POST['choice']; } else { $choice = 'unknown'; } and this is the function # strips slashes to a multi dimensional array, by reference function stripslashes_arrays($array) { if ( is_array($array) ) { $keys = array_keys($array); foreach ( $keys as $key ) { if ( is_array($array[$key]) ) { stripslashes_arrays($array[$key]); } else { $array[$key] = stripslashes($array[$key]); } } } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Back to Basics - Why Use Single Quotes?
I have traditionally used double quotes going back to my PASCAL days. I see many PHP examples using single quotes, and I began to adopt that convention. Even updating existing code. And I broke some stuff that was doing variable expansion. So I am back to using double quotes. But I wonder, is there any reason to use single quotes? Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] limiting the amount of emails sent at a time in a batch send
I would use a temporary table to hold all the email created in one job. Have a status field marked as sent, waiting or open. Have a cron job set 'x' number of open emails to waiting. Execute periodically. Have a cron job to send all waiting email and update status to sent. Execute periodically. Stephen Richard Kurth wrote: I want to limit these script two send 100 email and then pause for a few seconds and then send another 100 emails and repeat this tell it has sent all the emails that are dated for today. This script is runs by cron so it is running in the background. How would I do this and is it the best way to do it. I am using swift mailer to send the mail. I think I would use limit 100 in the query but how would I tell it to get the next 100. $today = date(Y-m-d); # Cache the Contact that will recive campain messages today $query = SELECT emailmessages. * , contacts.* FROM emailmessages, contacts WHERE emailmessages.contact_id = contacts.id AND emailmessages.nextmessagedate = '$today' AND contacts.emailstatus = 'Active'; $DB_Contact_Result = mysql_query($query); if (!$DB_Contact_Result) { die('Invalid query: ' . mysql_error()); } while ($this_row = mysql_fetch_array ($DB_Contact_Result)){ $CustomerID=$this_row[id]; //get the message for the contact $query1 = SELECT * FROM emailcampaign where member_id = '$this_row[members_id]' AND campaign_id = '$this_row[emailcampaign]' AND day = '$this_row[email_number]'; $DB_Mail_Result = mysql_query($query1); if (!$DB_Mail_Result) { die('Invalid query: ' . mysql_error()); } $Mail_row = mysql_fetch_array($DB_Mail_Result); //get member stuff $query2 = SELECT * FROM member where members_id = '$this_row[members_id]'; $DB_Member_Result = mysql_query($query2); if (!$DB_Member_Result) { die('Invalid query: ' . mysql_error()); } $subject=stripslashes($Mail_row['subject']); $message=stripslashes($Mail_row['textmessage']); $hmessage=stripslashes($Mail_row['htmlmessage']); $swiftPlain = $message; $MailFrom1=$this_row['emailaddress']; $MailFromName1=$this_row['firstname']; $full_name=stripslashes($this_row['firstname']) . . stripslashes($this_row['lastname']); //Create the message $message = new Swift_Message($subject); $message-attach(new Swift_Message_Part($swiftPlain)); $message-attach(new Swift_Message_Part($swiftHtml, text/html)); $message-setReturnPath($MailAddReplyTo); $message-setReplyTo($MailFrom1,$MailFromName1); //Now check if Swift actually sends it $swift-send($message, $this_row['emailaddress'],$MailFrom1,$MailFromName1); #After we send the email we need to update the database to send the next message # get the next message number $nextday=getnextday(stripslashes($this_row['emailcampaign']),stripslashes($this_row['members_id']),stripslashes($this_row['email_number'])); # get the new dates $newdate=getnewdate(stripslashes($this_row['emailstarted']),$nextday); #update the emailmessages //unsubscribecode updateemailmessages($unpass,$nextday,$newdate,stripslashes($this_row['em_id']),stripslashes($this_row['email_number'])); }//end of mail loop -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Optimization of PHP Code
Manoj Singh wrote: I am developing the web site in PHP using MYSQL database. Can you please provide me some tips to write the optimized code. Hard to be specific without a more detailed understanding of what you are going to do. But in general, use the newer PDO class instead of the older mySQL functions. PDO is better at handling demanding SQL activity. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Class 'PDO' not found in .... PHP 5.2.5
I am with a new host and just tried to upload new files that use PHP and the class PDO for database access. I get the error in the subject. I thought PDO was in the base code of PHP 5* My host is on 5.2.5 according to PHP info I have created a ticket I fear that this is one of those not supported things. So I am asking for any advise. Thanks Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[Fwd: Re: [PHP] Removeing duplicates inside for/foreach loop.]
Niccolo Machiavelli wrote: $array = array( 1 = array(order_number = 10DA0DDEDAF97DB, order_payment_first_name = Mike, order_payment_last_name = Smith), 2 = array(order_number = 10DA0DDEDAF97DB, order_payment_first_name = Mike, order_payment_last_name = Smith), 3 = array(order_number = 45Y3453245T23T5, order_payment_first_name = Steve, order_payment_last_name = Jobs), 4 = array(order_number = 34RTB345T45T456, order_payment_first_name = Frank, order_payment_last_name = Capra), 5 = array(order_number = 567U457645645Y6, order_payment_first_name = John, order_payment_last_name = Doe), 6 = array(order_number = 7698234T456M963, order_payment_first_name = Bill, order_payment_last_name = Williams)); echo('pre'); print_r($array); echo('/pre'); My question is I want to remove duplicate order numbers in other words ditch *one* of the Mike Smith rows there's a duplicate order number there. And I need to do it in either a for/foreach loop. Somehow there's got to be a simple way to check and only output non duplicate order numbers while I'm looping thru the data. Any help would be greatly appreciated. It looks like the array is sorted. In pseudo code for i = 2 to n if x[1].order = x[i-1].order then unlink x[i-1] Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Question. Number of rows returned
Kevin Waterson wrote: I am switching to PDO and can't find an equivalent to mysql_num_rows. Am I missing something silly? Or is there a change of thinking needed for PDO? How should I determine how many rows a query returned? PDO returns an array, sizeof/count will get you home I would like to know how many rows I am working with before starting to fetch. Also fetchall, does not seem to have a style that returns each column value just once. I see this ugly thing in the manual: Fetch all of the remaining rows in the result set: Array ( [0] = Array ( [NAME] = pear [0] = pear [COLOUR] = green [1] = green ) [1] = Array ( [NAME] = watermelon [0] = watermelon [COLOUR] = pink [1] = pink ) ) If I could get the column offsets only, without the column names I would be very happy. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php