[PHP] Re: phpDesigner 2008?
Holografix wrote: > Hi > I tried PHPDesigner some time ago. It's not bad but now I'm using Netbeans > and it's a good editor: http://www.netbeans.org/ (it's free!) > > Best regards, > Holo > > > ""Waynn Lue"" <[EMAIL PROTECTED]> escreveu na mensagem > news:[EMAIL PROTECTED] >> I know the IDE wars spring up occasionally, but looking through the >> archives, I haven't seen any discussions pro or con for phpDesigner 2008 ( >> http://www.mpsoftware.dk/phpdesigner.php). Anyone had a chance to use it >> and think it's good or not? >> >> I just installed PDT + Eclipse today, and I'm still getting used to the >> integration. I'm used to Eclipse + Java, so it somewhat throws me for a >> loop in trying to figure out what works in what scope. I do wish I could >> have it do some kind of analysis of my files plus dependencies so any >> problems could be discovered at compile time, rather than run time. >> >> Thanks, >> Waynn >> > > +1 for Netbeans. I've been using Quanta+ and got frustrated trying to get debugging to work. I've just got a development release of Netbeans 6.5 and the PHP support is really quite good now (I wasn't impressed with the 6.1 version I tried). I've used various incarnations of Netbeans (since about 3.5) for Java, and I've always liked it... I do miss some of Quanta+'s neat quote, bracket and tag completion, though... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Netbeans 6.5 WAS: phpDesigner 2008?
Bastien Koert wrote: > On Wed, Nov 26, 2008 at 7:34 PM, Daevid Vincent <[EMAIL PROTECTED]> wrote: > >> On Tue, 2008-11-18 at 10:32 +, Holografix wrote: >> >> Hi >> I tried PHPDesigner some time ago. It's not bad but now I'm using Netbeans >> and it's a good editor: http://www.netbeans.org/ (it's free!) >> >> I watched the little movie demo and was impressed, so I just installed and >> tried the Netbeans 6.5 (.sh installer for Linux b/c the Ubuntu repository >> has 6.1 still) and am really disappointed at how pokey the GUI is?! It's so >> slow as to be unusable. I'm baffled by this, as I've been using Eclipse PDT >> (which is a pig) and that also uses Java, but it's nowhere near as slow as >> Netbeans is. >> >> My system is far from old: >> >> Intel P4 CPU 3.20GHz with 2GB RAM. >> >> java version "1.6.0_10" >> Java(TM) SE Runtime Environment (build 1.6.0_10-b33) >> Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing) >> >> (also tried with the OpenJDK or whatever it's called, and had the same >> miserable experience) >> >> I tried to adjust some of the netbeans.conf that I saw in the FAQ to no >> avail: >> >> netbeans_default_options="-J-client -J-Xverify:none -J-Xmx256m -J-Xss2m >> -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m >> -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true >> -J-XX:CompileThreshold=100 -Dswing.aatext=true" >> >> The fonts also looked horrible! All pixeley and like I was back in the >> 1980's. >> >> I read the forums and searched for "slow" and saw other poor souls with >> similar experiences, but no solutions. [image: :(] >> >> Oh well... Guess I'll stick with Eclipse PDT (and how does Zend get off >> charging $400 for "Zend Studio" which amounts to a few Eclipse plugins?!? >> Seriously? That's $150 at best) >> >> Daevid. >> http://www.daevid.com <http://daevid.com> >> >> > I've installed it but have yet to use it. I am having a good time with > APTANA Studio, though there is a learning curve > As a long-time Java developer, I am pretty familiar with NetBeans, so I'm loving 6.5 for PHP. It's the best debugging environment I've found (I could never get Quanta+ to do debugging in any sane way...) I certainly don't find it slow (not like Eclipse was) or confusing (again, looking at you, Eclipse), and on my SuSE Linux box (Intel CoreD 2.4Ghz, 2Gb RAM) the fonts are lovely and smooth. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing XML
Per Jessen wrote: > Ashley Sheridan wrote: > >> On Fri, 2008-11-28 at 10:15 +0100, Per Jessen wrote: >>> Ashley Sheridan wrote: >>> >>>> Do any of you have a copy of this extension, or failing that, a >>>> suggestion of how I can parse XML files without having to install >>>> anything on the remote server, as I do not have that level off >>>> access to it. >>> Parsing XML is best done with XSL - if that's out of the question, >>> you're in for a difficult time. >>> >>> >>> /Per Jessen, Zürich >>> >>> >> XSL will only allow me to convert it into a different document format, >> which is not what I want as I need to keep a local copy of information >> in a database for searching and sorting purposes. Nathans class allows >> me to have the entire document put into an array tree, which is fine >> for what I need so far. > > That's cool, but XSL is still the more appropriate tool IMO. It does > exactly what you need - it parses and validates the XML document, > allows you to extract the bits you need and in virtually any format you > need - which could be a text document with SQL statements for piping to > mysql. > > > /Per Jessen, Zürich > I'm with you on this, Per. You could even use the XSL to construct a bunch of PHP which could be eval'd or just read in as an include. Or better yet, if you use the XSL classes, you can register PHP functions and then call them within your XSL directly. That could potentially handle the validation you required, and even do the database inserts. I'm looking into using something like that on a project I'm currently working on: maybe I can come up with some examples in a couple of days... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
German Geek wrote: > On Tue, Dec 9, 2008 at 2:46 PM, Micah Gersten <[EMAIL PROTECTED]> wrote: > >> Robert Cummings wrote: >>> On Tue, 2008-12-09 at 00:16 +, Nathan Rixham wrote: >>> >>>> Ashley Sheridan wrote: >>>> >>>>> On Mon, 2008-12-08 at 23:23 +, [EMAIL PROTECTED] wrote: >>>>> >>>>>> Presumable, the EXISTS sub-query can be optimized sometimes to just >> stop processing the sub-query and kick things back out to the outer query. >>>>>> >>>>>> >>>>>> IN has to process them all and find them all. >>>>>> >>>>>> >>>>>> >>>>>> >>>>> Don't forget the special case use as well: >>>>> >>>>> IF NOT EXISTS `universe` THEN bigbang() >>>>> >>>>> >>>>> Ash >>>>> www.ashleysheridan.co.uk >>>>> >>>>> >>>> any chance of writing the implementation of that bigbang() function? >>>> >>> If nothing exists and a universe is created via a big bang... does it >>> make a sound? Can we realistically call it a big bang if it doesn't make >>> a sound? Couldn't we call it the big light show? But then again... if >>> nothing exists and a universe is created via a big light show... does it >>> matter? Can it be perceived? Is this just a proverbial pandrödinger's >>> box? You can't implement the bigbang() function if you don't exist. >>> >>> Cheers, >>> Rob. >>> >> The function doesn't say who's doing the creating, it just checks for >> the existence of the universe. > > Lol, I agree, the function bigbang() doesn't need to be implemented (or it > could be empty if it needs to be there for this line to work), because by > definition, the universe must exist, if this statement is to exist. > Although it would be interesting to see an implementation of a simulation of > bigbang(). > And, I would say there is a sound, even if no one is there to hear it, > assuming it to have happened. Also if there were no sound, there would be no > light show either, there would be nothing, which contradicts the assumption > that the big bang was there (exists)... > > Guys, I think this is taking it a bit far... > In space, no one can hear you scream... (or bang, for that matter) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Poll of Sorts: Application Frameworks--Zend, Cake etc
Terion Miller wrote: > On Thu, Dec 11, 2008 at 4:25 PM, Colin Guthrie wrote: > >> 'Twas brillig, and Terion Miller at 11/12/08 14:56 did gyre and gimble: >> >>> Hey Everyone, I am wondering if using a framework such as one of these may >>> make my life easier, which do any of you use and what has been your >>> experience with the learning curve of them? >>> I just put Cake on my local server, basically I want to know which is >>> easiest? LOL... >>> >> Personally I'm a ZF fan, but each to their own. >> >> Col >> >> -- >> >> Colin Guthrie >> gmane(at)colin.guthr.ie >> http://colin.guthr.ie/ >> >> Day Job: >> Tribalogic Limited [http://www.tribalogic.net/] >> Open Source: >> Mandriva Linux Contributor [http://www.mandriva.com/] >> PulseAudio Hacker [http://www.pulseaudio.org/] >> Trac Hacker [http://trac.edgewall.org/] >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> Thanks for the responses, CakePhp was seemingly very easy for me to catch > on to and get started in (which means its super super easy folks) > unfortunately when I got to the viewing of my files (pretty important) I > couldn't get the IIS (yep I know sucks) to work with it, and I installed a > mod_rewrite.dll for IIS and everything along with setting it to Cakes > "pretty urls" and removing the htdocs, but then it just kept resolving all > urls to the root ... no matter what I changed the path to, and no matter if > I set it only to that directory...so by end of day yesterday I downloaded > the zend and will attempt to see what I can do with it, I want off this > windows box but that isn't going to happen anytime soon ...sigh... > Terion > If you're up for a bit of playing, look at www.virtualbox.org and set up a virtual linux box inside your windows server. I got a nice new laptop to play with for setting up a demo of one of our web-apps, and since it had Vista (and was high enough spec to handle it) I just put VirtualBox on board and installed OpenSuSE in there to run the server side of the app. A bit of fiddling with network bridges (all documented by the VirtualBox people) and the server is visible just like it was a real machine... So I can take this machine around, and (without needing any network connection) show off the app in IE, Firefox, Opera or Chrome without having to run IIS. Well, I thought it was cool, anyway :( -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Secure uploads tutorial
tedd wrote: > I can't imagine evil code still working after someone resizes the file. > Yeah, but the uploaded OpenOffice Writer doc won't look too good either... :) I prefer to move files to an off-line store, run them through a unix 'file' command (with a mime-type magic file) to get the mime-type, use that to decide whether or not to accept, and then serve them back to clients through a script. As an optional step, on really paranoid systems, I run a virus scan over the upload (with clamav, usually). I'm not exactly sure what all the fuss is about protecting IE users from malicious code - if they care then they shouldn't be using IE, and if they don't care they shouldn't be on the internet. Tim's efforts do seem to be a bit of overkill... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of beginner questions
Paul M Foster wrote: (snip) > But here's a question for those of you who work in a collaborative > environment-- are you really ever in a situation where some HTML weenie > is coding HTML pages and you're somewhere else doing the PHP work? Or is > that some academic's view of the way things *should* be done? > > Paul Yup, been there in a mid-sized web agency a few years ago, although with Java/JSP rather than PHP. The sensitive types drew the pretty pictures on their Macs, passed the design to the HTML hackers who broke the pretty pictures into sprawling arrays of table cells and image fragments, then passed the HTML to the Java teams (me and others) who had to slot in the logic without spoiling the pretty pictures. Then the sensitive types would see a pixel out of place and the HTML hackers would have to carefully navigate the logic sections and tweak the tables to make it look right again. It certainly focuses the mind about separating logic and presentation. In the end most of the JSP was done with JSP tag libraries, so that the HTML hackers were not too distracted by scary Java code. It actually all worked quite well, and produced some really beautiful web sites AND really elegant code libraries. But then the dot-com thing all fell over and it was too expensive for most people to pay for three teams and a couple of managers just to build a web shop... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: "use strict" or similar in PHP?
Hans Schultz wrote: > Is there in PHP something like "use strict" from perl? I find it pretty > annoying to need to run script over and over again just to find out that I > made typo in variable name. I find that my IDE catches most of the typos before I even try to run the page. I use Netbeans 6.5 with the PHP extension, but there are alternatives... > Is there some way for PHP to cache some data on the page? I like very much > PHP's speed but it would be even better to be able to cache some frequently > used data from database? Generally it's not worth the trouble, but you could cache in the session... Remember that PHP is largely stateless, so one page call knows nothing of any other page calls. This is different to Java, where you can hold state in the underlying virtual machine and recover it later... > Also regarding databases, I liked a lot java's way of sending data to > database > using parameters ("select * from user where username = ?" and then passing > parameter separately with database doing necessary escaping and > everything). > Is there something like PHPDBC similar to JDBC? With PostgreSQL (and probably MySQL too) you can do either a prepared statement (see http://www.php.net/manual/en/function.pg-prepare.php) and then execute that, or a simpler parameterised query (see http://www.php.net/manual/en/function.pg-query-params.php) Something like $sql = 'SELECT * FROM user WHERE username=$1'; $params = Array('pete'); $result = pg_query_params($sql,$params); That way you get the safest handling of values without any tedious messing about with manually escaping strings. I suspect that under the hood it actually prepares a statement and then executes it, but I might be wrong... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: preg_match and dates
Michael A. Peters wrote: > I have absolutely no control over the source file. > > The source file is an xml file (er, sort of, it doesn't follow any > particular DTD) and has a tag called VERBATIM_DATE in each record - > looks to be required in their output as every record so far has it, but > w/o a DTD hard to know - time of day, on the other hand, is not required > and sometimes (usually) the tag missing. > > Here's the beauty - VERBATIM_DATE in the same xml file uses multiple > different formats. IE - > > 12 March 1945 > 14 Mar 1967 > Apr 1999 > 12-03-2005 > Before 1904 > Winter or Spring 1977 > > etc. > > It does seem that if there is a day, the day is always first - but > sometimes it has a space as a delimiter, - as delimiter, and sometimes > it has both - IE > > 10-15 Dec 1934 > 12 March-03 April 1956 > > What I'm trying to do is write a preg matches for each case I come > across - if it matches the preg, it then parses according to the pattern > to get me an acceptable -MM-DD (not sure how I'll deal with the > season case yet ... but I'm serious, that kind of thing in there several > times) > > To at least get started though, is there a wildcard defined that says > match a month? > > IE > > /^([0-9]{2})[\s-](MONTH_MATCH)[\s-]([0-9]{4,4}$/ > > where MONTH is some special magic that matches Mar March Apr April etc. ? > > If you must know - it's data from a biology vertebrate museum. Thousands > of records may match a given query. Most of them look fairly easily > parsable and it does look like when a day is specified, it is always > first and year is always last. > > The data is needed by me, so I'm planning on having the script die if it > comes across a date I don't have a regex to parse before it does > anything so I can add appropriate regex as necessary, but damn - you'd > think a vertebrate museum would have cleaned up their DB somewhat. My first shot would be to see how far I get with strtotime(), or date_create(). The rest looks like a job for the Mechanical Turk (http://www.mturk.com/mturk). For your specific query, you could do something like (Jan|January|Feb|February|...) alternation, but that won't catch typos and idiosyncrasies. You probably want to make it case-insensitive too. I suspect you will end up with a bunch of records where the data cannot be parsed sensibly - I would probably write the list of such records to an exception file. Once you have a a system that generates a manageable number of exceptions you can deal with those by hand. As for your expectation of a museum: the reputation of "dusty old rooms full of stuff" is not entirely un-earned, so I wouldn't expect their databases to be spotless! -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whoami explanation
PJ wrote: > Per Jessen wrote: >> PJ wrote: >> >> >>> forgot to add: >>> What's the difference between back ticks or quotes and regular single >>> quotes? >>> >> text in back ticks is executed via a shell, text in single quotes isn't. >> > Ok, but how does this relate to a command passed from a php Web page? > I don't understand the processus. > I use bash on my FreeBSD and have not needed a back quote yet that I can > recall... and on WinXP? In your bash shell, you can use backticks in a similar way to how PHP uses them - to assign the output of a command to a variable. For example: LIST=`find . -name '*.php'` will fill up the shell variable $LIST with all the files with extension .php below the current directory. You could then do something with that variable, like for FILE in $LIST do cp $FILE $FILE.bak done to make a backup copy of each of the files. In PHP, something like should do much the same thing (if permissions etc. allow...) Note that in both of these examples, filenames with spaces in them will blow the whole thing up :( -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Web Development/Application Analysis
Robert Cummings wrote: > On Fri, 2009-03-20 at 11:34 +0300, OOzy Pal wrote: >> Hello, >> >> I have just hired a remote PHP programmer. His main job is web >> development and applications. >> >> I have few concerns, I would be happy if someone can point me to the >> right direction. >> >>1. How can I provide him the requirements. I mean how can I analyze >> the site and put everything in writing. > > How would you describe to a person what the problems are or what it is > you want? Pictures are worth a bazillion muggered up words, use > screenshots often. > >>2. How can I estimate manhours. > > If you're not a coder... you can't. > > Even coders often have trouble estimating man hours for a project. > > Cheers, > Rob. 1 Goes like this: Boss: I want the site to do this (blah ... blah ...) Me: Ok, do me a mock up of how you want it to look, and a quick sketch storyboard. Boss: Have you done that site yet? Me: Yes: here. Boss: That looks terrible! Me: Never mind the gloss, look at the functionality! Boss: But I wanted it to look like those ... pictures ... Me: ... that you never sent to me ... Boss: Oh. 2 Goes like this: Boss: How long will it take to code that up then? Me: An hour. Boss: Really? Me: No, a year. Boss: Eh? Me: Actually, somewhere between the two, I suspect... Boss wanders off, tearing out some more of the little hair remaining... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML data extraction
Andrew Williams wrote: > Best All, > > How can you best and accurately extract XLM data to DB table. e.g.: > > > - > > 20 > FRA > Frankfurt > > - > > 28 > LSE > London Stock Exchange > > - > > 226 > GER > Xetra > > > > www.willandy.co.uk > Oh, I thought of another one: Write some XSL to turn you XML into SQL. Write some code to run that SQL. HTH Pete -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML data extraction
Andrew Williams wrote: > Best All, > > How can you best and accurately extract XLM data to DB table. e.g.: > > > - > > 20 > FRA > Frankfurt > > - > > 28 > LSE > London Stock Exchange > > - > > 226 > GER > Xetra > > > > www.willandy.co.uk > Write some code to read the XML file. (you could at simpleXML, or DOMDocument-based stuff) Write some code to write the database statements. (probably some SQL, depends on your database) Run the database statements. (mysql_query, pg_query, whatever) This is a very vague question, and this list is not normally well disposed to writing people's programs for them, especially when they look like college assignments. Cheers Pete -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Button id's - firefox and IE different ?
Angus Mann wrote: > Hi all. > > I want to have several delete buttons with just one form, and depending on > which button is pressed, one of several items is deleted. > > So I need multiple submit buttons for 1 form, each displaying the same text > "Delete" to the user, but each with a different "value" so the PHP script can > tell them apart. > > I've used this code for the buttons... > Delete > Delete > Delete > > And it works just fine with firefox. But IE does not seem to pass the value > back to the btid so when the script asks > if $_POST['btid'] == "1" { > } > > the value 1, 2, or 3 is not given back to PHP by IE. It is given back > correctly by firefox and works fine. > > Any suggestions ? > > Thanks. > > Well, to answer your initial question, IE won't play like that - it uses the content of the button as the value and no amount of telling it is going to change that at present... I suspect this behaviour is one of those things that is ambiguously specified by the standards. The real question is ... why do you want to do that (tell the buttons apart, I mean)? From a user's perspective, if they are labelled the same, and in the same form, then surely they must do the same thing? Sounds like the form design needs to fresh thought. If you must do it like you this, you need to change the labels on the buttons, but remember: when you come to internationalize your site with twenty-six different languages then you'll have to check each possible translation in the back-end code. And if you decide to put images on the buttons instead of words then you are really up the creek... Either: split the form up so that different delete buttons act on their respective bits of the form. Or: bite the bullet and use javascript onclick events to set a hidden field which signals what the action is supposed to be in the back end. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Button id's - firefox and IE different ?
Peter Ford wrote: > Angus Mann wrote: >> Hi all. >> >> I want to have several delete buttons with just one form, and depending on >> which button is pressed, one of several items is deleted. >> >> So I need multiple submit buttons for 1 form, each displaying the same text >> "Delete" to the user, but each with a different "value" so the PHP script >> can tell them apart. >> >> I've used this code for the buttons... >> Delete >> Delete >> Delete >> >> And it works just fine with firefox. But IE does not seem to pass the value >> back to the btid so when the script asks >> if $_POST['btid'] == "1" { >> } >> >> the value 1, 2, or 3 is not given back to PHP by IE. It is given back >> correctly by firefox and works fine. >> >> Any suggestions ? >> >> Thanks. >> >> > > Well, to answer your initial question, IE won't play like that - it uses the > content of the button as the value and no amount of telling it is going to > change that at present... I suspect this behaviour is one of those things that > is ambiguously specified by the standards. > > The real question is ... why do you want to do that (tell the buttons apart, I > mean)? From a user's perspective, if they are labelled the same, and in the > same > form, then surely they must do the same thing? Sounds like the form design > needs > to fresh thought. > > If you must do it like you this, you need to change the labels on the buttons, > but remember: when you come to internationalize your site with twenty-six > different languages then you'll have to check each possible translation in the > back-end code. And if you decide to put images on the buttons instead of words > then you are really up the creek... > > Either: split the form up so that different delete buttons act on their > respective bits of the form. > Or: bite the bullet and use javascript onclick events to set a hidden field > which signals what the action is supposed to be in the back end. > There's a third option: make sure your clients only use Firefox :) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] W3C Validator and Post Arrays
Michael A. Peters wrote: > Shaun Thornburgh wrote: >> Hi, >> >> We are getting errors when trying to vaildate our HTML due to the [ >> character when using Post Arrays: >> >> Line 173, Column 65: >> character "[" is not allowed in the value of attribute "id" >> >> …e="filters[calling_url]" id="filters[calling_url]" >> value="categories-bulk-ear >> >> Does anyone know of a way around this? >> >> Thanks > > Don't use [] in an ID - it doesn't belong there. > If you are not using the ID for a hook, just drop it - the ID doesn't > need to be there. > > The name attribute is where you want the [] to post an array, ID does > not get sent in a post. The ID of any element should be unique in a HTML document - if you need an ID for each of the inputs then you'll have to generate a unique one for each. To the rest of the list: I'm not too happy about having stuff inside the [] either - is that some syntax I've missed or is it just wrong? -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] W3C Validator and Post Arrays
Peter Ford wrote: > Michael A. Peters wrote: >> Shaun Thornburgh wrote: >>> Hi, >>> >>> We are getting errors when trying to vaildate our HTML due to the [ >>> character when using Post Arrays: >>> >>> Line 173, Column 65: >>> character "[" is not allowed in the value of attribute "id" >>> >>> …e="filters[calling_url]" id="filters[calling_url]" >>> value="categories-bulk-ear >>> >>> Does anyone know of a way around this? >>> >>> Thanks >> Don't use [] in an ID - it doesn't belong there. >> If you are not using the ID for a hook, just drop it - the ID doesn't >> need to be there. >> >> The name attribute is where you want the [] to post an array, ID does >> not get sent in a post. > > The ID of any element should be unique in a HTML document - if you need an ID > for each of the inputs then you'll have to generate a unique one for each. > > To the rest of the list: I'm not too happy about having stuff inside the [] > either - is that some syntax I've missed or is it just wrong? > Oooh, I've just looked it up - that *is* neat! -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Java applet clearing session variables?
Dan King wrote: > It seems that our java applet is clearing our php session variables. > > I have an html form that saves user information as session variables. These > session variables are used to create folders, where uploaded files can be > saved. I've tested my php script that uses the session variables to create a > folder and then moves uploaded files to that folder with a traditional html > upload form. > However, when I use a java applet in place of the traditional html form the > php script does not create the folder, and thus it obviously cannot move the > uploaded files. > > I've tested the applet and it does successfully upload files to the server. > When I printed the session array variable after using the applet, I noticed > the session array was empty. Does anyone know why this the applet clears the > session variables? Or how to stop/work around it so I can use the applet and > the php script? > > Thanks, > > Dan > > > > The most likely thing is that the java applet isn't using the same session as the HTML. I suspect that the applet does not have access to, or does not attempt to access, the cookie that carries the session ID. You may have to prime the applet with the session ID somehow before it runs so that it can generate a PHP_SESSIONID (or whatever it is) cookie to send back to PHP... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP class or functions to manipulate PDF metadata?
O. Lavell wrote: > Hi group, > > I am looking for an easy way to manipulate (read, write) the metadata > (title, subject, keywords, author) in PDF files through PHP. > > Most PHP/PDF solutions I have found so far (through Google) are aimed at > constructing PDFs from text and graphics, with lots of fancy features, > but most of them omit metadata functions altogether. > > I would also prefer something extremely lightweight that I could just > include_once() into my script, i.e. not a module or external program. I > am currently using pdfinfo from xpdf-utils, but it has to go. > > My use case is I want to build a database with the metadata of a bunch > (many hundreds, perhaps thousands) of PDF files in a directory on the > server for easy search, statistics and retrieval. I also want users to be > able to make edits to any PDF's metadata from the web. > > If it can be at all avoided, I would rather not have to invent the wheel > myself here. I have looked at the Adobe PDF specification a bit and it > looks quite... challenging. Or should I say daunting. > > Any and all suggestions are welcome. Thank you in advance. > So many people ask about manipulating, editing and generally processing PDF files. In my experience, PDF is a write-once format - any manipulation should have been done in whatever source generated the PDF. I think of a PDF as being a piece of paper: if you want to change the content of a piece of paper it is usually best to chuck it away and start again... Even more so, this would apply to the PDF metadata: metadata is supposed to describe the nature of the document: it's author, creation time etc. That sort of data should be maintained with the document and ideally not changed throughout the document's lifetime (like the footer, or end-papers in a physical book) I do accept that the metadata should be machine-readable: that part of your project is reasonable and I'm fairly sure that ought to be possible with something simple. The best bet I found so far is PDFTK (http://www.pdfhacks.com/pdftk/) which is a command-line tool that you could presumably call with exec or whatever... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP class or functions to manipulate PDF metadata?
O. Lavell wrote: > Peter Ford wrote: > >> O. Lavell wrote: > > [..] > >>> Any and all suggestions are welcome. Thank you in advance. >>> >> So many people ask about manipulating, editing and generally processing >> PDF files. In my experience, PDF is a write-once format - any >> manipulation should have been done in whatever source generated the PDF. >> I think of a PDF as being a piece of paper: if you want to change the >> content of a piece of paper it is usually best to chuck it away and >> start again... >> >> Even more so, this would apply to the PDF metadata: metadata is supposed >> to describe the nature of the document: it's author, creation time etc. >> That sort of data should be maintained with the document and ideally not >> changed throughout the document's lifetime (like the footer, or >> end-papers in a physical book) > > Thank you very much for your reply. And it's not that I don't agree with > you. Because I do, completely. > > However... > > PDFs often come from sources that can't be bothered to fill in the > relevant fields correctly, completely, or at all. For those cases I would > like the users of my application to be able to correct the values found > in the metadata. Upload the PDF, get a nice little HTML form with 4 or 5 > values to review or edit. That sort of thing. > >> I do accept that the metadata should be machine-readable: that part of >> your project is reasonable and I'm fairly sure that ought to be possible >> with something simple. The best bet I found so far is PDFTK >> (http://www.pdfhacks.com/pdftk/) which is a command-line tool that you >> could presumably call with exec or whatever... > > Like I said, this is what I am already doing with the pdfinfo utility > from xpdf. Sorry - I guess I didn't read that bit carefully enough... > > But now that you mentioned pdftk... I just tried it and it does seem to > come close to what I want. It is capable of writing a new PDF with the > contents of an existing one, with new metadata fed as a text file. So it > shouldn't be very hard to write a little PHP around that process. > > Now I need to think a bit more about this approach. Perhaps it can be > implemented using only pure PHP, after all. But for the time being, pdftk > will do. > > So thank you again for pushing me in that direction, even if > unintentionally and despite the fact that what I am doing goes against > your judgement ;) > As I know only too well, you can't always choose your customers (especially if they choose you...) and you certainly can't control all of the sources of data you have to deal with! I have spent many hours/days/possibly longer hacking through files that are in one form to get data into another, and PDF is the one that always makes me nervous :( My judgement is certainly not final, or even particularly important: if I had time I would also look into at least getting the metadata with pure PHP. Good luck... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Larger fonts...
Patrick, The reason you think the fonts are too small is that you have (un)zoomed the screen at some point. The proportions of the centre white panel to the side bars is wrong. Measuring your screenshots, and assuming you had a full-screen browser window at 1680x1050 resolution (what your monitor does), I work out that the white section of the screen is only around 800 pixels wide - it is defined to be 1000 pixels wide at normal magnification. Measuring the icons suggests that your screen is showing them at 42 pixels, while they are supposed to be 56 pixels. Overall, your seeing the whole thing at 80% full size - no wonder the fonts look small! The fonts and icon sizes haven't changed for about a year, and you haven't really complained before. In addition, you are using a pretty large screen - the pages are designed to work on a 1024x768 screen as a minimum. Making the fonts larger would drastically reduce the amount of information displayed vertically - it's already pretty tight on some of the design screens. So, I'll ignore the calls for bigger fonts and icons. The button icons may also look better at full size, but the main problem is that they need to be properly designed. Replacing them with just words is not very good - it makes them all different sizes, which messes up the layout. I could remove the shaded background and see if that helps. Other points I will work on. Cheers -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Larger fonts...
Tom, You're right - I tried to catch it before it went, but just too late! To the list - please ignore the message Tom refers to - it's not too commercially sensitive, at least. I probably need more coffee before fielding bug reports in the morning. Cheers Pete Tom Chubb wrote: > Pete, > Before you get slated by the list, I'm guessing you meant to send this > to someone else? > (It came to me via the PHP-General Mailing List. > > Tom > > 2009/4/8 Peter Ford mailto:p...@justcroft.com>> > > Patrick, > > The reason you think the fonts are too small is that you have > (un)zoomed the > screen at some point. The proportions of the centre white panel to > the side bars > is wrong. > Measuring your screenshots, and assuming you had a full-screen > browser window at > 1680x1050 resolution (what your monitor does), I work out that the > white section > of the screen is only around 800 pixels wide - it is defined to be > 1000 pixels > wide at normal magnification. Measuring the icons suggests that your > screen is > showing them at 42 pixels, while they are supposed to be 56 pixels. > Overall, > your seeing the whole thing at 80% full size - no wonder the fonts > look small! > > The fonts and icon sizes haven't changed for about a year, and you > haven't > really complained before. > > In addition, you are using a pretty large screen - the pages are > designed to > work on a 1024x768 screen as a minimum. Making the fonts larger would > drastically reduce the amount of information displayed vertically - > it's already > pretty tight on some of the design screens. > > So, I'll ignore the calls for bigger fonts and icons. > > The button icons may also look better at full size, but the main > problem is that > they need to be properly designed. Replacing them with just words is > not very > good - it makes them all different sizes, which messes up the layout. > I could remove the shaded background and see if that helps. > > Other points I will work on. > > Cheers > > -- > Peter Ford phone: 01580 89 > Developer fax: 01580 893399 > Justcroft International Ltd., Staplehurst, Kent > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > Tom Chubb > t...@tomchubb.com <mailto:t...@tomchubb.com> | tomch...@gmail.com > <mailto:tomch...@gmail.com> > 07912 202846 -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generate XHTML (HTML compatible) Code using DOMDocument
Michael Shadle wrote: > On Mon, Apr 13, 2009 at 2:19 AM, Michael A. Peters wrote: > >> The problem is that validating xhtml does not necessarily render properly in >> some browsers *cough*IE*cough* > > I've never had problems and my work is primarily around IE6 / our > corporate standards. Hell, even without a script type it still works > :) > >> Would this function work for sending html and solve the utf8 problem? >> >> function makeHTML($document) { >> $buffer = $document->saveHTML(); >> $output = html_entity_decode($buffer,ENT_QUOTES,"UTF-8"); >> return $output; >> } >> >> I'll try it and see what it does. > > this was the only workaround I received for the moment, and I was a > bit afraid it would not process the full range of utf-8; it appeared > on a quick check to work but I wanted to run it on our entire database > and then ask the native geo folks to examine it for correctness. I find that IE7 (at least) is pretty reliable as long as I use strict XHTML and send a DOCTYPE header to that effect at the top - that seems to trigger a standard-compliant mode in IE7. At least then I only have to worry about the JavaScript incompatibilities, and the table model, and the event model, and -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: error in printer_open function
AYAN PAL wrote: > hi, > i am using local server to print a simple text > i config the php.ini file as > ;extension=php_printer.dll > added in the extension list > and add > [printer] > printer.default_printer = "Send To OneNote 2007" > in this file > > and write a sim ple page as- > > > > > > Prabal Cable Network > > > > > > The ";" at the start of the configuration line in php.ini is a comment character... Remove that, restart the web server, and you might see things working better. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] object literals
Richard Heyes wrote: > Hi, > >>$x = (object) array('a'=>1, 'b'=>3, ...); >> >> which works but isn't very lovely. it's neater in, for example, javascript. > > Well, you could wrap it up in a function to make it a bit lovelier. Eg: > > $foo = createObject(array('key' => 'value')); > > It's not great, but PHP doesn't have a object literal syntax AFAIK. > You could use JSON, $foo = json_decode('{"a":1,"b":3}'); but I guess that's not much better than Richard's suggestion. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: graphical integrated development environment recommendations?
Adam Williams wrote: > With the wide range of users on the list, I'm sure there are plenty of > opinions on what are good graphical IDE's and which ones to avoid. I'd > like to get away from using notepad.exe to code with due to its > limitations. Something that supports syntax/code highlighting and has > browser previews would be nice features. I'm looking at Aptana > (www.aptana.com) but it seems like it is more complicated to use then it > should be. Either Linux or Windows IDE (i run both OSes) > recommendations would be fine. > Netbeans: works on Windows or Linux (or OSX, if you're that way inclined), and it's free. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- 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
tedd wrote: (and I added in some extra bits...) > You need to normalize. > > Authors should have an unique id in an authors table. The authors table > has all the specific information about authors, but not the books they > have written. > > Books should have an unique id in a books table. The books table has all > the specific information about books, but not the contributing authors. > Like the ISBN, for example - that should be unique enough for anyone... I suppose if you deal in antique books, there might not be an ISBN. > Then you connect the two tables with a Book-Author table that has only > the id's of both -- no real need for any other information. > This also has the advantage that when you come to add new books by authors already in the database, you only have to look the name up, and you can avoid duplicating authors with misspelt names, etc. You will have to allow for the case of a book with multiple authors, but that should work out fine - you just have two (or more) records in the Book-Author table to link the same book to several authors, and logic that watches out for that when you extract the data. > That way when you want to see all the books an author has written, then > you pull out all the records that has the author's id and look up each > book via the book id. > > Likewise, when you want to see all the authors who have contributed to a > book, then you pull out all records that has the book's id and look up > each author via their author id. > > Do you see how it works? > > Cheers, > > tedd > It always surprises me how many people need to have database normalisation explained to them - it seems obvious to me... (and tedd, clearly!) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- 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
tedd wrote: > At 3:14 AM -0700 5/6/09, Michael A. Peters wrote: >> Peter Ford wrote: >>> >>> tedd wrote: (and I added in some extra bits...) >>>> You need to normalize. >>>> >>>> Authors should have an unique id in an authors table. The authors table >>>> has all the specific information about authors, but not the books they >>>> have written. >>>> >>>> Books should have an unique id in a books table. The books table has >>>> all >>>> the specific information about books, but not the contributing authors. >>>> >>> >>> Like the ISBN, for example - that should be unique enough for anyone... >>> I suppose if you deal in antique books, there might not be an ISBN. >> >> Unfortunately sometimes an otherwise identical but different printing >> of the same book has different ISBN numbers. Sometimes the difference >> is hardback vs softcover, special edition, or just a reprint. >> >> The L.O.C. catalog number may be better, AFAIK there is typically only >> one LOC number per edition of a book. It is a good idea to record both >> (if both exist) and use an internally assigned substitute number when >> one, the other, or both don't exist (small run self published works >> often don't have a LOC number for example, if the author didn't want >> to pay for it). > > > But for a database, a book identifier would probably be best (differing > opinions on this) if it was simply an auto_increment unsigned integer > primary key. A key that is generated upon entry of a book record. > > Certainly one can argue that using a different unique key might provide > more information and make the table require one less field, but if one > uses a primary key, then the field can be searched faster than using a > ISBN or L.O.C., which may be duplicated, amended, or not even present. > My thinking on this is a unique identifier for the book should not be > tied to any attribute of the book, which may change, but rather > something completely detached and artificial. > > Cheers, > > tedd > tedd, That is, in fairness, probably what I'd do too: I might have the ISBN or LOC number as a detail field in the book record, and have it available for look-ups, but the primary key would just be a sequence number generated automatically. Same with authors, just a sequence number for the key. (I am not a number, I am a free man...) These things do not need to be visible to the user. Just an implementation detail, nothing to see here... :) Cheers Pete -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Trying to create a colortable - what am I missing here?
Thodoris wrote: > >> דניאל דנון wrote: >>> I've tried to make a color table, but I am missing something. not in the >>> color-table-code itself, but in somewhere else... I just can't find... >> >> untested but try.. >> >> // 4096*4096 = 16777216 = FF+1 >> $im = imagecreate(4096, 4096); >> $white = imagecolorallocate($im, 0, 0, 0); >> $r = $g = $b = $x = $y = 0; >> $max = 255; >> while ($r <= $max) { >> while ($g <= $max) { >> while ($b <= $max) { >> $n = imagecolorallocate($im, $r, $g, $b); >> imagesetpixel($im, $x, $y, $n); >> $x = $x == 4096 ? 0 : $x+1; >> $y = $y == 4096 ? 0 : $y+1; >> $b++; >> } >>$b = 0; >>$g++; >> } >> $g = 0; >> $r++; >> } >> header("Content-Type: image/png"); >> imagepng($im); >> imagedestroy($im); >> >> > > Never used image manipulation with PHP but this is giving me a black image. > You probably need $im = imagecreatetruecolor(4096,4096); Also be aware that creating a truecolor image 4096 pixels square is going to take a LOT of memory, and it will take a while to download to the client, AND it is 4096 pixels square! That's a fair bit bigger than most screens... I suspect the OP is going to have to rethink this... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can not read write file from Desktop
Thodoris wrote: > >> hi >> I was trying to read a file from Desktop (Centos), >> >> Simply saying (php code file is in /var/www/html/ ) >> >> if (file_exists("/root/Desktop/conf_files_linux")) >> echo "yes file is there"; >> else >> echo "no none"; >> >> It gives me none. >> If i place conf_files_linux file in /var/www/html. i get yes... >> >> >> After checking log file i got >> >> [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) >> >> What i need to do, so tht i can access files from outside? >> help pls >> >> thanx >> > > I assume that this running by the web server (/var/www/html) so a wild > guess is that the user that your web server uses to run (usually apache > or www) cannot access the Desktop directory. In order to use the suexec > feature you need to configure it or else the web server user needs to > have read/write rights to the directory you need to access like the > Desktop. > > Though this not recommended. You could always run this script from > command line being root or whatever user is the owner of the Desktop > directory. Read this if you are not aware of how this can be done: > > http://www.php.net/features.commandline > If the OP's system is set up properly, then nobody but root should be able to read ANY of root's home directory, so the files will not be found. For a start, one doesn't want config files in anyone's home directory if they are for a system-wide server. And one doesn't EVER want to have anything in /root that anyone but root needs to access. And one shouldn't be logged in as root unless one is doing a short-lived system maintenance task: certainly one should not doing development work there... I know it sounds dictatorial, but it's (part-way to) best practice... Those config files should be in something like /etc/apache/extra, perhaps, if they are not safe in the web root (which they probably are not, unless the web server is configured to keep them safe) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]Cannot output the same data from text file in PHP
Moses wrote: > Hi Folks, > > I have a written a script in PHP which outputs the result from a text file. > The PHP script is as follows: > > $alldata = file("result.txt"); > echo ""; > foreach($alldata as $line_num => $line) { > echo $line.""; > } > echo""; > ?> > > I have attached the result.txt file. However the output of the script is as > follows: > > > Query: 1 atggcaatcgtttcagcagattcgtaattcgagctcgcccatcgatcctcta 60 > > Sbjct: 1 atggcaatcgtttcagcagattcgtaattcgagctcgcccatcgatcctcta 60 > > which is not exactly as in the result.txt file in that the pipelines > are displaced. > > Any pointer to this problem shall be appreciated. Thanking you in advance. > > Moses > Not a PHP problem, but a HTML problem: First, HTML compresses white space into just one space, so all of those leading spaces on line 2 are lost. Second, you are (probably) displaying using a proportionally-spaced font, so the narrow pipeline characters take up less width than the letters. So you need something like: "; foreach($alldata as $line_num => $line) { echo $line."\n"; } echo""; ?> -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] When is __destruct called on an object in $_SESSION ?
I'm sure I've seen something about this before, but I can't find it: I'm creating a file which needs to live for the duration of a session, and ONLY the duration of the session. I made a little call which holds the name of the file like this: file = '/tmp/'.session_id().'.xml'; } public function __get($name) { if ($name=='file') return $this->file; } public function __destruct() { @unlink($this->file); } } ?> So I create an instance of this object and I put a reference to the object in the session: I was then expecting TFR::__destruct() to only be called when the session was closed, with either a timeout, or a session_destroy() call. But it looks like the object destructor is called at the end of every page. Any ideas about working around that? -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] When is __destruct called on an object in $_SESSION ?
Stuart wrote: > 2009/5/14 Peter Ford : >> I'm sure I've seen something about this before, but I can't find it: >> >> I'm creating a file which needs to live for the duration of a session, and >> ONLY >> the duration of the session. >> I made a little call which holds the name of the file like this: >> > class __TFR >> { >>private $file; >>public function __construct() >>{ >>$this->file = '/tmp/'.session_id().'.xml'; >>} >> >>public function __get($name) >>{ >>if ($name=='file') return $this->file; >>} >> >>public function __destruct() >>{ >>@unlink($this->file); >>} >> } >> ?> >> So I create an instance of this object and I put a reference to the object in >> the session: >> >> >$_SESSION['TFR'] = new __TFR(); >> ?> >> >> I was then expecting TFR::__destruct() to only be called when the session was >> closed, with either a timeout, or a session_destroy() call. >> But it looks like the object destructor is called at the end of every page. >> Any ideas about working around that? > > The destructor will be called at the end of each page request because > the object in memory is destroyed. > > When the object is serialized you will get __sleep being called, and > when it's unserialized you'll get __wakeup. > > There is no way to detect when a session is destroyed unless you > implement your own session handler. > > -Stuart > Oh bother. I guess it's a consequence of the statelessness of the PHP engine. I thought I might be able to set a flag in __sleep() to indicate that the session had been serialised rather than destroyed, but __destruct() is called before __sleep(). I will have to see whether it is worth coding a custom session handler or to just let the disk fill up... :) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Software to read/write Excel to CD?
Matt Graham wrote: > Ashley Sheridan wrote: >> Paul M Foster wrote: >>> On Thu, May 14, 2009 at 03:22:12PM -0500, Skip Evans wrote: >>>> One of the things the other company said was possible, and I'm >>>> not familiar with... if I understand correctly, is to create a >>>> CD with not just an Excel spreadsheet, but software on that CD >>>> that when placed in another computer will open the >>>> spreadsheet, allow it to be modified and rewritten back to the CD. > > It has to be a CD-RW, the CD-RW has to be in UDF format, and the host > machine has to be able to read and rewrite CD-RWs in UDF. This is > actually not that tough to arrange--it just has nothing to do with > PHP. 'DozeXP should be able to do this, and Linux will do this if the > right kernel options are on. Don't know about OS X. > >>> Second, include some other program which >>> would do the same thing. Good luck with that. > > OOO Calc, which should be just fine for basic tasks and is Free. > >>> And now the kicker-- write the spreadsheet back to CD. Okay, maybe, if >>> it's a CD-RW. But who's going to pay attention to that little detail? >>> And as far as I know, writing to a CD is far more complicated than >>> writing to a hard drive. You can't overwrite data on a CD-RW. > > UDF, which has been a standard for quite some time, allows this. The > main thing you lose is some space on the CD-RW. > >> I've never heard of anything like that, there are so many unknown >> variables that I would really feel for the poor team who had to take >> that project on! > > It sounds like whoever defined the requirements was trying to solve a > problem in the wrong way. Why drag physical media into this when you > have the Net available? And if the clients don't have the Net > available, *why not*? > It *is* possible to be offline, and so far from anywhere that the only com links are to satellites... (expensive). I suspect that a USB key is a better option (and more physically portable) than a UFB CD. But why write an Excel spreadsheet - why not save the data in something more portable like CSV that ExCel and read and write to once you are back at base? -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Parsing of forms
Daniele Grillenzoni wrote: > I noticed that php's way to fill $_GET and $_POST is particularly > inefficient when it comes to handling multiple inputs with the same name. > > This basically mean that every in order to function > properly needs to have a name ending in '[]'. > > Wouldn't it be easier to also make it so that any element that has more > than one value gets added to the GET/POST array as an array of strings > instead of a string with the last value? > > I can see the comfort of having the brackets system to create groups of > inputs easily recognizable as such, while I can overlook the > impossibility of having an input literally named 'foobar[]', having to > add [] everytime there is a slight chance of two inputs with the same name. > > This sounds flawed to me, as I could easily append '[]' to every input > name and have a huge range of possibilities unlocked by that. > > This can't be right. Or can it? Isn't it ironic that a post about multiple form inputs is posted four times? That's not a good way to make friends here, Daniele... I really don't understand your complaint - in general if your form has multiple inputs with the same name, then you either meant to do that, (like a multiple select, in which case there's not really a big deal to add the []), or it's wrong and wouldn't work as expected anyway. You could append [] to every input - that would be lovely, but it would hide the possibility that you mistakenly gave two inputs the same name. It's true that every so often I can't work out why something is not posting an array to PHP when I expected it to, and a look back to the form to find I'd missed a [] on the name is the answer. As I like to say in other areas of life (especially to my children), "stop whining and get on with it!" ( sorry :) ) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] formatting - design question
PJ wrote: > tedd wrote: >> At 3:58 PM -0400 6/4/09, PJ wrote: >>> tedd wrote: >>> >>> > Style sheets are meant simplify things so decide on how you want >>>> things to look uniformly throughout your site and then stick with it. >>>> There's really no good reason to keep changing things throughout a >>>> site. >>>> >>>> Cheers, >>>> >>>> tedd >>>> >>>> >>> Maybe I'm just too complicated. ;-) >>> I do try to keep it simple. But then, little things creep in, like a >>> login box on the index page which mucks up all the other pages. Then >>> there is a recipe page which is totally different, yet to keep is >>> stylistically continuous it uses a similar layout to the other pages but >>> different. The same for the main recipe page, and the same for the >>> portraits of producers - all the pages are different yet remain within a >>> cohesive style. CSS gets super bloated and almost unamageable. Most >>> sites are very repetitive; mine tend to be "provocative" or semthing >>> like that. I really don't see an ooption. Although, Nitsan's body tags >>> sound promising. I'll have to try that; maybe the solution is to do a >>> series of definitions unique just fo certain pages. :-) >> That's simply an example of not thinking things out before you write >> the code. >> >> First you figure out a layout, then you populate it. You don't pick a >> layout, populate it and then change the layout. That leads to a >> lackluster and "lack of thought" site. >> >> Cheers, >> >> tedd >> >> > If only it were that simple. > When one is developing, one is always changing. And even when you're > finally "live and on the air", you will still be changing or else your > site will die before your client gets a chance to see all you can offer. > It's a matter of evolution and adaptation, Darwin. ;-) > Agree with PJ here: More likely, you go live and the boss says "Can you make that look more like ...?" "Er, yes, but it totally stuffs the whole design..." Evolution was *not* carefully thought out - that would be Intelligent Design -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Any conflict with $_POST when 2 users concurrently submitting the same form using POST method?
Keith wrote: > Let's say user A and user B submitting purchase order form with > "order.php" at the same time, with method=post action='confirmation.php'. > > (1) Will $_POST['order'] submitted by user A replaced by > $_POST['order'] submitted by user B, and the both user A & B getting the > same order, which is made by user B? Why? > > (2)Since $_POST['xxx'] is superglobal array, will $_POST['order'] > read by users other than A & B? In shared hosting server environment, > are all domains hosted within that server using the same $_POST array? > Can $_POST array accessible by all domains even if not from the > originating domain? > > Thx for clarification! > > Keith Other posters have explained, but I'm not sure their explanations are clear. Think of it like this: User A posts to "confirmation.php". When the server receives the request, it starts up a Process and fills the $_POST array with whatever came in, then runs confirmation.php with that information. User B posts to "confirmation.php". When the server receives the request, it starts up a Process and fills the $_POST array with whatever came in, then runs confirmation.php with that information. The KEY thing is that the process in each case is entirely separate. Each makes it's own copy of the script in its own bit of memory, and each has its own version of $_POST in its own bit of memory. The two posts can happen at the same time and they will still be completely independent. The fact that $_POST is called "superglobal" does not mean that it is shared by separate requests - it is not even shared by requests in the same session. It just means that it is already declared and you don't need to use the "global" keyword to access it in your PHP pages. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Dynamic Titles
David Robley wrote: > Austin Caudill wrote: > >> Hello, im trying to make the CMS system im using more SEO friendly by >> giving each page it's own title. Right now, the system assigns all pages >> the same general title. I would like to use PHP to discertain which page >> is being viewed and in turn, which title should be used. >> >> I have put in the title tags the variable "$title". As for the PHP im >> using, I scripted the following: >> >> $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'"; >> switch ( $url ) >> { >> default: >> $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts Tutorial >> Search"; break; >> >> case "$config[HTTP_SERVER]help.php" : >> $title = "Newtuts Help"; >> break; >> } >> >> Right now, im getting this error: >> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting >> T_STRING or T_VARIABLE or T_NUM_STRING in >> /home/a7201901/public_html/includes/classes/tutorial.php on line 803 >> >> Can someone please help me with this? >> >> >> >> Thanks! > I'm guessing that line 803 is > > $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'"; > > which is full of mismatched quotes :-) Try any of > > $url = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}"; > $url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; > $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; > > Cheers Also the line: case "$config[HTTP_SERVER]help.php" : probably won't work very well : should be either case $config[HTTP_SERVER].'help.php': or case "{$config[HTTP_SERVER]}help.php": according to whether you like interpolation in quotes or not. I recommend finding a development environment or editor that does syntax highlighting - that would catch all of these problems before you even save the file. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Search/Replace in entire database?
Chris Payne wrote: > Hi everyone, > > I am in the middle of creating an editor where you can search and > replace on an individual column in a single table then I came across > something I need to be able to do but not sure how. > > Is it posible (And if so please how :-) to search an entire database > and all tables within a database and do a find/replace on keywords > without having to specify each table/column within that table? > > The people I am working for have made some big changes and one of them > is changing the names of one of their products, but this product name > appears EVERYWHERE in many tables and in lots of different column > names, and it would save so much time if I could do a single query > that would just search EVERYTHING within the database. > > Thanks for any advice you can give me. > > Regards > > Chris Payne Chris, This is not really a PHP question, is it? More like a question for the support group that corresponds to your database software... However, in my experience databases don't allow a cross-table update in a single query - you won't be able to do it in one query. You will either have to 1. work out which columns and tables contain the name 2. script a query to make the changes for each separately 3. test it on a backup version of the database 4. fix the bugs 5 run the script on the live database. OR (possibly) 1. block access to the database (to prevent any changes while you are processing) 2. dump the whole DB to an SQL script 3. do a search and replace on the text of the SQL script 4. Drop the existing data and reload the database from your SQL dump 5. enable access again so that the users can find the (inevitable) mistakes. These are both pretty time-consuming - sorry! Then make a business case for the project of normalising the database, at least with respect to the product names... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] populate form input option dropdown box from existing data
PJ wrote: > I'm including the relevant code: > > // select categories for book to be updated > $sql = "SELECT id, category FROM categories, book_categories > WHERE book_categories.bookID = '$bid' && > book_categories.categories_id = categories.id"; > if ( ( $results = mysql_query($sql, $db) ) ) { > while ( $row = mysql_fetch_assoc($results) ) { > $selected[] = $row['id']; > } > } > else $selected = Array( 0 => '0'); > echo $selected; > print_r($selected); > > $sql = "SELECT * FROM categories"; > echo ""; > if ( ( $results = mysql_query($sql, $db) ) !== false ) { > while ( $row = mysql_fetch_assoc($results) ) { > if (in_array($row['id'], $selected)) { >echo "> ", $row['category'], ""; >} >else echo "", > $row['category'], ""; > } > } > > Problem #1)in the first query result. I can't figure out how to deal > with it. The code works fine if there are categories assigned to the > book. If not, an undefined variable error is spewed out for selected. > That's because the test you use for the success of the query: ( ( $results = mysql_query($sql, $db) ) !== false ) is true if and only if the query succeeds, whether or not you get any rows returned. You then start looping over the fetched rows, and if there are none $selected never gets anything assigned to it, and so never gets defined. Since you don't rely on $selected being actually populated (in_array works fine on an empty array...), you might be better off pre-setting $selected before you start the first query: $selected = Array(); $sql = "SELECT id, category FROM categories, book_categories WHERE book_categories.bookID = '$bid' && book_categories.categories_id = categories.id"; if ( ( $results = mysql_query($sql, $db) ) ) { while ( $row = mysql_fetch_assoc($results) ) { $selected[] = $row['id']; } } > Problem #2) in the second query, the selected is in the source code but > it is not highlited. Several times I did get the categories highlighted, > but I could never catch what it was that made it work. When I had the > $id problem, i was trying this code from Yuri (but I don't understand > where he got the $id from ) : > The HTML you generate in the selected case is not quite right - you should have quotes around the "value" attribute's value, and you missed a closing '>' off the option tag... while ( $row = mysql_fetch_assoc($results) ) { if (in_array($row['id'], $selected)) { echo "", $row['category'], ""; } else { echo "", $row['category'], ""; } } More succinctly: while ( $row = mysql_fetch_assoc($results) ) { $sel = in_array($row['id'], $selected) ? "selected='selected'":""; echo "{$row['category']}"; } Unless the code is seriously performance critical, I still think variable interpolation is nicer to read than all those quotes and commas, and it keeps the HTML structure together better... Good luck -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: aesthetic beauty in conception, execution
PJ wrote: > I just thought I would share a revelation. > Someone just pointed me to a site that IMHO is superb for elegance of > artistic design and programming. > I was blown away. > http://www.apfq.ca > You won't regret it. 8-) > Il y a seulement une problème - je ne lis pas Française... I18N - it's important, you know... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: accessing level above $_SERVER['DOCUMENT_ROOT']
LAMP wrote: > hi, > > I have this structure: > /home/lamp/mydomain/html > /home/lamp/mydomain/logs > /home/lamp/mydomain/config > etc. > > html directory is the only one accessible from outside. > > to access config file I can use this: > required_once('/home/lamp/mydomain/config'); > > but this is the structure on my local/development machine. once the site > is done it will be moved to "production" server and the structure will be > /srv/www/mydomain/html > /srv/www/mydomain/logs > /srv/www/mydomain/config > etc. > > to "automate" the document_root I define on the begining of the page > > define('HTML_PATH', $_SERVER{"DOCUMENT_ROOT']); > define('CONFIG_PATH', $_SERVER{"DOCUMENT_ROOT'].'/../config'); > define('LOGS_PATH', $_SERVER{"DOCUMENT_ROOT'].'/../logs'); > > it works but I think it's not good solution. or at least - it's not nice > solution :-) > > suggestions? > > afan > > Outside of a define, you could have used dirname($_SERVER["DOCUMENT_ROOT]), but in a define, that's not going to work. I think you're stuck with your inelegance... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I've some doubts if I should go with 5.2 or go alreadywith 5.3 (for a course)
Robert Cummings wrote: > Per Jessen wrote: >> Manuel Aude wrote: >> >>> I'm giving a PHP course next semester (3 hours all saturdays for 22 >>> weeks) and I just realized that PHP 5.3 is coming very soon (2 days >>> now!). So, my plans of teaching PHP 5.2 are starting to change, and I >>> think it's a good idea to teach them 5.3 already. >> >> Does it _really_ matter which one? I can't imagine there are that many >> revolutionary changes in a dot-release. > > Given the naming of PHP versions of PHP-x.y.z, I would agree that not > much changes between versions at the .z level. But at the .y level there > are usually significant changes. > > Coming to a PHP 5.3 near you are the following notable features: > > - namespaces > - closures > - late static binding > - garbage collector to handle cyclic references > - PHAR > - goto > > Cheers, > Rob. I read that last bit as PHAR togo Need coffee... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Echo result in a loop on each instance
Anton Heuschen wrote: > I have a question regarding echo of a var/string in a loop on each instance > > A shortened example: > > Lets say I have an array of values (rather big), and then I loop > through this array: > > for or foreach : > { >$value = $arrValAll[$i]; > >echo "test".$i."--> ".$value; > } > > > When the script runs it will only start to echo values after certain > period ... it does not echo immediately ... how can I force it start > echo as soon as the first echo instance is done ? I thought ob_start > does this but I have tried it and not getting what I want. > > Is there some other way/correct to do this? call flush() after each echo to flush the buffer to the client. That should work... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Scope woe
Luke wrote: > Hello again guys, > > I was wondering the best way to tackle the following problem: > > I've got a class, containing a property which is another object. So from > outside I should be able to do > $firstobject->propertycontainingobject->methodinsidethatobject(); > > The $firstobject variable is in the global namespace (having been made with > $firstobject = new FirstObject;), and I'm having a problem that I'm sure > many people have when accessing it inside another class, so: > > class otherObject > { > static function messwithotherthings () > { > $firstobject->propertycontainingobject->methodinsidethatobject(); > } > } > > But $firstobject is blank, which makes sense because in there it is pointing > to the local variable within the method. > > To solve this, I could add 'global $firstobject' inside every method, but > this is very redundant and boring. I've tried a couple of things like > adding: > > private $firstobject = $GLOBALS['firstobject']; > > But apparently that's bad syntax. I was just wondering the best way to get > around this? > > Thanks a lot for your help, > Set the value of $firstobject in the constructor of otherObject (that's what constructors are for!): eg. class otherObject { private $firstobject; function __construct() { $this->firstobject = $GLOBALS['firstobject']; } static function messwithotherthings () { $this->firstobject->propertycontainingobject->methodinsidethatobject(); } } -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Scope woe
Luke wrote: >> > Thanks for the replies :) > > Surely if I pass it as a parameter to the __construct then I would have to > make an instance of the otherObject, notice that messwithotherthings is > static? > > Also, if I'm not using OOP properly, Eddie, how would I use it properly to > prevent this situation? > > Thanks, > Hmmm, I didn't notice the method was static - that means my idea really won't work... I did have a bad feeling about this, and Eddie confirmed my unease with the point about OOP. Really, you should need your $firstobject to be a singleton: eg. class FirstObject { private static $theInstance = NULL; public $propertyContainingObject; protected function __construct() { // whatever } public static function getInstance() { if (!self::$theInstance) { self::$theInstance = new FirstObject(); } return self::$theInstance; } // ... other methods ... } So then: class OtherObject { static function messWithOtherThings() { $firstObject = FirstObject::getInstance(); $firstObject->propertyContainingObject->methodInsideThatObject(); } } I think that works, and is reasonable to the OOP purists... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [GD] Image errors
Ash, Martin, Seems you are both wandering around the obvious problem... I suspect that $tipo (in the next line) is *supposed* to be $type - sounds like a partial Italian translation to me... So given that $type="imagecreatefrompng" (for example, if the mime check returns 'png' - not very reliable, I suspect), then $immagine = $type($this->updir.$id.'.png') should create a GD resource from the file, but the image appears to be empty. My take on this is: OP says he gets the same result from $immagine = imagecreatefromjpeg(this->updir.$id.'.png') - well I might expect to get an error message if I loaded a PNG expecting it to be a JPEG, but I certainly wouldn't expect an image. On some basic tests, I find that mime_content_type() is not defined on my system, so ignoring that and trying to load a PNG file using imagecreatefromjpeg results in pretty much the same result as the OP... Conclusions: First: if you use Italian for your variable names, don't change half of their instances to English... Second: Make sure you actually know the mime type of a file before you try to load it into GD... My version of this would test against known image types to try the GD function: foreach (Array('png','jpeg','gif') as $typeName) { $type = 'imagecreatefrom'.$typeName; $immagine = $type(this->updir.$id.'.png'le); if (is_resource($immagine)) { header('Content-type: image/jpeg'); imagejpeg($immagine,null,100); imagedestroy($immagine); break; } } header('HTTP/1.0 500 File is not an allowed image type'); -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [GD] Image errors
Martin Scotta wrote: > Why are you ussing GD? > All you need is output the image to the browser? > > try this... I didn't test/run this code, but it may work... > > public function showPicture( $id ) { > header('Content-type:' . mime_content_type( $this->updir . $id . > '.png' ) ); > readfile( $this->updir . $id . '.png' ); > } > > hey, look, just 2 lines! > But it doesn't convert the image from whatever came in to a JPEG output, which is what the OP's code appears to be trying to do (and possibly ought to work...) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: newbie question - php parsing
João Cândido de Souza Neto wrote: > You made a mistake in your code: > > > > must be: > > > Not necessarily: what if you have function the_title() { echo "Title"; } for example... In response to Sebastiano: There would be not much point in using something like PHP if it ignored the "if" statements in the code! What effectively happens in a PHP source file is that all the bits outside of the tags are treated like an "echo" statement (except that it handles quotes and stuff nicely) Your original code: can be read like: '; the_title(); echo ''; } ?> You might even find a small (but probably really, really, really small) performance improvement if you wrote it that way, especially if it was in some kind of loop. Note that I prefer to keep HTML separate from PHP as much as possible because it helps me to read it and helps my editor check my syntax and HTML structure better... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Undefined Index ...confusion
Miller, Terion wrote: > I keep getting this error while trying to use the field 'ID' to pass in a > url.. And it's odd because the query is pulling everything BUT the ID which > is the first field... > > code: > htmlspecialchars(stripslashes($_SESSION['fullRestaurantList'][$i]['name'])); > ?> What's the query? I find (I use PostgreSQL rather than the mySQL that many on this list use) that unless you explicitly ask for a field called ID (using SELECT "ID" ... ) you get a returned field in lower case So $resource = pg_query("SELECT ID, Foo FROM MyTable WHERE Foo='Bar'"); $data = pg_fetch_all($resource) gives me an array $data of rows like $data[0]['id'] = '1' $data[0]['foo'] = 'Bar' To make sure $data[] has fields named ID and Foo I would have to do $resource = pg_query("SELECT ID AS \"ID\", Foo AS \"Foo\" FROM MyTable WHERE Foo='Bar'"); -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Broken IF behavior? (Changing the branch changes the evaluation)
Matt Neimeyer wrote: > It's exactly what I would expect... The content of the row... But in > any case, what does changing the content of the { } branch have to do > with how the IF() itself is evaluated? > > array(4) { > [0]=> > string(8) "CustName" > ["config"]=> > string(8) "CustName" > [1]=> > string(11) "Sample Cust" > ["value"]=> > string(11) "Sample Cust" > } > > The if() *is* being evaluated *the same* whatever the content of that branch, but when there's no content, you see no result... It always looks odd to me to have empty if branches - why do you not just write if ($Ret) { return $Ret; } Anyway, the !$Ret branch is being executed because the fetch operation will return NULL (or FALSE or something equivalent) when there are no results. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
Christoph Boget wrote: >>> /usr/share/file/magic >> /usr/share/file/magic has lots of rules to know its type and its just >> matching it. > > I know it has a lot of rules. Grepping it for excel shows that there > are rules in it for those types of files as well. > >> Maybe your file is quite strange . have you tried with other xls files? > > Yes, I have; the result is the same for all. > >> what does "file /path/to/my/excel.xls" say > > $ file excel.xls > excel.xls: Microsoft Office Document > > Interestingly... > > $ file word.doc > word.doc: Microsoft Office Document > > So apparently, to the file command, there is no distinction. That > seems both odd and wrong to me. But not nearly as wrong as fileinfo > reporting "application/msword" as the mime type of an excel document. > > thnx, > Christoph Have you tried using 'file -i' from the command line: after all you are looking for a MIME type with your fileinfo... Having said that, with file -i on my system, Word documents are 'application/msword' and Excel files are 'application/octet-stream' -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Clean break.
Paul Halliday wrote: > Whats the cleanest (I have a really ugly) way to break this: > > [21/Jul/2009:00:00:47 -0300] > > into: > > date=21/jul/2009 > time=00:00:47 > > Caveats: > > 1) if the day is < 10 the beginning of the string will look like > "[1/... > 2) the "-0300" will differ depending on DST or TZ. I don't need it > though, it just happens to be there. > > This is what I have (it works unless day < 10): > > $theParts = split("[\"]", $theCLF); > > // IP and date/time > $tmpParts = explode(" ", $theParts[0]); > $theIP = $tmpParts[0]; > $x = explode(":", $tmpParts[3]); > $theDate = str_replace("[","", $x[0]); > $theTime = "$x[1]:$x[2]:$x[3]"; > > the full text for this part looks like: > > 10.0.0.1 - - [21/Jul/2009:00:00:47 -0300] ... more stuff here > > Anyway, any help would be appreciated. > > thanks. As far as I can tell from a brief test, date_create will happily parse your format, so something like $tmp = date_create($theParts[0]); $theDate = $tmp->format("d/m/Y"); $theTime = $tmp->format("h:i:s"); should do it -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: file upload question
seb wrote: > Hey all, > > i am using move_upload function to upload files to the server, but i > want to add a feature that will allow files to be archived that have > been uploaded already. > > so, the problem is: > > i upload a file that i want to "upgrade" and move the old file to an > archive directory but I want to verify the NEW file is upload BEFORE > moving the old file (the file being uploaded might not have the same > filename as the old file currently on the server).. > > i want to move the old file only when the new file was successfully > uploaded. something like: > > if(move_uploaded_file()) > { >rename(...); > } > > only one problem.. then if both files have the same name it will be > overwritten before it moves the old one i want to save. if i move the > old one first, there still the possibility of the new upload failing so > i am back to square one.. > > i guess i can move_upload to a different directory, verify it's been > uploaded, move the old to the archive file, then move the new file back > to where it should be (where the archive file was).. > > is that my only option? any suggestions? I'd suggest you *copy* the old file (if it exists) to archive anyway, and then *move* it back if the new version doesn't verify. That seems pretty safe to me... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSIONS lost sometimes
Leon du Plessis wrote: > ">> It's not an issue, it's a feature." > > Thanks Arno...but it is a pain also. > If I work with user A in Tab1 (window1), I want to work with user B > separately in Tab2. When user in Tab2 logs off, I still want user A to work, > and not suddenly have to re-login. Same with bank. If I work with my company > account, then my personal account must not become an issue because I am on > the same machine and site. > > I have no issue with using FF and IE to do testing as that takes care of > browser compatibility testing at the same time :-), but I think when you > start a new session with new values, it should be kept under that window/tab > alone. Cookies can take care of more details, but my opinion is data should > never be affected across windows/tabs unless the same user is logged in on > botheven then I would expect PHP to keep data per session. Maybe it goes > beyond being an IE or FF issue..the questiojn is...will PHP allow variables > from session A become corrupted when session B is in progress when they > should actually be handled seperately? > > In the end I think it is something I do wrong in PHP with the SESSION > variables and how I clear themif so...I don't think PHP should allow > clearing SESSION variables from other sessions. > > -Original Message- > From: Arno Kuhl [mailto:ak...@telkomsa.net] > Sent: 20 August 2009 10:03 AM > To: 'Leon du Plessis'; php-general@lists.php.net > Subject: RE: [PHP] SESSIONS lost sometimes > > -Original Message- > From: Leon du Plessis [mailto:l...@dsgnit.com] > Sent: 20 August 2009 09:44 AM > To: php-general@lists.php.net > Subject: RE: [PHP] SESSIONS lost sometimes > > Since we are on the subject: I have the following similar problem: > > When testing page on internet explorer, I find that one tab's variables can > affect another tab's variables. Thus when having the same web-site open and > using SESSION variables but for different users, Internet explorer can > become "disorientated". This also "sometimes" happen when I have two > separate browsing windows open with Internet Explorer for the same site. > > I have yet to determine if this is an internet explorer, or PHP or > combination of the two that is causing this condition. > > To my understanding _SESSION variables should be maintained per session, tab > or window. If this has been addressed already, my apologies, but thought it > worthwhile to mention. > > If someone perhaps have a solution or can confirm this as a known issue and > maybe is the same or related to Angelo's problem? > > > > If different browser windows/tabs on the same client-side computer didn't > share session info then you'd get the effect of being able to log onto a > site with one browser window, but find in a second browser window that you > were not yet logged on. Experience will tell you that you're logged on in > both browser windows (try it with your online bank). It's not an issue, it's > a feature. If you want to be able to use different browser windows as though > they were different users then use different browsers e.g. IE and FF on the > same client-side computer will look like two separate end users to the > server, and they don't share session info or cookies. > > Cheers > Arno > > The key thing is that both tabs (or windows) from the same browser are in the *same* session - they send the *same* PHPID cookie. PHP is essentially stateless - it doesn't care where the request comes from, and ties a session to the PHPID cookie if it gets one. As far as PHP knows, requests from different tabs with the same PHPID cookie are requests from the same place in the same session. To get a different session you need a different instance of the browser - that's the way browsers have been coded to work. It's not too hard with Firefox, since you can set up multiple profiles to have independent Firefox windows on the same screen. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: unset() something that doesn't exist
Stuart wrote: (among other things) > If you ask me you are essentially describing engineers (or doers) as > idiots and salespeople as morons. I won't debate the labels but > unfortunately it's a fact of life that most "management" types in this > world are ex-sales because they're the ones who know how to use their > skills to further their career which them in a position to favour > sales over engineering when it comes to salary and rewards. > I think you'll find it's because the engineers like engineering and not managing, so they (if they can get away with it) avoid or decline the "opportunities" for promotion to management. ISTR the Royal Air Force has a "Specialist Aircrew" track where the really good pilots, who wanted to fly planes rather than desks, could be promoted to "management" ranks but avoid the management duties. I had the pleasure of meeting one of these chaps when I was at university - he had more flying hours than I had lived and flown just about everything with wings. A superb instructor, but far too much of a livewire to be a manager... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IRC and English
tedd wrote: > At 2:02 PM -0700 9/1/09, Jessi Berkelhammer wrote: >> As a monolingual North American, I am also very uncomfortable with >> this thread. >> >> A rant about abbreviations/IRC jargon is an appropriate discussion for >> list, but criticizing how non-native English speakers write English is >> not. This thread began with a mention of the "attitude" that >> non-native English speakers have, as if non-native English speakers >> are a unified group that are are more likely to have a bad attitude >> than native English speakers. Of course such a generalization could >> make people uncomfortable. >> >> -jessi >> >> tedd wrote: >>> At 11:16 AM -0300 9/1/09, Martin Scotta wrote: >>>> As a non-english speaker I feel very uncomfortable with this thread. >>> >> > You shouldn't feel uncomfortable because no one is talking about you. >> > > > As a fellow monolingual North American, I feel very uncomfortable about > your statement as well. Does any other monolingual North American feel > the same way as I do? Please expound on your feelings about this most > disheartening and distasteful topic. (Boy has this thread degenerated > into some politically correct bullsh#t, huh?) > > Look if you are not the one using "u" as a substitute for "you", then I > don't see any support for the discomfort you may feel about this thread. > But you are free to feel as it is your nature (shudder). > > If non-English users (or anyone else for that matter) want to use "u" > for "you" that's fine -- but I'll refrain from helping them as well. I > am sure that if I were writing in their language and shortened it to > uncomprehending gibberish, I would receive the same treatment from them. > Why is this so hard to understand -- am I using words that are two lengthy? > > Cheers, > > tedd > Words that are two lengthy: "of", "an", "to", "it" (etc.) Words that are too lengthy: "antidisestablishmentarianism", "internationalisation" and that other one that begins with "flocci..." something Sorry tedd :) +1 on hating l33tsp34k and txtspk though (not tho). The American standardisation of English spelling did quite enough damage to the beautiful language of Shakespeare (who couldn't even spell his own name consistently), without any more neologisms creeping in. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CodeWorks 09
Jim Lucas wrote: > Elizabeth Naramore wrote: >> Hey all, >> Just wanted to make sure you knew about php|architect's upcoming >> CodeWorks >> conference, coming to 7 cities in 14 days: >> >> - San Francisco, CA: Sept 22-23 >> - Los Angeles, CA: Sept 24-25 >> - Dallas, TX: Sept 26-27 >> - Atlanta, GA: Sept 28-29 >> - Miami, FL: Sept 30 - Oct 1 >> - Washington, DC: Oct 2-3 >> - New York, NY: Oct 4-5 >> >> Each two-day event includes a day of *in-depth PHP tutorials* and a >> day of *PHP >> conference talks* arranged across three different tracks, all >> presented by >> the *best experts* in the business. >> >> Each event is limited to 300 attendees and prices increase the closer >> we get >> to each event. Get your tickets today before we run out or the price goes >> up! >> >> For more information and to register, you can go to http://cw.mtacon.com. >> Hope to see you there! >> >> -Elizabeth >> > > Is their anything like this in the Pacific NORTH WEST?? > > Seattle or Portland Oregon area would be great! > Or even in the rest of the world - PHP is bigger than just the USA :) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return XML attribute in DOM
Matthew Croud wrote: >>> Doesn't the DOM have the getAttribute() method? >> >> Thanks, >> Ash >> http://www.ashleysheridan.co.uk > > It's not in my reference, though I see it in the PHP manual now. > This is what I have: > > _ > > $dom = new DomDocument(); > $dom -> load("items.xml"); > > $topics = $dom -> getElementsByTagName("item"); > > echo(""); > foreach ($topics as $node ) > { > echo("". $node -> hasAttributes() .""); > } > echo(""); > > __ > > I'm replacing hasAttributes() with getAttribute() but its throwing me an > error, I'm probably using it incorrectly. > I think I'm drowning in the deep end =/ > Could you advise Gamesmaster ? It's a method on DomElement: http://uk3.php.net/manual/en/function.domelement-get-attribute.php and you need to tell it which attribute to get... :) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php/mysql Query Question.
ad...@buskirkgraphics.com wrote: > Before most of you go on a rampage of how to please read below... > > As most of you already know when using MySQL from the shell you can write > your queries in html format in an out file. > > Example: shell>mysql -uyourmom -plovesme --html > This now will return all results in an html format from all queries. > > Now I could “tee” this to a file and save the results returned if I so choose > to save the result of the display . > > Let’s say I want to be lazy and write a php MySQL query to do the same so > that any result I queried for would return the html results in a table > without actually writing the table tags in the results. > > Is there a mysql_connect or select_db or mysql_query tag option to do that > since mysql can display it from the shell? I think you'll find that the HTML output is a function of the mysql command line program (I tend to use PostgreSQL, where 'psql' is a similar program) so you can only access that functionality by calling the command line. I suspect that, since PHP is a HTML processing language (originally), the creators of the mysql_ functions figured that the user could sort out making HTML from the data returned... It's should be a simple operation to write a wrapper function to put HTML around the results. There might even be a PEAR extension or PHPClasses class to do it (I haven't looked yet) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: avoid Denial of Service
Gerardo Benitez wrote: > Hi everybody! > > > I want to get some tips about how avoid a attack of Denial of service. May > be somebody can about your experience with Php o some configuration of > apache, o other software that help in these case. > > > Thanks in advance. > > Unplug the network cable :) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Fun with XSLT
Matthew Croud wrote: > Hi Guys, > > Well i;ve been slaving on with my PHP XML endeavors and i'm loving it, > just finishing the meaty parts of my XSLT for dummies book too. > > I have a question which asks "is it possible?". > > Using XSLT I can collect specific parts of my XML using something sexy > like . Lets say however, that I need to > use XSLT, but I would want the user to select which element they > request. In other words, they are given a form with options and that > form can manipulate the .XSL file. > > Now I know it could be done in a lengthly manner by just opening the XSL > file and manipulating it like fopen or something like that, but is there > a way to somehow embed the contents of the xml into the php code (like > using <<< EOF for html), and being able to substitute the template match > string for a variable ? > > Any ideas ? > > Thanks Gamesmaster, > Matt > A bit off-topic (since XSLT is not PHP...) but here goes. First I need to clarify what you are doing - ... defines the template portion, and that is pretty immutable. At some point you must have in your XSLT something like This is the bit you can play with: so: http://www.w3.org/1999/XSL/Transform";> Essentially you need to apply the template of any element, but only those whose name matches your request. Note that doesn't work... :( So now if your PHP does something like $xslDom = new DOMDocument(); $xslDom->load('matchMe.xsl'); $xslt = new XSLTProcessor(); $xslt->importStylesheet($xslDom); $xslt->setParameter('','matchMe','umbongo'); $xmlDom = new DOMDocument(); $xmlDom->load('some_document_that_has_an_umbongo_tag.xml'); echo $xslt->transformToXML($xmlDom); you should get the results of the 'umbongo' template (only) 'f course, this is not tested, but I have used this idea in working code -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Fun with XSLT
Matthew Croud wrote: > Hi Guys, > > Well i;ve been slaving on with my PHP XML endeavors and i'm loving it, > just finishing the meaty parts of my XSLT for dummies book too. > > I have a question which asks "is it possible?". > > Using XSLT I can collect specific parts of my XML using something sexy > like . Lets say however, that I need to > use XSLT, but I would want the user to select which element they > request. In other words, they are given a form with options and that > form can manipulate the .XSL file. > > Now I know it could be done in a lengthly manner by just opening the XSL > file and manipulating it like fopen or something like that, but is there > a way to somehow embed the contents of the xml into the php code (like > using <<< EOF for html), and being able to substitute the template match > string for a variable ? > > Any ideas ? > > Thanks Gamesmaster, > Matt > Despite my other post, of course you can generate the XSL on the fly: http://www.w3.org/1999/XSL/Transform";> EoXSL $xslt = new DOMDocument(); $xslt->loadXML($xslScript); // ... etc... ?> -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spam opinions please
Ashley Sheridan wrote: > > > Won't stop a bot worth it's salt either, hence the need for more complex > and confusing captchas. The best way to stop spam, is to use linguistic > testing on the content being offered, which protects against bot and > human spammer alike. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > Unfortunately, it might also confound someone who doesn't speak the language. Admittedly, they would probably already be struggling with the rest of the site... I guess locale-dependent captchas are a possibility. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multilingual website, texts in external JavaScript problem
leledumbo wrote: > I need to create a multilingual website and my framework already gives me > that facility. However, I also use JavaScript quite extensively and since > XHTML 1.0 Strict doesn't allow inline script, I must use external .js file. > The problem is in these scripts, there are strings that needs to be > translated as well. How can I make PHP parse these scripts as well? Or are > there alternative approaches? > I don't see why you can't use inline script in XHTML 1.0 Strict: just put the script in CDATA sections, like /*<![CDATA[*/ // Inline javascript here /*]]>*/ That seems to validate fine in XHTML 1.0 Strict for me... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multilingual website, texts in external JavaScriptproblem
leledumbo wrote: >> I don't see why you can't use inline script in XHTML 1.0 Strict > > Because I don't know about CDATA, thanks. Glad to be of service! As another regular contributor to this list often points out, there's always something new to learn :) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: fread() memory problems
Ashley Sheridan wrote: Ashley Sheridan wrote: > I was just wondering why fread() seems to use so much memory when > reading in a file. My php.ini has a script memory limit of 32MB, yet PHP > hits its memory limit on a 19MB mbox file that I'm reading in. How is it > possible that this function can use 150% of a files' size in memory?! > > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > Is it possible that the file is 8-bit characters and your PHP implementation is converting it to 16-bit characters? I'm not sure what settings would be involved for that, but no-one else has responded so I thought a vague idea might be better than nothing! -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Lightweight web server for Windows?
O. Lavell wrote: > > Also, it is not for daily use. I have two desktop computers and a server > for that. This is for when I have to go by train or something. > > Essentially it is just an extra plaything. > Does the battery still hold enough charge for a train journey - that always seems to be the first thing that goes on old laptops. They make really good low-power servers for stuff like DNS or even firewalling (as long as you can plug in enough network cards), but only when on mains power :( -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Does PHP block requests?
I have a tricky problem. I'm trying to make a progress feedback mechanism to keep users informed about a slowish process on the server end of a web app. The backend is generating a PDF file from a bunch of data which extends to many pages. I can keep tabs on the progress of this generation by working out how many lines of data is present, and how much of it has been processed. I use that information to set a session variable with a unique name - so for each step I set $_SESSION['some-unique-name']=>Array('total'=>$totalLines,'count'=>$linesProcessedSoFar); Now on the front end I'm doing an AJAX call to a script that just encodes this session variable into a JSON string and sends it back. The problem is that while the PDF is being generated, the AJAX calls to get the progress data (on a 1-second interval) are being blocked and I don't get why. The PDF generation is also triggered by an AJAX call to a script which generates the PDF in a given file location, then returns a URL to retrieve it with. So it appears that the problem is that I can't have two AJAX calls to different PHP scripts at the same time? WTF? Checking the requests with Wireshark confirms the the browser is certainly sending the progress calls while the original PDF call is waiting, so it's not the browser side that's the problem: and once the PDF call is finished the outstanding progress calls are all serviced (returning 100% completion of course - not much use!) Different browsers (Firefox, IE, Chrome at least) give the same result. For reference, the server is Apache 2.2.10 on a SuSE linux 11.1 box using mod_php5 and mpm_prefork - is that part of the problem, and is there an alternative? -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Does PHP block requests?
Ford, Mike wrote: >> -Original Message- >> From: Peter Ford [mailto:p...@justcroft.com] >> Sent: 20 November 2009 15:18 >> To: php-general@lists.php.net >> Subject: [PHP] Does PHP block requests? >> >> I have a tricky problem. >> >> I'm trying to make a progress feedback mechanism to keep users >> informed about a >> slowish process on the server end of a web app. The backend is >> generating a PDF >> file from a bunch of data which extends to many pages. I can keep >> tabs on the >> progress of this generation by working out how many lines of data is >> present, >> and how much of it has been processed. I use that information to set >> a session >> variable with a unique name - so for each step I set >> >> $_SESSION['some-unique- >> name']=>Array('total'=>$totalLines,'count'=>$linesProcessedSoFar); > > The progress-counter Ajax script uses a session -- but does the PDF generator > use the same session? If so, I'm guessing you don't manually close the > session at any point and all the progress-checking calls are blocked until > the session auto-commits at the end of the generator script. To counter this, > you need to manually session_commit() somewhere near the beginning of the > generator script. > > Cheers! > > Mike > -- > You're right about trying to use the same session - that was the plan to get the progress state passed across from one call to the other. Closing the session on the generator script has the effect of stopping any further changes to the session variable, so I get the initial value at each request after that. I put together a simple "Generator" script to test this: 10,'count'=>0); for ($i=0; $i<10; $i++) { sleep(1); $_SESSION[$fcode]['count']++; } echo "Done"; ?> and the code for the progress backend is like this: http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Class not returning value
Pieter du Toit wrote: > Hi > > This is my first class and it does not work, i do a return > $this->responseArray; with the public function getResult() method, but get > nothing. Can someone please help me. > > Thsi is how i create the object > $number = new Smsgate($cell_numbers, $message, "27823361602", "27"); > $result = $number->getResult(); > > Here is the code: > > /** > * > * @version 1.0 > * @copyright 2009 > */ > > /** > */ > class Smsgate { > > protected $number; > protected $message; > protected $sender_id; > protected $tofind; > private $result; > /** > * Constructor > */ > function __construct($number = "", $message = "", $sender_id = "", > $tofind = "") > { > > $this->message = $message; > $this->number = $number; > $this->sender_id = $sender_id; > $this->tofind = $tofind; > } > > protected function display ($result) > { > return $result; > } > > public function getResult() > { > return $this->processRequest(); > > } > public function numberErrors() > { > return $this->errorResult; > } > > /** > * Smsgate::checknumbers() > * > * @return array of correct and incorrect formatted numbers > */ > private function processRequest() > { > echo "nou by numers"; > print_r($this->number); > // check if the property is an array and add to new array for > sending > if (is_array($this->number)) { > // check for starting digits > $this->result = ""; > // loop through numbers and check for errors > foreach ($this->number as $this->val) { > > $this->position = strpos($this->val , $this->tofind); > > // number correct > if ($this->position === 0) { > echo "is integer "; > if ($this->result != "") { > $this->result .= ","; > } > // create comma seperated numbers to send as bulk in > sendSMS method > $this->result .= $this->val; //infobip multiple > recipients must be seperated by comma > // create an array to use with responseStringExplode in > sendSMS method > $this->cellarray[] = $this->val; > echo "Result is " . $this->result . ""; > } else { > // numbers not in correct format > $this->errorResult[] = $this->val; > } > > } //end foreach >$this->sendSMS(); > > } else { > $this->result = "Not ok"; > return $this->result; > } > > } > > private function sendSMS() > { > > $this->smsUrl = > 'http://www.infobip.com/Addon/SMSService/SendSMS.aspx?user=&password='; > $this->post_data = '&sender=' . $this->sender_id . '&SMSText=' . > urlencode($this->message) . '&IsFlash=0&GSM=' . $this->result; > $this->sendData = $this->sendWithCurl($this->smsUrl, > $this->post_data); > $this->responseStringExplode = explode("\n", $this->sendData); > > $count=0; > foreach ($this->responseStringExplode as $this->rvalue) { > $this->responseArray[$this->rvalue] = ($this->cellarray[$count]); > $count = ++$count; > } > return $this->responseArray; > } > private function sendWithCurl($url, $postData) { > if (!is_resource($this->connection_handle)) { >// Try to create one >if (!$this->connection_handle = curl_init()) { > trigger_error('Could not start new CURL instance'); > $this->error = true; > return; >} > } > curl_setopt($this->connection_handle, CURLOPT_URL, $url); > curl_setopt ($this->connection_handle, CURLOPT_POST, 1); > $post_fields = $postData; > curl_setopt ($this->connection_handle, CURLOPT_POSTFIELDS, $post_fields); > curl_setopt($this->connection_handle, CURLOPT_RETURNTRANSFER, 1); > $this->response_string = curl_exec($this->connection_handle); > curl_close($this->connection_handle); > return $this->response_string; > } > } > > ?> > > Based on a first scan of your code, it looks like the only return in processRequest() is inside the else block, so nothing is returned unless the processing fails. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: logic operands problem
Merlin Morgenstern wrote: > Hello everybody, > > I am having trouble finding a logic for following problem: > > Should be true if: > page = 1 OR page = 3, but it should also be true if page = 2 OR page = 3 > > The result should never contain 1 AND 2 in the same time. > > This obviously does not work: > (page = 1 OR page = 3) OR (page = 2 OR page = 3) > > This also does not work: > (page = 1 OR page = 3 AND page != 2) OR (page = 2 OR page = 3 AND page > != 1) > > Has somebody an idea how to solve this? > > Thank you in advance for any help! > > Merlin Surely what you need is xor (exclusive-or) I can't believe a programmer has never heard of that! (page==1 XOR page==2) AND page==3 -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP + PostgreSQL: pg_query not returning the expected result for this (edge) case:
Here's a tricky one: Versions: I'm using PostgreSQL 9.0.7 and PHP 5.3.8. First, I have a table "bob" with two columns: "bobid" (integer) and "bobtext" (text). The "bobid" field defaults to a sequence called "bob_seq" which is just a simple counter (1,2,3 etc.) I can do an INSERT query into "bob": INSERT INTO bob (bobtext) VALUES ('Hello Bob') RETURNING bobid; and get the value the sequence has given me for "bobid": this works fine using both the psql tool and pg_query in PHP. I can also do an UPDATE query in the same vein: UPDATE bob SET bobtext='Hello Bob revisited' WHERE bobid= RETURNING bobid; where is a valid "bobid" value for an existing record in the table. This returns the value of "bobid" for the updated record which should be the same as and again it works in the psql tool and in pg_query. Next, I have a VIEW based on "bob", called "fred". It is simply defined as CREATE VIEW fred AS ( SELECT * FROM bob ); I have two rules on "fred" which allow me to alter the view. The first is used for INSERT into "fred", which translates them into INSERT into "bob": CREATE OR REPLACE RULE fred_insert AS ON INSERT TO fred DO INSTEAD INSERT INTO bob (bobtext) VALUES (NEW.bobtext) RETURNING * ; The second is used for UPDATE on "fred", which translates to creating a new record in "bob" and deleting the old record: CREATE OR REPLACE RULE fred_update AS ON UPDATE TO fred DO INSTEAD ( INSERT INTO bob (bobtext) VALUES (NEW.bobtext) RETURNING *; DELETE FROM bob WHERE bobid=OLD.bobid; ) ; Note that these rules both return all of the fields of the newly inserted "bob" records back up the chain to be accessible to the original query. Now, I can insert into "fred" knowing that the rule will handle it: INSERT INTO fred (bobtext) VALUES ('Hello Fred') RETURNING bobid; and that should return the new "bobid" value of the inserted record (from the "bob_seq" sequence). It still works in the psql tool and in pg_query. I should also be able to exercise the update rule on "fred": UPDATE fred SET bobtext='Hello Fred revisited' WHERE bobid= RETURNING bobid where is a valid "bobid" value for an existing record in the table. This should insert a new row with a new "bobid" from the sequence and the new "bobtext" value, delete the row with "bobid"=, and return the "bobid" for the new row. Here's the punchline (at last): It works in the psql tool. It doesn't work in pg_query. $result = pg_query("UPDATE fred SET bobtext='Hello Fred revisited' WHERE bobid=42 RETURNING bobid"); // Assume there is a record with bobid==42 if ($result && pg_numrows($result)) { echo pg_numrows($result).PHP_EOL; echo pg_fetch_result($result, 0, 0).PHP_EOL; ) ?> Tells me there that although the $result resource is valid, there are no rows and therefore no result to fetch (PHP Warning: pg_fetch_result(): Unable to jump to row 0 on PostgreSQL result ...) So: why is the return from the UPDATE rule different to the return from the INSERT rule in PHP pgsql? Thanks for taking the time... Cheers Pete -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable type - conversion/checking
On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like "if (is_numeric($var)&& $var == floor($var))" will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 7:02 PM, georg wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg You could use is_numeric for that, though it also accepts floats. - Matijn for that type of test I have always used this: if ( $val == (int)$val ) { http://www.php.net/manual/en/**language.types.integer.php#** language.types.integer.casting<http://www.php.net/manual/en/language.types.integer.php#language.types.integer.casting> I hope you're not serious about this... When comparing a string and an int, PHP will translate the string to int too, and of course they will always be equal then. So: $a = "abc"; if($a == (int)$a) echo "YES"; else echo "NO"; Will always return YES. - Matijn H... Interesting. Looking back at my code base where I thought I was doing that, turns out the final results were not that, but this: $value = "asdf1234"; if ( $value === (string)intval($value) ) { Looking back at the OP's request and after a little further searching, it seems that there might be a better possible solution for what the OP is requesting. '.PHP_EOL; } returns... asdf1234 - is NOT all digits 123.123 - is NOT all digits 123 - is all digits http://www.php.net/manual/en/function.ctype-digit.php An important note: This function expects a string to be useful, so for example passing in an integer may not return the expected result. However, also note that HTML forms will result in numeric strings and not integers. See also the types section of the manual. -- Jim Integers can be negative too: I suspect your test would reject a leading '-'... -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Preferred Syntax
On 14/12/11 16:48, Al wrote: On 12/14/2011 7:59 AM, Rick Dwyer wrote: Hello all. Can someone tell me which of the following is preferred and why? echo "$page_name"; echo "".$page_name.""; When I come across the above code in line 1, I have been changing it to what you see in line 2 for no other reason than it delineates out better in BBEdit. Is this just a preference choice or is one method better than the other? --Rick This not a PHP subject and should not be here. However, styles should be in the style block or better in the styles CSS file. Spend some time learning about CSS3 and modern techniques. With respect to tedd and Al, you've misread the question: the important PHP-related bit is about whether to embed variables in double-quoted strings or to concatenate them. These are only two of the options, and each has it's pros and cons. There has been (some time ago) plenty of discussion on this list about this sort of thing, including (ISTR) a timed test of the performance implications of various forms - that only really matters in big loops, of course... Horses for courses. I use whatever I feel like at the time, and mix various styles, as long as it's readable! Cheers Pete -- Peter Ford, Developer phone: 01580 89 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is it possible to restart Windows Apache (service) on a PHP script?
You could try using exec to set up an "AT" job with a short delay which will then run 'net apache restart' - I'm not a total windows guru so I can't give you the exact recipe... Something like exec('AT 12:00 "net apache restart"'); Check the documentation on the AT command... One possible extra advantage is that you could cancel the 'AT' job during the delay period if you clicked restart by accident :) Louie Miranda wrote: > Thanks for your suggestions. > > But, both did not worked. > > Louie > > On 10/19/07, Philip Thompson <[EMAIL PROTECTED]> wrote: >> On 10/19/07, Robert Degen <[EMAIL PROTECTED]> wrote: >>> Why don't you try a >>> >>> passthru('net apache restart') >>> >>> perhabs another parameter order, but I think It won't work. >>> Stopping it might work, but restarting... >>> >>> >>> >>> On Fr, Okt 19, 2007 at 04:32:45 +0800, Louie Miranda wrote: Is it possible to restart Windows Apache (service) on a PHP script? i have installed PHP/Apache on a Windows machine. Added the ext >>> windows32 service. But could not find any how to or information online. Please help! -- Louie Miranda ([EMAIL PROTECTED]) >> This reminds me of the time I was remoting into a machine (using Altiris, >> I >> think) to do some work on it. I then needed to restart it... so I did. >> Well, >> class, what happens when you turn off Mr. Computer? >> >> Not saying that this is the same thing... b/c if you push a "restart" >> command, then it *should* come back up. =/ Sorry, I don't know the exact >> command, but consider using exec(). >> >> Good Luck, >> ~Philip >> >> PS... Yay, it's Friday! >> > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Benchmarking check to see if array key is set
Ford, Mike wrote: > On 06 November 2007 12:57, Christoph Boget wrote: > >> Consider the following test code: > > [...snip...] > >> Running that I found that >> >> if( isset( $myArray[$key] )) >> >> is faster than >> >> if( array key exists( $key, $myArray )) >> >> is faster than >> >> if( $myArray[$key] ) >> >> To be honest, I was surprised. I would have thought that if( >> $myArray[$key] ) would have been the fastest way to check. I'm >> wondering if those in the know could explain why it's the slowest and >> also where the discrepancies come from w/r/t the difference in the >> amount of time it takes >> to make each >> check. > > OK, I'll take a stab. > > Firstly, isset() is a language construct not an actual function, so the only > thing your isset() does is check whether the array element exists. > > Next, array_key_exists() is the only one that involves a real function call, > so it's going to bear that cost. However, the function then does a pretty > simple test which again only involves checking whether the key exists, so the > function itself is going to be pretty quick. > > Finally, the if() is the only one that actually gets the value in > $myArray[$key], and then casts it to Boolean to boot, and the cost of this > must therefore outweigh the cost of a function call plus a check for a key's > existence. > > I'm certainly not surprised that isset() is the quickest, because it does the > simplest test, but to be honest I'm not sure if I'd have predicted the > relative positions of the other two.. > > Cheers! > > Mike > For convenience let's label the cases: 1: if( isset( $myArray[$key] )) 2: if( array key exists( $key, $myArray )) 3: if( $myArray[$key] ) Now, surely 3 is not comparable at all to 1 and 2. Cases 1 and 2 check that the key exists in the array. Case 3 does a boolean test on the value referenced by the key. That has several consequences: Firstly, if there is no element with key "$key" in the arrray, the interpreter will throw an error (undefined index ...); this error could be suppressed and ignored, I suppose. Secondly, if the value referenced by the key is equivalent to FALSE, then the test will return FALSE; for example, if you have set $myArray[$key]='' or $myArray[$key]=0. This could be very confusing. So if you want to test that the key exists, case 3 is NOT the way to do it. In fact, you will often want to check that the key exists(with case 1, ideally) BEFORE using a test of the form of case 3. Cheers Pete Ford (no relation, I think, although I do have a cousin called Michael...) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP ide?
Hulf wrote: > Just wondering if anyone uses an IDE and if so what ones? > > Ta, > > H. Quanta+, with KDESVN for version management... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP ide?
I've tried to use Eclipse PDT, and it's just generally horrible - the All-in-one has no Subversion support and no SSH support for deploying to the server properly. The debugging support worked well on the windows version, but I couldn't get it to work from Linux (with the same web server...) And the look and feel is so crowded and over-complicated. Yuck. Quanta+ can do this (mostly) right, although I have had some trouble with debugging. [EMAIL PROTECTED] wrote: > Andrew Peterson wrote: >> I'll try installed it again with none of the other nonsense. > > PDT has the so called ALL-IN-ONE thing, however I don't really trust it. > > I would suggest the following - > > a) Be sure you have the latest Java. > > b) Get the normal, traditional Eclipse. > > c) Update it (Help > Software updates > Find and install > Search for > updates of the currently installed features). Repeat if needed. > > d) Go to Help > Software updates > Find and install > Search for new > features to install and add the PDT site > (http://download.eclipse.org/tools/pdt/updates/). Check the PDT site and > the Europa Discovery Site and click Finish (I haven't done it for a > while, so could be something has changed there). When you get the > result, the Update manager might complain that PDT depends on something. > In this case unfold the Europa Discovery Site result (by clicking the +, > if you do not unfold it the next step might not work) and click the > Select Required button. This should select the minimum you need. Let me > know if you run into a trouble and I'll try to send you reproducible steps. > > And again, Eclipse is Java, so you need a decent machine. > > Iv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP ide?
Lester Caine wrote: > Peter Ford wrote: >> I've tried to use Eclipse PDT, and it's just generally horrible - the >> All-in-one >> has no Subversion support and no SSH support for deploying to the server >> properly. The debugging support worked well on the windows version, but I >> couldn't get it to work from Linux (with the same web server...) >> And the look and feel is so crowded and over-complicated. >> Yuck. > Well PDT is the 'commercial' offering from Zend since they hijacked the > PHP slot :( > PHPEclipse is much tidier and has a longer pedigree. > Subversion and SSH are OTHER packages and part of Eclipse not the PHP > editor. And the look and feel is fully configurable, but it does take a > while to work out how. > >> Quanta+ can do this (mostly) right, although I have had some trouble with >> debugging. > But you can't handle the legacy C++ code with that ;) > OK, I'm looking at the PHPEclipse site, and I've been here before: the current Using PHPEclipse document lists the system requirements as PHP 5.1.2 or *below*, and Apache 2.0 or *below* Is that just badly out-of-date (last update is April 2007), or is PHPEclipse really not able to support PHP 5.2.4 and Apache 2.2.4 (my current system levels)? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [NEWBIE GUIDE] For the benefit of new members
> > I was all ready to jump on Point #6 to disagree until I read the > next paragraph, updating that with the correct information. PHP can > find out the OS of the system on which the browser is running. > Strictly speaking, PHP can only find out what the browser tells it - that includes the OS. I could quite easily hack the browser info string sent by (at least one of) my browsers to pretend I was using some horrible Windows rubbish... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] overloading members. aghhh!!!
Jochem Maas wrote: > Kiketom wrote: >> Hi all. >> Yesterday i have looking for the overloading members >> >> Member overloading >> void __set ( string name, mixed value ) >> mixed __get ( string name ) >> >> As an example i put this code: >> >> class foo >> { >> private $ID; >> private $Name; >> private $LastName; > > when you declare these three as 'real' members, __get() and __set() > will no longer be called - they are only called for non-existent members. > Nope, that's not true. If the members are private, or otherwise inaccessible, __get() and __set() are called - I've used this in a few places to provide a "read-only" member variable, e.g.: class foo { private $bar=0; public function __get($nm) { return $this->$nm; } public function __set($nm,$val) { if ($nm != 'bar') { $this->$nm = $val; } } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] shared memory access - shmod_open
Richard Lynch wrote: > On Thu, December 6, 2007 2:44 am, Rolf_ wrote: >> I have a problem working with shmop_open() in a Solaris environment. >> The >> following cli-script works fine, except shmod_open returns a warning >> 'unable >> to attach or create shared memory segment': >> >> > $sem = "/tmp/" . rand() . ".sem"; >> touch ($sem); >> echo "sem $sem \n"; >> >> $sem_key = ftok($sem, 'w'); >> echo "sem_key $sem_key \n"; >> >> if ($sem_key == -1) { die ("ftok error"); } >> >> $shm_id = shmop_open($sem_key, "w", 0644, 1); >> echo "shm_id $shm_id\n"; >> ?> >> >> I checked the $sem_key with the Solaris ipcs command. The file exists >> and >> the read/write rights are correct. I tried explictly to call >> shmop_open with >> the right key - the error message remains the same. >> >> Checking out different access mode like "r" does not succeed too. In >> the >> Xdebug output, php changes the value 0644 to 420, i.e. >> shmop_open(1258300033, 'w', 420, 1). Of course, I compiled php with >> --enable-shmop. >> >> Does anyone has an idea what I might also check? > > Perhaps the 0644 needs to be expressed in some other way? > > I know it works fine that way for chmod and friends, so I wouldn't > expect it, but... > > Or maybe 420 *IS* the right value, and you're on a red herring. > > Try Googling for the error message and Solaris if you haven't done > that yet. > The problem is that 0644 == 420, because 0644 is parsed as "644 base 8" (the zero prefix forces the number to octal...) So 420 (decimal) is actually the correct value. RTFM for chmod, which gives you a big hint about this... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Assign variable to a block of html code
You could just swap all the double quotes in the HTML tags for single quotes - that would work in this instance... $myblokvar = " ... "; Or perhaps a HereDoc syntax: $myblokvar = << ... EndOfMyHTMLBlock; Then you don't need to worry about what quotes you use, and if you start putting stuff like onclick events in you can mix quotes up happily ... I go to great lengths to avoid escaping quotes - it just looks ugly. That is, however, a personal foible. Cheers Pete Stephen Johnson wrote: > What you have will work, you just need to escape out the double quotes in > the html. > > > > > On 12/19/07 7:38 PM, "php mail" <[EMAIL PROTECTED]> wrote: > >> Hi All, >> >> Is it possible to assign variable to a block of html code ? >> >> Something like this : >> >> $myblokvar = " >> >> >> >> >> > height="30" /> >> >> >> >> > cellspacing="2"> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> "; >> >> Although example above is not working, what I want to achieve is something >> like that. Is it possible how can I do that ? >> >> Regards, >> >> Feris > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Can't find .php3 files
Jim wrote: > I'm sure this is a FAQ but I can't seem to come up with the right search > keys to dig it out. > I'm trying to help a friend migrate his application to php 5 from > another system. The problem seems to be that he references files > (require, include, etc) that have a .php3 extension, however there are > no files in those locations with the .php3. There are files with .php > extensions. It's running on a system that has php 4 on it. > > So I'm sure either php or Apache is rewriting the files somehow, but I > don't know how. > > Can someone please point me to the appropriate documentation or give me > a hint as to what is going on here? > > Thanks, > Jim. Take a look in the Apache reference docs for mod_rewrite (exactly where you look depends on which version of Apache you are using). Then search for (a) any .htaccess files in the web-app, and (b) any Apache config files: this will be Linux-distro-dependent but somewhere like /etc/apache or /etc/httpd might be the first thing to try... You are looking for either directory-specific or system-wide Apache RewriteRule directives, especially those that contain a pattern which matches ".php3" If you can't find anything like that, then Apache ain't rewriting... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Exception thrown without a stack frame
Jochem Maas wrote: > Jochem Maas schreef: >> I'm getting exceptions thrown without a stackframe. I understand what >> this >> means but not how it can happen given the following: >> >> 1. *every* frontend script on the site is wrapped in a try/catch block >> 2. I have set an exception handler to dump these so-called uncaught >> exceptions >> in the error log >> >> I use APC on the site/server in question but it doesn't matter whether >> I actually >> load or use APC as to whether these uncaught exceptions occur. >> >> I can't seem to reproduce the problem from my own browser - although it's >> difficult to determine much from the log given the lack of information >> in any >> entry referring to 'exception thrown without a stack frame' - >> apparently the >> uncaught exception is not causing users to see broken or blank pages. >> >> The problem only occurs on the production server, I can't reproduce it >> on my test server no matter how hard I push with ab. >> >> I haven't updated php for quite a long time which is at version 5.1.1 >> >> has anyone ever experienced something like this? anyone have any clue >> as to >> what it might be. > > I'd like to add that the exception handler is set after 6 files are > included, > 2 of them just define constants and 4 of them define classes related to > exception/error/msg handling - none of the 6 files contain a 'throw' > statement > anywhere *and* none of them include any other files. > > I am completely stumped. > >> >> tia >> I just spotted this in the manual page for "date_create": When using these functions inside of destructors or functions called as a result of being registered with register_shutdown_handler, be sure to use date_create() instead of new DateTime(). This is because new DateTime will throw an exception on failure, which is not permitted in any of the above circumstances. If new DateTime() does fail in one of these circumstances, you will get an error stating "Fatal error: Exception thrown without a stack frame in Unknown on line 0." Maybe there's a clue for you in there? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Anyone else doing PHP on Symbian?
Paul Scott wrote: > On Tue, 2008-02-05 at 13:29 -0500, Daniel Brown wrote: >> Still debating what >> device I'll get next, but I want to use it as a mobile server myself. >> I had been working on a bound-for-trash PDA doing the same a while >> back, but with what we'll refer to as "limited results." > > I think that the key here is > > 1. A decent ARM processor and a PHP build for ARM specifically (new > project??) > > 2. Enough RAM to be useful - at least figure out how to use a SD card or > something as a RAMDisk and use like a 2GB card? > > 3. Getting an entire LAMP stack on there as a package - no use messing > with things - otherwise people won't use it. > > Just think of the possibilities though... I do a lot in the eLearning > sphere in PHP, and this type of thing could be a mobile eLearning server > for rural schools in Africa that is actually affordable! Students could > connect to it via thin clients or mobile phones and get an education all > in one. > To be honest Paul, I think you'd find that an EeePC would be cheaper than a sufficiently well-specced PDA, especially given the time and effort required for the key points you describe. An EeePC already runs Linux, with a decent processor, reasonable "disk" space and good connectivity options, so a LAMP stack ought to be easy. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XSLTProcessor without validation
Siegfried Gipp wrote: > Hi, > > i still got no answer. Maybe i did not see it, altough i'm trying to read any > single post. But may be i overlooked it due to high traffic. So now i have > set up a filter (hopefully) copying answers to another folder. > > Here is the question: Is it possible to disable validation when using > XSLTProcessor? If yes, how? > > When i use xsltproc, the command line tool for the libxslt, i can use the > switch --novalid to subpress validation. This makes a huge difference in > speed. Without validation it is fast enough. With validation it takes far too > long to be acceptable. So how do i use XSLTProcessor from within PHP to > achieve the same result as if using xsltproc --novalid? > > Regards > Siegfried What if you don't have a DTD in the XML to validate it with? I haven't tested it but it was something that worked in the Java XML processing stuff. No DTD, no validation: simple! So have you tried stripping the DOCTYPE declaration before XSLTing the XML? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Create collections of objects
Emilio Astarita wrote: > Hi people, > > I want a class that allows create objects that get the information > consulting the DB. So, I am thinking to do something like this: > > class element { > public __construct($id,$type = 'id') { > switch($type) { > case 'id': > $where = sprintf(" id = %d ",$id); > break; > case 'name': > $where = sprintf(" name = %s ",escape($id)); > break; > //... > // get the row and call setName($row['name'])... > } > } > } > > This works fine, but also I want a good way (efficient) of getting a > collection of these objects. I can't figure a convenient way. A static > function its a good posibility? I have some ideas but they imply public > setters of the class `element'. > > Thanks for any help. > A static method should still be able to set values of private members. I do something like: class Element { private $id; private $name; public __construct() { // Do general construction tasks... } public static bulkLoad($id,$type='id') { $ret = Array(); $sql = 'SELECT id,name FROM Table '; switch ($type) { case 'id': $sql .= 'WHERE id ILIKE $1'; // Use ILIKE to allow for wildcards break; case 'name': $sql .= 'WHERE ILIKE $1'; // Use ILIKE to allow for wildcards break; //... } $params = Array($id); // I use postgreSQL parameterised queries a lot - saves lots of quoting etc. // Note: NO ERROR CHECKING in this example... $data = pg_fetch_all(pg_query_params($sql,$params)); foreach ($data as $row) { $elem = new Element(); // No-args constructor $elem->id = $row['id']; $elem->name = $row['name']; $ret[$id] = $elem; } return $ret; } } Then you get an array of elements which match the (possibly wild-carded) condition, indexed by the element Id (useful for making HTML lists, for example). In fact, I have a base class which implements this by class introspection - filling the properties of objects which extend it by mapping them to the database fields... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Create collections of objects
Emilio Astarita wrote: > Peter Ford <[EMAIL PROTECTED]> writes: > >> Emilio Astarita wrote: >>> Hi people, >>> >> A static method should still be able to set values of private members. I do >> something like: >> ... >> > > Thank you, I was not sure how to implement it. > > Another question. It would be a better approach, making the constructor > private? Maybe: I use the constructor in other places, so in my case, no. > >> Then you get an array of elements which match the (possibly wild-carded) >> condition, indexed by the element Id (useful for making HTML lists, >> for >> example). >> >> In fact, I have a base class which implements this by class introspection - >> filling the properties of objects which extend it by mapping them to the >> database fields... >> > > Good idea. Do you use a script to do mapping or you ask by the fields > to the database with the name of the table? > > Thanks again > I have the classes which extend my BaseData class provide the SQL statement they will use (or at least the bit between 'SELECT' and 'WHERE'), and also an array of database field -> class property mappings. This is really overkill, since you can use something like "SELECT foo AS id, bar AS name ..." to do the mapping to field names directly from the SQL. Letting the Element class define the SQL to get itself also lets you do some processing of the database, such as using JOINS across tables, COALESCE to provide default values where NULL is stored, and all sorts of useful database tricks. That makes the database share the work and cuts out some of the PHP processing... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending XML to MSIE7
Stut wrote: > Brian Dunning wrote: >> I just tried that, and unfortunately the MSIE7 toolkit behavior was >> the same. Darn, I had high hopes for your suggestion as soon as I read >> it. I fear this means there's little we can do server-side in PHP, >> except to choose something other than XML for the result. > > You should be able to put in your own XSLT that ensures the XML file is > presented unchanged. Dunno if IE7 will obey it but certainly worth a try. > > -Stut > I came up against this a while ago, and my work-around was the XSLT solution you suggest, Stut. I have a stylesheet called 'copy.xsl', like this: http://www.w3.org/1999/XSL/Transform";> and then insert into the XML I am returning - you'd have to make sure that the href actually points to your file with an absolute URL, to be certain... That seems to work - IE7 sees the xml-stylesheet PI and doesn't then try to mangle the XML in it's own special way. Only problem is the extra hit on the server to get the XSLT... :( -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: temporary error
Greg Donald wrote: > On 2/22/08, tedd <[EMAIL PROTECTED]> wrote: >> Shouldn't the reason why we ask "if" be sufficient proof that "it is"? > > I don't believe having an interrogative nature proves existence in God, no. > >> I imagine there are a great number of things that don't exist >> that we never mention -- so why this one? > > Well because this one bilks money from people who usually can't afford > to be giving it in the first place. It has over-reaching influence > into my government, one that's supposed to be completely separate from > it. > Sounds like Microsoft ... >> All rhetorical comments -- no need to reply. We all have different >> beliefs -- whatever gets you through. > > That's my viewpoint to some extent, as long as it's not harming me then fine. > > But the truth is it is harming all of us. Do we really want our > children taught about a magical sky-god who insists on genital > mutilation at birth? Do we want influences into our governments that > inhibit natural advances in modern science? Do you really believe in > virgin birth and resurrection? > > Really sounds like Microsoft! Bill Gates IS the Messiah. -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Transferring files between computers using php
Aschwin Wesselius wrote: > Rahul wrote: >> I have a small file to be transferred between two computers every few >> seconds. I'm using unix with a bare bones version of php, i.e. just >> the original thing that gets installed when I run "yum install php". >> As there is no webserver on any of these machines, I was wondering if >> there is a way to transfer a small file between them and if there is, >> could someone be kind enough to provide me with an example please? >> >> Thank You > > You can use netcat (nc), but that doesn't run in daemon mode. You can > use them both ways (client / server, sending / receiving). You can use > them on the commandline with a cronjob or whatever. > > Netcat makes it possible to do this, to send content over to port 2200 > of 192.168.1.1: > > cat textfile.txt | nc 192.168.1.1 2200 > > On 192.168.1.1 all you do is something like this: > > nc -l -p 2200 > textfile.txt > > I don't know all the options in depth and may not work like scp does > (which is way more secure). > > So I would go with scp in a cronjob, but netcat is still an option. > > Here's overkill: use "fuse" to make two sshfs filesystems :) # Make some directories to mount the remote stuff onto mkdir -p mount_point_for_B mkdir -p mount_point_for_C # Use 'fuse' to make SSHFS mounts from the remotes to the new directories sshfs B:/path_to_where_the_file_ismount_point_for_B sshfs C:/path_to_where_the_file_goes mount_point_for_C # Copy the file across: repeat this step every few seconds (cron job?) cp mount_point_for_B/the_file_to_copy mount_point_for_C # Unmount the SSHFS mounts when you're finished fusermount -u mount_point_for_B fusermount -u mount_point_for_C Still not PHP though... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: fwrite/fclose troubles
Mark Weaver wrote: Hi all, I've been lurking and reading now for some time, but have decided to come out of the shadows cause I've got an issue that's gonna drive me crazy! I'm developing an application and within this application is a class that is very simple and only serves a singular purpose - to make log entries to help with debugging. Problem is, now I'm debugging the damned logging class that is supposed to be helping me debug the application as I'm putting it together! I've looked and looked all over the place, but I don't seem to be able to find an answer to this problem. The only information that I have found so far deals with permissions and I don't think that's the problem. At first I was getting an access denied error but since setting dir perms and log file perms so that both apache and my user can right to both the directory and the file that one has gone away. Log Directory permissions: /mystuff/logs rwx-rwx-rwx (777) Log file permissions: /mystuff/logs/run.log rwx-rwx-rwx (777) At any rate, the following is the information I'm getting in the apache error_log while working on this particular portion of the application: PHP Warning: fwrite(): supplied argument is not a valid stream resource in /mystuff/inc/Log.inc on line 22, PHP Warning: fclose(): supplied argument is not a valid stream resource in /mystuff/inc/Log.inc on line 23, The Log class: - class Log{ public $path, $entry, $logfile; public function Log(){} public function setLog($path,$file){ $this->path = $path; $this->logfile = $file; } public function writeLog($entry){ // open the file, in this case the log file $h = "$this->path/$this->logfile"; fopen($h, 'a+'); fwrite($h,$entry); fclose($h); } } Code snippet where attempting to write log entry from program: $pl_log = new Log; $pl_log->setLog($logpath,"run.log"); $usernanme = $_POST['username']; $password = $_POST['secret']; /** * (debugging) logging incoming values from form: */ $pl_log->writeLog("getDateTime(): Incoming values from Login Form: blah...blah...blah\n"); Any help with this would be most appreciated. (be gentle... I'm a PERL program learning PHP OOP) As Stut pointed out, you've misunderstood the difference between a file resource and a file name. Try something like: public function writeLog($entry) { // open the file, in this case the log file $fileName = $this->path.'/'.$this->logfile; $h = fopen($fileName, 'a+'); fwrite($h,$entry); fclose($h); } The file resource that fwrite and fclose need is the *result* of opening the file, not the file name as you were doing. Ideally, you would check the value of $h after the fopen call, to make sure that it had successfully opened the file. Also, I changed the way you were constructing the file name: interpolating the variables in a string is slightly less efficient than concatenating the bits together, and there are possible gotchas when using the $this->variable structure in a string like that. An alternative syntax is to escape the variables with braces: $fileName = "{$this->path}/{$this->logfile}"; -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Pattern etc to reduce duplicated validation?
David Lidstone wrote: Hi All I seem to be writing a lot of this: // SCRIPT = $var = $_POST['var']; // validate $var $foo = new foo; $foo->setBar($var); // CLASS == class foo { public function setBar($var) { // validate $var } } As you can see, the "issue" is that I am validating the input in my script, and then again in my class... surely unwanted duplication!? Obviously (I think!), I need to be validating at the level of my class, so does anyone have a pattern / strategy to help ease the pain... a way of using the validation in the class to validate the script and return meaningful errors to the user?? Throwing errors and forcing the script to catch them perhaps? I have tried a few validation classes etc and they have not really addressed this issue. Perhaps I should just live with it and get on with it! :) Many thanks for your help, David Well, you could try looking at using exceptions: // CLASS class foo { public function setBar($var) { if ( var_is_NOT_a_valid_value_for_bar ) { throw new Exception('Invalid value for bar in class foo'); } } } // = Script = $var = $_POST['var']; $foo = new foo(); try { $foo->setBar($var); } catch (Exception $e) { echo 'An error occurred: ',$e->getMessage(),"\n"; } Take a look at http://www.php.net/manual/en/language.exceptions.php -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
Jason Pruim wrote: On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote: Al wrote: Good point. I usually do use the single quotes, just happened to key doubles for the email. Actually, it's good idea for all variable assignments. Philip Thompson wrote: On Mar 26, 2008, at 6:28 PM, Al wrote: Depends on the server and it's load. I've strung together some rather large html strings and they aways take far less time than the transient time on the internet. I used to use OB extensively until one day I took the time to measure the difference. I don't recall the numbers; but, I do recall it was not worth the slight extra trouble to use OB. Now, I simple assemble by html strings with $report .= "foo"; And then echo $report at the end. It also makes the code very easy to read and follow. You might as well take it a step further. Change the above to: $report .= 'foo'; This way for literal strings, the PHP parser doesn't have to evaluate this string to determine if anything needs to be translated (e.g., $report .= "I like to $foo"). A minimal speedup, but nonetheless... ~Philip Andrew Ballard wrote: On Wed, Mar 26, 2008 at 1:18 PM, Al <[EMAIL PROTECTED]> wrote: You are really asking an HTML question, if you think about it. At the PHP level, either use output buffering or assemble all your html string as a variable and then echo it. The goal is to compress the string into the minimum number of packets. Yes, but do so smartly. Excessive string concatenation can slow things down as well. On most pages you probably won't notice much difference, but I have seen instances where the difference was painfully obvious. Andrew Yes and if your script takes .0002 seconds to run using double quotes it will only take .00019 seconds with single (depending upon how many quotes you have of course) :-) I'm coming in late to this thread so sorry if I missed this :) How much of a difference would it make if you have something like this: echo "$foo bar bar bar bar $foo $foo"; verses: echo $foo . "bar bar bar bar" . $foo $foo; ?In other words... You have a large application which is most likely to be faster? :) There was a discussion about this a few weeks ago - ISTR that the compiler does wierd things with double-quoted strings, something like tokenising the words and checking each bit for lurking variables. So in fact echo "$foo bar bar bar bar $foo $foo"; is slowest (because there *are* variables to interpolate, echo $foo . " bar bar bar bar ".$foo." ".$foo; is a bit faster, but the double-quoted bits cause some slow-down, echo $foo . ' bar bar bar bar '.$foo.' '.$foo; is a bit faster again - the single quoted bits pass through without further inspection, and finally echo $foo,' bar bar bar bar ',$foo,' ',$foo; is actually the fastest, because the strings are not concatenated before output. I think that was the overall summary - I can't locate the original post to verify (or attribute) but it's in this list somewhere... Cheers -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: optimilize web page loading
Eric Butera wrote: On Thu, Mar 27, 2008 at 12:41 PM, Peter Ford <[EMAIL PROTECTED]> wrote: Jason Pruim wrote: > > On Mar 27, 2008, at 11:05 AM, Shawn McKenzie wrote: >> Al wrote: >>> Good point. I usually do use the single quotes, just happened to key >>> doubles for the email. >>> >>> Actually, it's good idea for all variable assignments. >>> >>> Philip Thompson wrote: >>>> On Mar 26, 2008, at 6:28 PM, Al wrote: >>>>> Depends on the server and it's load. I've strung together some >>>>> rather large html strings and they aways take far less time than the >>>>> transient time on the internet. I used to use OB extensively until >>>>> one day I took the time to measure the difference. I don't recall the >>>>> numbers; but, I do recall it was not worth the slight extra trouble >>>>> to use OB. >>>>> >>>>> Now, I simple assemble by html strings with $report .= "foo"; And >>>>> then echo $report at the end. It also makes the code very easy to >>>>> read and follow. >>>> >>>> You might as well take it a step further. Change the above to: >>>> >>>> $report .= 'foo'; >>>> >>>> This way for literal strings, the PHP parser doesn't have to evaluate >>>> this string to determine if anything needs to be translated (e.g., >>>> $report .= "I like to $foo"). A minimal speedup, but nonetheless... >>>> >>>> ~Philip >>>> >>>> >>>>> Andrew Ballard wrote: >>>>>> On Wed, Mar 26, 2008 at 1:18 PM, Al <[EMAIL PROTECTED]> wrote: >>>>>>> You are really asking an HTML question, if you think about it. >>>>>>> >>>>>>> At the PHP level, either use output buffering or assemble all your >>>>>>> html string as a variable and >>>>>>> then echo it. The goal is to compress the string into the minimum >>>>>>> number of packets. >>>>>> Yes, but do so smartly. Excessive string concatenation can slow >>>>>> things >>>>>> down as well. On most pages you probably won't notice much >>>>>> difference, >>>>>> but I have seen instances where the difference was painfully obvious. >>>>>> Andrew >> >> Yes and if your script takes .0002 seconds >> to run using double quotes it will only take >> .00019 seconds with single (depending upon >> how many quotes you have of course) :-) > > I'm coming in late to this thread so sorry if I missed this :) > > How much of a difference would it make if you have something like this: > echo "$foo bar bar bar bar $foo $foo"; verses: echo $foo . "bar bar bar > bar" . $foo $foo; ?In other words... You have a large application which > is most likely to be faster? :) > > There was a discussion about this a few weeks ago - ISTR that the compiler does wierd things with double-quoted strings, something like tokenising the words and checking each bit for lurking variables. So in fact echo "$foo bar bar bar bar $foo $foo"; is slowest (because there *are* variables to interpolate, echo $foo . " bar bar bar bar ".$foo." ".$foo; is a bit faster, but the double-quoted bits cause some slow-down, echo $foo . ' bar bar bar bar '.$foo.' '.$foo; is a bit faster again - the single quoted bits pass through without further inspection, and finally echo $foo,' bar bar bar bar ',$foo,' ',$foo; is actually the fastest, because the strings are not concatenated before output. I think that was the overall summary - I can't locate the original post to verify (or attribute) but it's in this list somewhere... Cheers -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Can you prove these statements with real benchmarks that are current? Ilia said that it is a myth that there is a performance difference between " and ' in one of his talks. I found one recent post on the subject in gmane: http://article.gmane.org/gmane.comp.php.general/169028 The poster's results are as I remembered,
[PHP] Re: putting variables in a variable
Hulf wrote: Hi, I am making and HTML email. I have 3 images to put in. Currently I have $body .=" "; ideally I would like to have $myimage1 = "image1.jpg"; $myimage2 = "image2.jpg"; $myimage3 = "image3.jpg"; and put them into the HTML body variable. I have tried escaping them in every way i can think of, dots and slashes and the rest. Any ideas? Ross Since you've used double quotes, It Should Just Work(TM) ... $body .=" "; I'd probably use single-quotes (') around the src attribute to avoid those ugly backslashes ... $body .=" "; Might be better in this case to use heredoc syntax ... $body .<< EndOfChunk; -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic boxes problem... JS and PHP
Mark Weaver wrote: Ryan S wrote: Hey everyone, A bit of a puzzle here, dont know if this is a JS problem or PHP or FF or just me. (My money is on the last one :p ) Here's what I am trying to do: In a form I have a listbox with the values 1-5, and under the listbox i have a with the id of "recips" (like so: cellpadding="2">' + '' + ''+ x +'. Recipient\'s name:' + '' + 'Recipient\'s email:' + '/>' + '' + '' + ''; } document.getElementById('recips').innerHTML=msg; } / # End JS code So far on the page everything is working, but when I click the submit button this is my PHP processing script: It shows me everything that has been submitted but NOT any of the above dynamically made boxes values... but get this, it DOES show me all values... in IE7 _not_ in FF (am using 2.0.0.13) Anybody else face anything like this? Is this a bug in FF? Is $_REQUEST wrong to catch this? Dont know what the @#$@ to do... ANY help even a link to a site which can shed a little light would be appreciated. Thanks in advance. /Ryan Hi Ryan, Since I'm relatively new to PHP I could be off on this, but I'd say yes, $_REQUEST is wrong. I would think you'd want to use $_POST to receive the incoming values from a form. That would depend on the method that the form is using: GET or POST. I don't think that's the answer. Two things I would suggest: 1. Check that the Javascript is doing what you expect: you *are* using Firebug on Firefox, aren't you? Also the WebDeveloper toolbar plugin is useful - it has a View Generated Source tool which will show you what Firefox thinks your page actually looks like after the JS has run... 2. Check that the TD you are loading with content is actually inside the tags - otherwise the inputs won't be included in the request/post variables... Cheers Pete -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic boxes problem... JS and PHP
Peter Ford wrote: Mark Weaver wrote: Ryan S wrote: Hey everyone, A bit of a puzzle here, dont know if this is a JS problem or PHP or FF or just me. (My money is on the last one :p ) Here's what I am trying to do: In a form I have a listbox with the values 1-5, and under the listbox i have a with the id of "recips" (like so: cellpadding="2">' + '' + ''+ x +'. Recipient\'s name:' + '' + 'Recipient\'s email:' + '/>' + '' + '' + ''; } document.getElementById('recips').innerHTML=msg; } / # End JS code So far on the page everything is working, but when I click the submit button this is my PHP processing script: It shows me everything that has been submitted but NOT any of the above dynamically made boxes values... but get this, it DOES show me all values... in IE7 _not_ in FF (am using 2.0.0.13) Anybody else face anything like this? Is this a bug in FF? Is $_REQUEST wrong to catch this? Dont know what the @#$@ to do... ANY help even a link to a site which can shed a little light would be appreciated. Thanks in advance. /Ryan Hi Ryan, Since I'm relatively new to PHP I could be off on this, but I'd say yes, $_REQUEST is wrong. I would think you'd want to use $_POST to receive the incoming values from a form. That would depend on the method that the form is using: GET or POST. I don't think that's the answer. Two things I would suggest: 1. Check that the Javascript is doing what you expect: you *are* using Firebug on Firefox, aren't you? Also the WebDeveloper toolbar plugin is useful - it has a View Generated Source tool which will show you what Firefox thinks your page actually looks like after the JS has run... 2. Check that the TD you are loading with content is actually inside the tags - otherwise the inputs won't be included in the request/post variables... Cheers Pete Ryan, First, you should reply to the list - that way more people could see the links you posted and help out. Right, It looks like there may be a problem with the form tags - when I look at this code I see That looks like you've closed your "mainform" before defining the inputs Don't know why IE works, but it's probably trying to be helpful... :) -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php