Re: [PHP] Mail-format...
It looks like somebody is trying to launch an e-mail injection attack. Looking at your code, I don't think you are vulnerable. You can read more about e-mail injection at http://securephp.damonkohler.com/index.php/Email_Injection You could also send nasty e-mails to [EMAIL PROTECTED], telling them to stop trying to hack your website. David Gustav Wiberg wrote: Hi there! I wonder why I get get these kind of mails (look down below in this mail) I recieve them sometimes... ...I have a code like this... $name = $_POST[frmNamn]; $email = $_POST[frmEpost]; //Send mail that there is a new member // mail([EMAIL PROTECTED],Ny medlem - Stammis Internet,Namn: $name, Epost:$email); /G http://www.varupiraten.se/ Namn: [EMAIL PROTECTED] Content-Type: multipart/mixed; boundary=\===0158601545==\ MIME-Version: 1.0 Subject: c1805938 To: [EMAIL PROTECTED] bcc: [EMAIL PROTECTED] From: [EMAIL PROTECTED] This is a multi-part message in MIME format. --===0158601545== Content-Type: text/plain; charset=\us-ascii\ MIME-Version: 1.0 Content-Transfer-Encoding: 7bit aienglpcm --===0158601545==-- , Epost:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail-format...
- Original Message - From: David Tulloh [EMAIL PROTECTED] To: Gustav Wiberg [EMAIL PROTECTED] Cc: PHP General php-general@lists.php.net Sent: Monday, September 19, 2005 8:19 AM Subject: Re: [PHP] Mail-format... It looks like somebody is trying to launch an e-mail injection attack. Looking at your code, I don't think you are vulnerable. You can read more about e-mail injection at http://securephp.damonkohler.com/index.php/Email_Injection You could also send nasty e-mails to [EMAIL PROTECTED], telling them to stop trying to hack your website. David Gustav Wiberg wrote: Hi there! I wonder why I get get these kind of mails (look down below in this mail) I recieve them sometimes... ...I have a code like this... $name = $_POST[frmNamn]; $email = $_POST[frmEpost]; //Send mail that there is a new member // mail([EMAIL PROTECTED],Ny medlem - Stammis Internet,Namn: $name, Epost:$email); /G http://www.varupiraten.se/ Namn: [EMAIL PROTECTED] Content-Type: multipart/mixed; boundary=\===0158601545==\ MIME-Version: 1.0 Subject: c1805938 To: [EMAIL PROTECTED] bcc: [EMAIL PROTECTED] From: [EMAIL PROTECTED] This is a multi-part message in MIME format. --===0158601545== Content-Type: text/plain; charset=\us-ascii\ MIME-Version: 1.0 Content-Transfer-Encoding: 7bit aienglpcm --===0158601545==-- , Epost:[EMAIL PROTECTED] -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.1/104 - Release Date: 2005-09-16 Ok, thanx! /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [php]: monthly statistics
John Taylor-Johnston wrote: How will I draw a graph img src=reddot.gif width=2 height=$mydate-number_of_hits_per_day? Anything in the manual to look at? http://www.mysql.com/search/?q=YEARMONTHcharset=utf-8 http://ca3.php.net/manual-lookup.php?pattern=YEARMONTH jpgraph is an application often recommended in this september forum - haven't used it myself so I can't give a personal opinion. Cheers -- David Robley Toys are made in heaven, batteries are made in hell. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using DOM object, how?
I was looking at the PHP DOM documentation here http://www.php.net/ manual/en/ref.dom.php (which is rather sparse in the way of examples) and can't even get to square one. Here's an example from the php site: ?php $doc = DOMDocument::loadXML('rootnode//root'); echo $doc-saveXML(); $doc = new DOMDocument(); $doc-loadXML('rootnode//root'); echo $doc-saveXML(); ? Problem is, it chokes on the first line with the error: Fatal error: Undefined class name 'domdocument' in /folder/ dom_test.php on line 1 Anyone know how to use this thing? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Javscript embedding problem
It might be a timing problem. It might take longer to load the file containing the code so that when the inline code is found and executed, the called function is not present. Notice that all the downloads of the bits and pieces of an HTML page proceed asynchronously and not sequentially. You should not assume that the call to a function will be done after the file is downloadad because it shows up later. The browser queues the download of all the external elements in the page, code, pictures, etc while it keeps downloading and processing the main download. They can easily get out of synch. The proper way to include and call javascript code is to include all code in the head and then make the call in the onLoad event of the body tag. This onLoad event is called when every part of the page is already loaded and, thus, the downloaded javascript file is assured to be available. Satyam Iggep [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] John Taylor-Johnston wrote: Try \countdown.js\ instead of single quotes ? //INCLUSION OF COUNTDOWN TIMER .trtd colspan=2SCRIPT language='JavaScript' SRC='countdown.js'/SCRIPTcenterscript type='text/javascript'countdown_clock(05, 11, 19, 08, 00, 1);/script/center/td/tr\n ./table\n Tried that and it didn't work either. I changed it to SRC='countdown.js' after escaping the double quites didn't work. This is really bugging the heck out of me! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] HEADER + target?
Hi there! I think this question has been on the list before, but I can't find it. I want to do like this: script language=Javascript parent.mainFrame.location = 'fire.php'; /script ...but in PHP with the HEADER() - function... I do I achieve that? /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HEADER + target?
Gustav Wiberg wrote: I think this question has been on the list before, but I can't find it. I want to do like this: script language=Javascript parent.mainFrame.location = 'fire.php'; /script ...but in PHP with the HEADER() - function... Not that hard to find... http://php.net/header header('Location: http://www.example.com/fire.php'); You should put the full URI, including http:// and your domain. Not doing so violates the HTTP spec. If you want to signal that the resource has permanently moved, put this before the above call: header('HTTP/1.1 301 Moved Permanently'); -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Using DOM object, how?
Ken Tozier wrote: I was looking at the PHP DOM documentation here http://www.php.net/ manual/en/ref.dom.php (which is rather sparse in the way of examples) and can't even get to square one. Here's an example from the php site: ?php $doc = DOMDocument::loadXML('rootnode//root'); echo $doc-saveXML(); $doc = new DOMDocument(); $doc-loadXML('rootnode//root'); echo $doc-saveXML(); ? Problem is, it chokes on the first line with the error: Fatal error: Undefined class name 'domdocument' in /folder/ dom_test.php on line 1 Anyone know how to use this thing? Thanks The first line of that page - The DOM extension is the replacement for the DOM XML extension from PHP 4. makes me suspect that it may be a PHP 5 feature, and sure enough, a look in the changelog confirms this. php.net/ChangeLog-5.php#5.0.0b1 So if you are using php 5.0, that would explain your error. Cheers -- David Robley Be nice to your kids. They'll choose your nursing home. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HEADER + target?
- Original Message - From: Jasper Bryant-Greene [EMAIL PROTECTED] To: PHP General php-general@lists.php.net Sent: Monday, September 19, 2005 10:31 AM Subject: Re: [PHP] HEADER + target? Gustav Wiberg wrote: I think this question has been on the list before, but I can't find it. I want to do like this: script language=Javascript parent.mainFrame.location = 'fire.php'; /script ...but in PHP with the HEADER() - function... Not that hard to find... http://php.net/header header('Location: http://www.example.com/fire.php'); You should put the full URI, including http:// and your domain. Not doing so violates the HTTP spec. If you want to signal that the resource has permanently moved, put this before the above call: header('HTTP/1.1 301 Moved Permanently'); -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.1/104 - Release Date: 2005-09-16 Hi again! I wasn't clear enough.. hm.. I meant that lets say, I have two frames = leftFrame and rightFrame. I'm in leftFrame and want to redirect to a page called fire.php in the rightFrame. If I use HEADER(Location: fire.phg); then the current frame will be updated (leftFrame), I want to update the rightFrame FROM the leftFrame... /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HEADER + target?
Gustav Wiberg wrote: I wasn't clear enough.. hm.. I meant that lets say, I have two frames = leftFrame and rightFrame. I'm in leftFrame and want to redirect to a page called fire.php in the rightFrame. If I use HEADER(Location: fire.phg); then the current frame will be updated (leftFrame), I want to update the rightFrame FROM the leftFrame... Then use JavaScript as you indicated in your original message. Remember PHP is executed on the server side so has no knowledge of browser things like frames. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
The first line of that page - The DOM extension is the replacement for the DOM XML extension from PHP 4. makes me suspect that it may be a PHP 5 feature, and sure enough, a look in the changelog confirms this. php.net/ChangeLog-5.php#5.0.0b1 So if you are using php 5.0, that would explain your error. That was it. (php 4.3.1 something) Just downloaded 5.0.5 and it works fine now. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
Next question: I don't see any obvious DOM method for including scripts or css links like script language='text/javascript' src='bobo.js'. Do you have to put them in some other type of node like a processing instruction or a comment? On Sep 19, 2005, at 5:22 AM, Ken Tozier wrote: The first line of that page - The DOM extension is the replacement for the DOM XML extension from PHP 4. makes me suspect that it may be a PHP 5 feature, and sure enough, a look in the changelog confirms this. php.net/ChangeLog-5.php#5.0.0b1 So if you are using php 5.0, that would explain your error. That was it. (php 4.3.1 something) Just downloaded 5.0.5 and it works fine now. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] can not re-use a object
Hi! Sorry about the bad english :-[ I try to re-use an object that manage the mysql connections (it is code from sugarcrm) $db = new PearDatabase(); $var = ' . $user_id .'; $pregunta = SELECT user_name FROM users WHERE id = $var; $resultado = $db-query($pregunta, true, Error filling in user array: ); $row = $db-fetchByAssoc($resultado); $user_name= $row['user_name']; if i try a new query (can be the same one or an other one), i become 0 as result and no error message I have try to use the same $db and to create a new one, i have try to close the descriptor Thanks for help pascal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
Ken Tozier wrote: I don't see any obvious DOM method for including scripts or css links like script language='text/javascript' src='bobo.js'. Do you have to put them in some other type of node like a processing instruction or a comment? ?php $dom = new DOMDocument('1.0', 'UTF-8'); $script = $dom-createElement('script'); $script-setAttribute('type', 'text/javascript'); $script-setAttribute('src', 'bobo.js'); $dom-appendChild($script); ? Similarly for a link or style element for CSS... -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
On Monday 19 September 2005 05:27 am, Jasper Bryant-Greene wrote: Ken Tozier wrote: I don't see any obvious DOM method for including scripts or css links like script language='text/javascript' src='bobo.js'. Do you have to put them in some other type of node like a processing instruction or a comment? ?php $dom = new DOMDocument('1.0', 'UTF-8'); $script = $dom-createElement('script'); $script-setAttribute('type', 'text/javascript'); $script-setAttribute('src', 'bobo.js'); $dom-appendChild($script); ? I would be extremely careful with this.. because sadly PHP's XML generator uses the short form whenever possible. script / will *NOT* work in most browsers such as FireFox. script/script Will work. I personally would love to see a function where I could set it to use the long form. and when importing if it's in long form.. set that long from flag on automatically .. this would have saved me _hours_ of debugging work. are you trying to just generate the entire html page using only the XML DOM? .. or are you doing this in conjunction with another language such as XSL? Similarly for a link or style element for CSS... -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
Stephen Leaf wrote: On Monday 19 September 2005 05:27 am, Jasper Bryant-Greene wrote: Ken Tozier wrote: I don't see any obvious DOM method for including scripts or css links like script language='text/javascript' src='bobo.js'. Do you have to put them in some other type of node like a processing instruction or a comment? ?php $dom = new DOMDocument('1.0', 'UTF-8'); $script = $dom-createElement('script'); $script-setAttribute('type', 'text/javascript'); $script-setAttribute('src', 'bobo.js'); $dom-appendChild($script); ? I would be extremely careful with this.. because sadly PHP's XML generator uses the short form whenever possible. script / will *NOT* work in most browsers such as FireFox. script/script Will work. You can probably add an empty text node to the script tag, or a text node consisting of a single space, or something like that, to make it use the long form. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session creation time
How can I get the first creation time of a session (the time a session was first started)? -thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session creation time
session_start(); if (empty($_SESSION['start_time']) $_SESSION['start_time']=time(); echo $_SESSION['start_time']; -Original Message- From: Eli [mailto:[EMAIL PROTECTED] Sent: 19 September 2005 13:21 To: php-general@lists.php.net Subject: [PHP] Session creation time How can I get the first creation time of a session (the time a session was first started)? -thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can I install versions of PHP/MySQL that will be compatible with my host server?
PHP General List, First, let me say that while I have been scripting with PHP and MySQL for my web sites for a few years, I have never configured or installed either PHP or MySQL, so I should be considered a newbie for installation issues. The situation: I am running Linux on my home computer. The specific distribution is CentOS 4.1. My computer is a pentium 3 with 512 MB Ram. On the web hosting service where my web sites are hosted, they have the following versions of PHP, MySQL and phpMyAdmin: PHP Version 4.3.8 MySQL 4.1.3-beta-standard phpMyAdmin 2.5.7-pl1 What I would like to do is install versions of these applications on my machine that will be compatible with my server so that I can develop and test web sites on my home machine which will hopefully work on my host server. I know that the current latest versions of these applications are as follows: PHP 4.4.0 MySQL 4.1.14 phpMyAdmin 2.6.4 I've already spoken to my web host and they intend to upgrade to the new versions as soon as they build a compatible interface for them with their administrator control panel interface. The Questions: If I install the latest versions locally, will they be backwards compatible enough with the versions on my host server? Would it be easy enough to install the versions that my host has, and then upgrade later? Any advice would be much appreciated. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] headers .vs javascript location.href
chris, i'd already asked/explained the error. to reiterate, the error i'm getting is the error that's generated when you try to use the php 'header' function, and it throws a warning/error regarding 'headers already being sent...' the soln appears to be to use the php buffering functions, as this is supposed to stop output from being generated/posted, allowing the app to 'buffer' the output until the page is displayed. i've tried to use an 'ob_start()' as the very 1st line in the index.php page that's being displayed. i've also tried to insert the 'ob_start()' in a number of various places within the app with no change... my question was how/what could i possibly do, short of using the javascript soln, which seems to work... i also stated that i could readily provide the code that i'm creating if anyone wanted to take an actual look. and as i also stated, yeah, it could/should be cleaned up, but for now, it's a test app... -bruce -Original Message- From: Chris Shiflett [mailto:[EMAIL PROTECTED] Sent: Sunday, September 18, 2005 8:20 PM To: [EMAIL PROTECTED] Cc: 'php' Subject: Re: [PHP] headers .vs javascript location.href bruce wrote: need to talk to someone to figure out how/what i need to do to use the php 'headers' function, as opposed to the javascript 'location.href'. i've tried to implement the buffering functions, but still get the same error... is there someone that i can talk to about this, who ha experience/understanding of what's going on. i've thought about rewriting what i have to this point, but i've got code interspersed with html... yeah.. i know... cleaning it up would probably make things easier/better, but this is a quick/dirty test.. and i don't claim to be a web developer! You need to ask a question if you want to receive an answer. If your question really is whether there is anyone you can talk to, then the answer is yes. There are quite a few people on this list who know a great deal about the topics you mention. (You might want to start by clarifying the reference to the same error.) Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can I install versions of PHP/MySQL that will be compatible with my host server?
Dave Gutteridge wrote: PHP General List, First, let me say that while I have been scripting with PHP and MySQL for my web sites for a few years, I have never configured or installed either PHP or MySQL, so I should be considered a newbie for installation issues. The situation: I am running Linux on my home computer. The specific distribution is CentOS 4.1. My computer is a pentium 3 with 512 MB Ram. On the web hosting service where my web sites are hosted, they have the following versions of PHP, MySQL and phpMyAdmin: PHP Version 4.3.8 MySQL 4.1.3-beta-standard phpMyAdmin 2.5.7-pl1 What I would like to do is install versions of these applications on my machine that will be compatible with my server so that I can develop and test web sites on my home machine which will hopefully work on my host server. I know that the current latest versions of these applications are as follows: PHP 4.4.0 do you 'abuse' references? if not then you should have no problem. ... you may have code that breaks on 4.4 due to fixes made to the core engine of php... e.g: $var = array_pop( explode('-', '1-2-3-4-5') ); .. is bad code (read the manual page for array_pop very carefully) and would work in older versions but the engine has been tightened up to disallow such fauxpas. MySQL 4.1.14 unless you are using very new features of mySQL I doubt you will have compatibility problems (although be ware of the difference between the mysql extension and it's replacement mysqli) phpMyAdmin 2.6.4 wouldn't worry about this at all.one version will have a few more/nicer features. not a big deal :-) I've already spoken to my web host and they intend to upgrade to the new versions as soon as they build a compatible interface for them with their administrator control panel interface. don't hold your breath for that :-) The Questions: If I install the latest versions locally, will they be backwards compatible enough with the versions on my host server? mostly yes, some stuff will break. it depends on what your code actually does. Would it be easy enough to install the versions that my host has, and then upgrade later? the release archive has what you need: http://nl2.php.net/releases.php Any advice would be much appreciated. ...hth. if you get stuck with a incompatibility problem with your home machine and hosting machine, and no one else can help ... call the 'A'team (er ... I mean mail this list and see if the regulards** can help :-)) rgds, Jochem ** I hereby put forth the motion to include the word 'regulard' into the english language ... stemming from 'regular retard' , invented in the spirit of total bastardization of every language through the power of internet acronymization ;-) Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Poll: PHP 4 / 5
Rasmus Lerdorf schrieb: [...] What do we do with code like this? If you follow it through it is essentially doing: 3 = banana; This is obviously totally wrong and has to be noted as wrong, hence E_NOTICE. Since it can be dealt with without rendering the script unexecutable raising a fatal error in PHP5 is wrong = switch that to E_NOTICE, too. But the problem for a lot of people using PHP applications simply is that they had perfectly running code and they weren't getting any notices at all. Now they still have working code but this one error in code they haven't written is throwing notices at them like hell. The quick answer is deactivate error reporting for production systems, but this is not a real solution for the PHP 4.x platform. People _using_ foreign code expect to get consistent behaviour from their applications. So the report level for this should be configurable for the 4.x branch with silence as default. AllOLLi The good news is: The whiskey works. [Lost in Translation] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] bowscap ini
Hi, Can some pont me towards a tutorial that can help me extract the information when using browscap.ini. I need to know browser, version and operating system If you any other advice for browser I would be happy to hear it. Thanks, Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: curl version and PHP docs
To put the question more simply, is there any way of finding out what versions of the PHP modules ship with each/the latest release, short of installing that version of PHP? Some release notes, for example? Thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bowscap ini
Ross wrote: Hi, Can some pont me towards a tutorial that can help me extract the information when using browscap.ini. I need to know browser, version and operating system If you any other advice for browser I would be happy to hear it. Thanks, Ross Generally, by reading the manual: http://uk.php.net/manual/en/function.get-browser.php Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can I install versions of PHP/MySQL that will be compatible with my host server?
Thank you for your helpful assistance in explaining the situation to me. It would seem from the advice I've been given that I don't need to worry about compatibility when it comes to application versions. But I do have a follow up question. Are there any specifications or installation options that I should look out for? Are there installation options I should ensure that I have selected for my home installation to ensure the behaviour is the same as my host machine? Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] REGEX Help Please
Hi, I am trying to implement a regular expression so that I have a number between 0.00 and 1.00. the following works except I can go up to 1.99 $regexp = /^[0-1]{1}.[0-9]{2}/; Can anyone help here please? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can I install versions of PHP/MySQL that will be compatible with my host server?
On Sep 19, 2005, at 8:31 AM, Jochem Maas wrote: e.g: $var = array_pop( explode('-', '1-2-3-4-5') ); .. is bad code (read the manual page for array_pop very carefully) and would work in older versions but the engine has been tightened up to disallow such fauxpas. Jochem, Whoa... what do you mean by this, exactly? I am running PHP 5.0.4 and $var is correctly set with the code you give above. I could not find anything like you describe in the array_pop manual (see below). Please elaborate on why this is bad code. Jordan array_pop (PHP 4, PHP 5) array_pop -- Pop the element off the end of array Description mixed array_pop ( array array ) array_pop() pops and returns the last value of the array, shortening the array by one element. If array is empty (or is not an array), NULL will be returned. Note: This function will reset() the array pointer after use. Example 1. array_pop() example ?php $stack = array(orange, banana, apple, raspberry); $fruit = array_pop($stack); print_r($stack); ? After this, $stack will have only 3 elements: Array ( [0] = orange [1] = banana [2] = apple ) and raspberry will be assigned to $fruit. See also array_push(), array_shift(), and array_unshift(). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bowscap ini
Mikey wrote: snip http://uk.php.net/manual/en/function.get-browser.php How about that. I've been using php since late '98, early '99. Messing around on this list since '99, and _did not_ know about that function. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] REGEX Help Please
Shaun wrote: Hi, I am trying to implement a regular expression so that I have a number between 0.00 and 1.00. the following works except I can go up to 1.99 $regexp = /^[0-1]{1}.[0-9]{2}/; Can anyone help here please? Thanks May have to go outside just a regex... if ( preg_match ( /^\d{1}\.\d{2}$/, $number ) $number = 0 $number = 1 ) -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with mysql_connect(...)
Hello. I'm trying to connect to my MySQL server with mysql_connect(...). The server is up and running, and I'm running Apache with PHP properly installed. The code: $hleServer = mysql_connect($host, $user, $password) or die(Error: Database. Error code: 1. Contact the web master!); $host, $user, and $password are set to correct values (checked and double checked). The funny thing is that not only does the function call fail, but I'm not even getting the text defined by die(...). It seems that the function call is more or less a black hole. Of course the rest of the script doesn't execute either, I'm just left with a blank page. I didn't use to have this problem before (using PHP 5 now instead of 4). Thanks for any input on this problem... Arthur
[PHP] Re: REGEX Help Please
I am trying to implement a regular expression so that I have a number between 0.00 and 1.00. the following works except I can go up to 1.99 $regexp = /^[0-1]{1}.[0-9]{2}/; You could always do this, unless you are set on using a regular expression: if($num=0 $num=1.01){ echo number_format($num,2); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] REGEX Help Please
On Mon, 2005-09-19 at 10:11, John Nichel wrote: Shaun wrote: Hi, I am trying to implement a regular expression so that I have a number between 0.00 and 1.00. the following works except I can go up to 1.99 $regexp = /^[0-1]{1}.[0-9]{2}/; Can anyone help here please? Thanks May have to go outside just a regex... if ( preg_match ( /^\d{1}\.\d{2}$/, $number ) $number = 0 $number = 1 ) $regexp = '/^((1\.00)|(0\.\d\d))$/'; Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RSS creator class
Wondering if anyone knows of a PHP class or other PHP tool for creating RSS/XML data which gracefully handles 'strange' characters such as M$ Word's delightful 'smart quotes'. I've found a couple so far, libRSS (by Jan Pieper) and ContentFeeder 2.0, but neither deals very well with the plethora of rubbish that seems to issue from Word. These seem to be mainly in the range (but not all of the range) ASCII 128 - 159 TIA for any pointers. Cheers -- David Robley I commanded a group of ships for a week, Tom said fleetingly. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with mysql_connect(...)
I'm trying to connect to my MySQL server with mysql_connect(...). The server is up and running, and I'm running Apache with PHP properly installed. : --- But have you got the mysql extension? put this in a script ?php phpinfo(); ? and view the output to check The code $hleServer = mysql_connect($host, $user, $password) or die(Error: Database. Error code: 1. Contact the web master!); $host, $user, and $password are set to correct values (checked and double checked). The funny thing is that not only does the function call fail, but I'm not even getting the text defined by die(...). It seems that the function call is more or less a black hole. Of course the rest of the script doesn't execute either, I'm just left with a blank page. I didn't use to have this problem before (using PHP 5 now instead of 4). Thanks for any input on this problem... Arthur -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can I install versions of PHP/MySQL that will be compatible with my host server?
Jordan Miller wrote: On Sep 19, 2005, at 8:31 AM, Jochem Maas wrote: e.g: $var = array_pop( explode('-', '1-2-3-4-5') ); .. is bad code (read the manual page for array_pop very carefully) and would work in older versions but the engine has been tightened up to disallow such fauxpas. Jochem, Whoa... what do you mean by this, exactly? I am running PHP 5.0.4 and what I meant an what I wrote apparently don't match up very well :-) I meant to give a valid example of when you can't pass the return value from a function to another function due to the fact that a reference is expected and in some situation the var you are passing is a reference to 'nothing' - which works in older version of php but is also the cause of a couple of weird/nasty inexplicable potential seg faults ... it was fixed, Derick opened his mouth, alot of people got angry - personally I don't give a shit because I only use 5.0.x (I'll be waiting until the shitstorm has died down before trying out 5.0.5 or 5.1 :-) maybe this helps to explain (alot) better what I was talking about ... http://phplens.com/phpeverywhere/?q=node/view/214 anyway thanks for the catch Jordan. $var is correctly set with the code you give above. I could not find anything like you describe in the array_pop manual (see below). Please elaborate on why this is bad code. Jordan array_pop (PHP 4, PHP 5) array_pop -- Pop the element off the end of array Description mixed array_pop ( array array ) array_pop() pops and returns the last value of the array, shortening the array by one element. If array is empty (or is not an array), NULL will be returned. Note: This function will reset() the array pointer after use. Example 1. array_pop() example ?php $stack = array(orange, banana, apple, raspberry); $fruit = array_pop($stack); print_r($stack); ? After this, $stack will have only 3 elements: Array ( [0] = orange [1] = banana [2] = apple ) and raspberry will be assigned to $fruit. See also array_push(), array_shift(), and array_unshift(). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: headers .vs javascript location.href
bruce wrote: hi.. need to talk to someone to figure out how/what i need to do to use the php 'headers' function, as opposed to the javascript 'location.href'. i've tried to implement the buffering functions, but still get the same error... is there someone that i can talk to about this, who ha experience/understanding of what's going on. i've thought about rewriting what i have to this point, but i've got code interspersed with html... yeah.. i know... cleaning it up would probably make things easier/better, but this is a quick/dirty test.. and i don't claim to be a web developer! thanks -bruce [EMAIL PROTECTED] Bruce, your question lacks specificity, so it is difficult to give you a simple answer. Here is how I handle virtually of of my html pages. It solves the buffering problems and makes good, clean, and easy to debug code. This approach is good since, like buffering, it sends everything in one stream to the client. I assemble my output stream like so. Obviously, foo can be anything, variables, strings, etc. $report= ''; code or what ever $report .= foo; code or what ever $report .= foo2; and so on Then at the end when the report is fully assembled, I simply echo $report; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bowscap ini
John Nichel wrote: Mikey wrote: snip http://uk.php.net/manual/en/function.get-browser.php How about that. I've been using php since late '98, early '99. Messing around on this list since '99, and _did not_ know about that function. Ah now, don't be saying things like that - it will only inflate my ego, and I am but a humble hacker ;o) Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can I install versions of PHP/MySQL that will be compatible with my host server?
That is very interesting, thank you. We cannot escape politics, eh? Jordan On Sep 19, 2005, at 9:32 AM, Jochem Maas wrote: Jordan Miller wrote: On Sep 19, 2005, at 8:31 AM, Jochem Maas wrote: e.g: $var = array_pop( explode('-', '1-2-3-4-5') ); .. is bad code (read the manual page for array_pop very carefully) and would work in older versions but the engine has been tightened up to disallow such fauxpas. Jochem, Whoa... what do you mean by this, exactly? I am running PHP 5.0.4 and what I meant an what I wrote apparently don't match up very well :-) I meant to give a valid example of when you can't pass the return value from a function to another function due to the fact that a reference is expected and in some situation the var you are passing is a reference to 'nothing' - which works in older version of php but is also the cause of a couple of weird/nasty inexplicable potential seg faults ... it was fixed, Derick opened his mouth, alot of people got angry - personally I don't give a shit because I only use 5.0.x (I'll be waiting until the shitstorm has died down before trying out 5.0.5 or 5.1 :-) maybe this helps to explain (alot) better what I was talking about ... http://phplens.com/phpeverywhere/?q=node/view/214 anyway thanks for the catch Jordan. $var is correctly set with the code you give above. I could not find anything like you describe in the array_pop manual (see below). Please elaborate on why this is bad code. Jordan array_pop (PHP 4, PHP 5) array_pop -- Pop the element off the end of array Description mixed array_pop ( array array ) array_pop() pops and returns the last value of the array, shortening the array by one element. If array is empty (or is not an array), NULL will be returned. Note: This function will reset() the array pointer after use. Example 1. array_pop() example ?php $stack = array(orange, banana, apple, raspberry); $fruit = array_pop($stack); print_r($stack); ? After this, $stack will have only 3 elements: Array ( [0] = orange [1] = banana [2] = apple ) and raspberry will be assigned to $fruit. See also array_push(), array_shift(), and array_unshift(). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS creator class
On 9/19/05, David Robley [EMAIL PROTECTED] wrote: Wondering if anyone knows of a PHP class or other PHP tool for creating RSS/XML data which gracefully handles 'strange' characters such as M$ Word's delightful 'smart quotes'. Why not do something simple like preg_replace [^a-zA-Z0-9_-](or something like that) with its #xx equivlent. I've found a couple so far, libRSS (by Jan Pieper) and ContentFeeder 2.0, but neither deals very well with the plethora of rubbish that seems to issue from Word. These seem to be mainly in the range (but not all of the range) ASCII 128 - 159 TIA for any pointers. Cheers -- David Robley I commanded a group of ships for a week, Tom said fleetingly. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
I would be extremely careful with this.. because sadly PHP's XML generator uses the short form whenever possible. script / will *NOT* work in most browsers such as FireFox. script/script Will work. Thanks for the heads up. Looks like if you define the tag like $script= $dom-createElement('script',''); -- empty string It tacks on an end tag. I personally would love to see a function where I could set it to use the long form. and when importing if it's in long form.. set that long from flag on automatically .. this would have saved me _hours_ of debugging work. are you trying to just generate the entire html page using only the XML DOM? .. or are you doing this in conjunction with another language such as XSL? So far, just playing. But ultimately I'd like to generate the whole page using dom calls. It seems much cleaner for what I'm doing than creating a whole bunch of large functions that do nothing more than echo prestyled html. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Suggestions for class design
Hello, Every time I write some classes I always come across the same fundamental problem that I haven't figured out how to solve/approach yet. I'm not exactly sure how to put it into words simply but here goes... Let's take for example a class called 'Customer' that (obviously) manipulates customers in the database. Here is a very basic Customer class. (Data validation and the like are left out for brevity.) class Customer { var $id; var $name; function add_customer() { // create sql statement $sql = INSERT INTO ...; // create db connection $db = DB::singleton(); // execute SQL $db-execute($sql); } function delete_customer() { // create sql statement $sql = DELETE FROM ...; // create db connection $db = DB::singleton(); // execute SQL $db-execute($sql); } function get_customer() { // create sql statement $sql = SELECT ... FROM ...; // create db connection $db = DB::singleton(); // execute SQL $customer = $db-execute($sql); // populate object variables $this-id = $customer['id']; $this-name = $customer['name']; } } (Unless I've already got some major design flaws I think we should be good to go.) Where I get tripped up is when I realize I'll need to at some point get more than one customer at a time and thus I want to add a method called 'get_customers()'. Since an object should be a single instance of something (e.g. ONE customer) how do I justify adding the method 'get_customers()'? Or better yer, how do I properly add a method like that? (A method where instead of using a SQL statement to return ONE customer's data I instead return a record set with more than one customer.) The class in its current state can't handle data like that so I have to then rethink the design and a new object variable called $customers where I store the record set that is in return accessed directly by the calling page itself. With the way I'm working with these objects now they seem less like objects and more like an organized collection of functions. I'd appreciate some actual code recommendations as I have a hard time understanding the abstract descriptions of how objects should work and be designed. Thanks, Chris. Thanks! Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Suggestions for class design
[snip] Where I get tripped up is when I realize I'll need to at some point get more than one customer at a time and thus I want to add a method called 'get_customers()'. [/snip] I know that you didn't ask for this, but the point needs discussing given your assertion above. Why, at any point, would you need to get more than one customer? One answer is that all customers or a group of customers will need to be updated/edited with the same information. Therefore you need a seperate class for multiple customers which could then be extended by group. A group of customers is a seperate object. Make sense? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Suggestions for class design
Jay Blanchard mailto:[EMAIL PROTECTED] on Monday, September 19, 2005 10:40 AM said: [snip] Where I get tripped up is when I realize I'll need to at some point get more than one customer at a time and thus I want to add a method called 'get_customers()'. [/snip] Why, at any point, would you need to get more than one customer? Good question. When I need more than one customer is when I'm displaying them all on an administration page. Maybe a better example class would be Products. One individual product is displayed on the product's detail page, but in the search results I'd normally be using the same Product class to display all the results which forces me to create a 'get_products()' method. One answer is that all customers or a group of customers will need to be updated/edited with the same information. Therefore you need a seperate class for multiple customers which could then be extended by group. A group of customers is a seperate object. Make sense? Well, yes I think it does, but what I'm missing is how this new object interacts with the original one if it does at all. And what would I call it? 'Multiple_Customers'? Or.. perhaps just 'Customers'! :) Do I extend the Customer class or is it a stand alone class? Thanks, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Unserialize Errors
Hello all, I'm curious to know if there are stability issues with the un/serialize functions. I've my code, I serialize a multidimensional array to disk and when I read it in later, 20% of the time I get errors like: Notice: unserialize(): Error at offset 2137774 of 2137781 bytes -- James T. Richardson, Jr. = eXcellence in IS Solutions, Inc. Office: 713-862-9200 Pager/Voicemail: 713-339-7226 Email: [EMAIL PROTECTED] = -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Suggestions for class design
[snip] Well, yes I think it does, but what I'm missing is how this new object interacts with the original one if it does at all. And what would I call it? 'Multiple_Customers'? Or.. perhaps just 'Customers'! :) Do I extend the Customer class or is it a stand alone class? [/snip] I think that it should be a stand alone class. The Customers class could instantiate the needed number of Customer objects and the methods of the Customers class could affect each Customer object. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Suggestions for class design
Jay Blanchard wrote: [snip] Well, yes I think it does, but what I'm missing is how this new object interacts with the original one if it does at all. And what would I call it? 'Multiple_Customers'? Or.. perhaps just 'Customers'! :) Do I extend the Customer class or is it a stand alone class? [/snip] I think that it should be a stand alone class. The Customers class could instantiate the needed number of Customer objects and the methods of the Customers class could affect each Customer object. +1 for this idea, it is a method I have used on countless projects and works very well. Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Suggestions for class design
Jay Blanchard mailto:[EMAIL PROTECTED] on Monday, September 19, 2005 10:53 AM said: I think that it should be a stand alone class. The Customers class could instantiate the needed number of Customer objects and the methods of the Customers class could affect each Customer object. I'm stuck on how I convert 'SELECT id, name FROM customers WHERE id nn' into the needed number of Customer objects. Here's an attempt: class Customers { var $customers = array(); function get_customers($sql) { // instantiate db object $db = new DB::singleton(); // get results of $sql $results = $db-execute($sql); foreach($results as $v) { // instantiate one Customer object $tmp = new Customer; // populate it with data $tmp-id = $v['id']; $tmp-name = $v['name']; // store it in array $this-customers[] = $tmp; } } function delete_customers() { // loop through array of customer objects ... foreach($this-customers as $customer_obj) { // ... deleting each customer one at a time $customer_obj-delete_customer(); } } } Thanks, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
Rats. Looks like you can't encapsulate DOM objects in your own classes. I tried this and the browser 'view source' shows a completely empty document. ?php $x = new MyDom(); $x-createScriptElement('howdy.js'); class MyDom { function MyDom() { $dom = new DOMDocument('1.0', 'iso-8859-1'); return $this; } function createScriptElement($inScriptPath) { $script= $this-dom-createElement('script',''); $script-setAttribute('language', 'javascript'); $script-setAttribute('src', 'howdy.js'); $this-dom-appendChild($script); echo $this-dom-saveXML(); } } ? If the element adding code is in the same function as the dom create, it works ?php $x = new MyDom(); class MyDom { function MyDom() { $dom = new DOMDocument('1.0', 'iso-8859-1'); $script= $dom-createElement('script',''); $script-setAttribute('language', 'javascript'); $script-setAttribute('src', 'howdy.js'); $dom-appendChild($script); echo $dom-saveXML(); return $this; } } ? Also if the DOM object is declared outside the class, and class functions access it as a global it works ?php $dom = new DOMDocument('1.0', 'iso-8859-1'); $x= new MyDom(); $x-createScriptElement('howdy.js'); class MyDom { function MyDom() { return $this; } function createScriptElement($inScriptPath) { global $dom; $script= $dom-createElement('script',''); $script-setAttribute('language', 'javascript'); $script-setAttribute('src', $inScriptPath); $dom-appendChild($script); echo $dom-saveXML(); } } ? Would be nice if you could encapsulate it though... You can probably add an empty text node to the script tag, or a text node consisting of a single space, or something like that, to make it use the long form. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: RSS creator class
Hello, on 09/19/2005 11:16 AM David Robley said the following: Wondering if anyone knows of a PHP class or other PHP tool for creating RSS/XML data which gracefully handles 'strange' characters such as M$ Word's delightful 'smart quotes'. I've found a couple so far, libRSS (by Jan Pieper) and ContentFeeder 2.0, but neither deals very well with the plethora of rubbish that seems to issue from Word. These seem to be mainly in the range (but not all of the range) ASCII 128 - 159 You may want to try this class. It can generate XML/RSS documents in any encoding you want. It may also convert iso-8859-1 to utf-8 and vice-versa when generating the XML documents, but if you already have the text in the target encoding that you want to use, you do not need the class to convert anything: http://www.phpclasses.org/rsswriter You also need this: http://www.phpclasses.org/xmlwriter -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can not re-use a object
I have try to use the same $db and to create a new one... Are you trying to use the $db object inside of another function later in the code? If so you'll need to use $GLOBALS['db'] instead. Sorry, this is the only thing I can think of with your description Have you tried a simple test program that does nothing more than execute your example below 2 or more times? ...well, wait, now I did have an issue where the constructor of an object was not being executed while mmcache was running. Do you run mmcache or any other code caching mechanism? (phpinfo() would tell you if you're not sure) Good luck! On Sep 19, 2005, at 6:26 AM, [EMAIL PROTECTED] wrote: Hi! Sorry about the bad english :-[ I try to re-use an object that manage the mysql connections (it is code from sugarcrm) $db = new PearDatabase(); $var = ' . $user_id .'; $pregunta = SELECT user_name FROM users WHERE id = $var; $resultado = $db-query($pregunta, true, Error filling in user array: ); $row = $db-fetchByAssoc($resultado); $user_name= $row['user_name']; if i try a new query (can be the same one or an other one), i become 0 as result and no error message I have try to use the same $db and to create a new one, i have try to close the descriptor Thanks for help pascal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Suggestions for class design
On Mon, 2005-09-19 at 14:00, Mikey wrote: Jay Blanchard wrote: [snip] Well, yes I think it does, but what I'm missing is how this new object interacts with the original one if it does at all. And what would I call it? 'Multiple_Customers'? Or.. perhaps just 'Customers'! :) Do I extend the Customer class or is it a stand alone class? [/snip] I think that it should be a stand alone class. The Customers class could instantiate the needed number of Customer objects and the methods of the Customers class could affect each Customer object. +1 for this idea, it is a method I have used on countless projects and works very well. Mikey -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Suggestions for class design
Chris W. Parker wrote: snip class Customer { var $id; var $name; snip snip function get_customer() { snip snip $this-name = $customer['name']; } snip Where I get tripped up is when I realize I'll need to at some point get more than one customer at a time and thus I want to add a method called 'get_customers()'. snip Hi Chris Assuming that you have some procedural code, could you not create an array of Customer objects? I am not sure what argument would be passed to the get_customer function as you do not have an argument in the function definition, but if it was perhaps the customer name, you coud have something like : /*Procedural code*/ $get_customer_names = 'SELECT ... FROM WHERE customer ADDRESS LIKE '; $customer_name_result_set = $db_connection-query($get_customer_names); for($i=0; $i $customer_name_result_set-num_rows; $i++) { $customer_name_result_record = $customer_name_result_set-fetch_row(); $customers[$i] = new Customer; $customers[$i]-get_customer($customer_name_result_record[0]); } That's how I would do it, at any rate (which is probably no recommendation ;) ). Regards Rory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Javscript embedding problem
Iggep wrote: countdown.js looks like this: script type=\text/javascript\ Its a JavaScript file, not an HTML fragment file. Don't put any HTML in it. -- David Dorward http://blog.dorward.me.uk/ http://dorward.me.uk/ Home is where the ~/.bashrc is -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Installing under IIS6.0
Hello, all - This is a subject that I've seen pop up on the list a few times, but not in great detail about setting up PHP under IIS 6.0. What I'm trying to achieve here is to install PHP to process PHP code embedded inside of HTML pages. Under Apache, I'd just add .html to my AddType directive and call it good. I know I'd sacrafice some speed for a bit of functionality (and bad code), but that's a sacrafice that I need to make here. I've got PHP set up to the point where it will process files ending in .php, but I want to blanket the processing of PHP code under IIS in the same manner in which I blanket PHP code with Apache. If anyone has any suggestions, other than reading PHP's manual which I've read several times which does not cover this, I would greatly appreciate it. Thanks -dant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Suggestions for class design
Chris W. Parker wrote: Let's take for example a class called 'Customer' that (obviously) manipulates customers in the database. Here is a very basic Customer class. (Data validation and the like are left out for brevity.) [snip] Where I get tripped up is when I realize I'll need to at some point get more than one customer at a time and thus I want to add a method called 'get_customers()'. Since an object should be a single instance of something (e.g. ONE customer) how do I justify adding the method 'get_customers()'? Or better yer, how do I properly add a method like that? (A method where instead of using a SQL statement to return ONE customer's data I instead return a record set with more than one customer.) [snip] Basically you're implementing DAO's (Data Access Objects), similar to what an ORM (Object Relational Mapper) tool would do for you. There are lots of different approaches for implementing DAO's, but personally I prefer to use a DAO class that represents one entity in my database (in your example, the Customer), and then have another separate class which is responsible for data operations on my DAO (the peer class). (This is the approach that many existing ORM tools use, both in the PHP and Java worlds.) In other words, Customer is only used to access the data that has been retrieved, but Customer itself doesn't have any methods for retrieving, updating, deleting, or saving. The CustomerPeer class handles all the data operations on Customer. If you want a particular Customer instance, you ask the peer to retrieve it for you, and it returns the appropriate object. If you want to save changes to a Customer, you retrieve the right instance, set its attributes, then give it back to the peer class which handles the database interaction. So, the Customer class is completely ignorant of the database, and is only concerned with giving you access to the data that is related to that Customer (and any other app specific methods that it makes since for the Customer class to handle). The advantage to using this approach is that you can easily have your peer class return an array of Customer objects, each one representing only one customer. Chris W. Parker wrote: Well, yes I think it does, but what I'm missing is how this new object interacts with the original one if it does at all. And what would I call it? 'Multiple_Customers'? Or.. perhaps just 'Customers'! :) Do I extend the Customer class or is it a stand alone class? As stated, I wouldn't recommend creating a new class to hold the Customers. Just use a normal PHP array of Customer objects. In your spare time, take a look at Propel (http://propel.phpdb.org/), an ORM for PHP5. I wouldn't suggest trying to introduce something like this in the middle of an existing project, but consider toying around with it for a future project. I used this for my last application with great success. It used 20 DAO's, similar to your Customer object, and Propel saved me a lot of tedious work in implementing all of the data-related methods+getters/setters for these 20 objects. If you have any questions about it feel free to drop me a line or check out the Propel mailing list which is very helpful. HTH... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Suggestions for class design
Hello, on 09/19/2005 02:33 PM Chris W. Parker said the following: Let's take for example a class called 'Customer' that (obviously) manipulates customers in the database. Here is a very basic Customer class. (Data validation and the like are left out for brevity.) This is a basic object persistence problem. (Unless I've already got some major design flaws I think we should be good to go.) Where I get tripped up is when I realize I'll need to at some point get more than one customer at a time and thus I want to add a method called 'get_customers()'. Yes, there is a problem. You are trying to retrieve objects into memory before they exist. It makes more sense that you retrieve objects using a factory class. That is the approach of Metastorage. You may want to take a looka at Metastorage before you reinvent the wheel. Metastorage is an persistent object class generator tool that lets you design your persistent object classes using a simple XML format that describes the classes, variables, validation rules, relationships and any functions that you may need to manipulate your objects. Besides the persistent object classes, it also generates a factory class that takes care creating new objects from scratch or retrieve them from the database. The factory class makes sure that each object does not exist more than once in memory. When you want to retrieve a collection of objects of the same class. You just add a function to the factory class to retrieve such objects, instead of calling the actual class of the objects your are retrieving. You can also retrieve a collection of objects related to an object right from its class, for instance retrieving children objects of given parent object. In that case you would add a function to the parent object class, despite internally Metastorage implements that using calls to the factory class, which is itself a singleton. Anyway, if you want to know more about Metastorage, you may find more information here: http://www.meta-language.net/metastorage.html There is a tutorial here: http://www.meta-language.net/metastorage-tutorial.html Some screenshots of the Web interface: http://www.meta-language.net/screenshots.html -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
$dom = new DOMDocument('1.0', 'iso-8859-1'); Shouldn't this be $this-dom = new DOMDocument('1.0', 'iso-8859-1'); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
On Sep 19, 2005, at 3:26 PM, Vance Rodriguez wrote: I am used to seeing global class variables initialized in the class level if they are available to the class's $this statement. ?php $x = new MyDom(); $x-createScriptElement('howdy.js'); class MyDom { protected $dom; function __construct() { $this-dom = new DOMDocument('1.0', 'iso-8859-1'); } function createScriptElement($inScriptPath) { $script= $this-dom-createElement('script',''); $script-setAttribute('language', 'javascript'); $script-setAttribute('src', 'howdy.js '); $this-dom-appendChild($script); echo $this-dom-saveXML(); } } ? On Sep 19, 2005, at 3:35 PM, comex wrote: $dom = new DOMDocument('1.0', 'iso-8859-1'); Shouldn't this be $this-dom = new DOMDocument('1.0', 'iso-8859-1'); ? That didn't work either. tried a few other things as well and it looks like PHP forces you to define DOM documents in one hideous monolithic code block without any of the encapsulation benefits classes provide. Not sure if this intentional due to security issues or if it's a bug. Anyone think of a reason why it would be necessary to prohibit DOM object embedding in a class? Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] replace
Hi all if I have an array of chars to be replaced array(1,2,3,4,5); and an arry of chars to replace with array(a,b,c,d,e) what function do I need to replace all chars from one arry to the other that are found in the var $contents Thanks M -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace
I hope this is what you were looking for: $contents = Numbers 1, 2, 3, 4 and 5 will be replaced with A, B, C, D, and E; $searcharr = array(1, 2, 3, 4, 5); $replacearr = array(A, B, C, D, E); $newcontents = str_replace($searcharr, $replacearr, $contents); echo $newcontents; Numbers A, B, C, D and E will be replaced with A, B, C, D, and E Good luck! -TG = = = Original message = = = Hi all if I have an array of chars to be replaced array(1,2,3,4,5); and an arry of chars to replace with array(a,b,c,d,e) what function do I need to replace all chars from one arry to the other that are found in the var $contents Thanks M ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with PHP after MySQL Upgrade
Here's the issue. I use MySQL as my database backend. I used to have php running fine and I used phpMyAdmin to do any admin functions I needed to on MySQL. I recently upgraded to MySQL 5.x and ever since I've gotten the following error messages. When I try to use extension=php_mysqli.dll This error follows The procedure entry point myslq_stmt_bind_param could not be located in the dynamic link library LIBMYSQL.DLL Then I the following warning: PHP Startup: Unable to load dynamic library 'c:\Program Files\Apache Group\Apache2\PHP\ext\php_mysqli.dll' - The specified procedure could not be found. When I try to use php_mysql.dll I get the following errors. The procedure entry point mysql_thread_end could not be located in the dynamic link library LIBMYSQL.DLL PHP Startup: Unable to load dynamic library 'c:\Program Files\Apache Group\Apache2\PHP\ext\php_mysql.dll' - The specified procedure could not be found. I've uninstalled and reinstalled Apache, PHP, and MyPHPAdmin - and I still get no love. Like I said, worked great before I upgraded to MySQL 5.x -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Suggestions for class design
Michael Sims mailto:[EMAIL PROTECTED] on Monday, September 19, 2005 12:04 PM said: Basically you're implementing DAO's (Data Access Objects), similar to what an ORM (Object Relational Mapper) tool would do for you. [snip] Thanks for the info, and I'll check out the Propel site a little later, but this is basically what I was saying I don't understand. I'd appreciate some actual code recommendations as I have a hard time understanding the abstract descriptions of how objects should work and be designed. Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
Ken Tozier wrote: Rats. Looks like you can't encapsulate DOM objects in your own classes. I tried this and the browser 'view source' shows a completely empty document. ?php $x = new MyDom(); $x-createScriptElement('howdy.js'); class MyDom { function MyDom() { $dom = new DOMDocument('1.0', 'iso-8859-1'); return $this; } function createScriptElement($inScriptPath) { $script= $this-dom-createElement('script',''); $script-setAttribute('language', 'javascript'); $script-setAttribute('src', 'howdy.js'); $this-dom-appendChild($script); echo $this-dom-saveXML(); } } ? Made a few changes to it as follows and it works perfectly here (PHP 5.0.5, Gentoo Linux): ?php $x = new MyDom(); $x-createScriptElement('howdy.js'); print($x-saveXML()); class MyDom { private $dom; /* __construct() = PHP5 constructor */ function __construct() { $this-dom = new DOMDocument('1.0', 'iso-8859-1'); /* No need to return $this from a constructor */ } function createScriptElement($scriptPath) { $script = $this-dom-createElement('script', ''); $script-setAttribute('type', 'text/javascript'); $script-setAttribute('src', $scriptPath); $this-dom-appendChild($script); /* Doesn't make sense for a createScriptElement() method to also print out the XML, so I made a separate method and called that from the mainline code. */ } function saveXML() { return $this-dom-saveXML(); } } ? -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers .vs javascript location.href
bruce wrote: i'd already asked/explained the error. to reiterate, the error i'm getting is the error that's generated when you try to use the php 'header' function, and it throws a warning/error regarding 'headers already being sent...' If you're absolutely certain that your script produces no output prior to the point where you call header(), then you might want to check to see whether an error is being generated - with display_errors enabled, these are included in the output stream. Also, just copy/paste your exact error here, and also include the lines indicated in the message (and a few lines before/after). I bet someone on this list can spot the problem. Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Suggestions for class design
Chris W. Parker [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Jay Blanchard mailto:[EMAIL PROTECTED] on Monday, September 19, 2005 10:40 AM said: [snip] Where I get tripped up is when I realize I'll need to at some point get more than one customer at a time and thus I want to add a method called 'get_customers()'. [/snip] Why, at any point, would you need to get more than one customer? Good question. When I need more than one customer is when I'm displaying them all on an administration page. Maybe a better example class would be Products. One individual product is displayed on the product's detail page, but in the search results I'd normally be using the same Product class to display all the results which forces me to create a 'get_products()' method. --- The signs don't seem to show up on this reply, sorry. Anyway, I have often found the need to make an object and a collection of the same kind of objects. A Customers class containing Customer items, Products and Product. Usually, the collections all look quite the same, they have the Add (which gives me a brand new initialized item object) , Find (which returns another instance of the Customers class, this with a subset of the whole collection), Get (returns and individual item based on a key), Delete (you cannot ask an object to delete itself while you are having a reference to it), Update (call the Update method of the modified items), then, if the language allows, a means to iterate over it and posibly some sort alternatives. Beware, though, that this sounds nice and proper except when the collection starts loading and taking up memory. Then you can handle several strategies, the first is 'load as you go' or 'on demand'. If nobody asks for it, don't load it. Then, you can load the properties on demand as well. You might only load the primary keys first, to be able to enumerate them and then load the rest of the properties when the get_() function is called. Actually, from an SQL standpoint, it is better to subdivide your fields into those which are used most often, and have them loaded as a group, then several sets of specific fields, groups that usually go together (like an address record, if the street is accessed, there is a good change that the zip will also be accessed, so, load them both when either one is read. Several internal flags should keep track of which set of fields are loaded for each set. Sounds terrible? Yes, it is. It is much faster to rely on the SQL server to handle most of the job of these collections. If you are just sequentially fetching records to show on a listing, it is easier to let them come from the database, a record at a time, and send it right to the client, using and reusing the memory of the resultset over and over. Much faster than loading them in either an array or a collection and then showing them from there. Specially if using them in an environment like a web server where the connection is not persistent and whatever gets loaded in response to a page request gets lost after that is handled. They are much more usefull in batch processes, where you can hold of to that information for quite a while, and it is worth to have it handy. But we don't do that kind of processes any longer these days. Satyam One answer is that all customers or a group of customers will need to be updated/edited with the same information. Therefore you need a seperate class for multiple customers which could then be extended by group. A group of customers is a seperate object. Make sense? Well, yes I think it does, but what I'm missing is how this new object interacts with the original one if it does at all. And what would I call it? 'Multiple_Customers'? Or.. perhaps just 'Customers'! :) Do I extend the Customer class or is it a stand alone class? Thanks, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Unserialize Errors
James Thomas Richardson wrote: Hello all, I'm curious to know if there are stability issues with the un/serialize functions. I've my code, I serialize a multidimensional array to disk and when I read it in later, 20% of the time I get errors like: Notice: unserialize(): Error at offset 2137774 of 2137781 bytes $save_str= base64encode($your_str); when retrieving $retrieve_str= base64decode($string); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Suggestions for class design
From what I understand is you need a data objects class. Use a generic class such as PEAR's DB_DataObject (http://pear.php.net/package/DB_DataObject). All you have to do is give the table name and the class for example would be in our case DB_DataObject_Customer And then querying the table would be in a line such as [code] $customer_data=new DB_DataObject_Customer(); $customer-get, -insert,-find, -update and the other goodies given that you supply the right parameters. [/code] HTH.
[PHP] this may be a daft question but.....defining indexes
Hi This may be a daft question but I keep getting notices on undefined indexes Is there a way to define them prior to use similar to.. $global $myvariable; Can you show me examples of how to do this with cookies/arrays? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] this may be a daft question but.....defining indexes
This may be a daft question but I keep getting notices on undefined indexes Is there a way to define them prior to use similar to.. $global $myvariable; Can you show me examples of how to do this with cookies/arrays? $array = array( ); and with a class you can use class Test { var $variable1; var $variable2; } Hope this helps Tjoek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Installing under IIS6.0
I've got PHP set up to the point where it will process files ending in .php, but I want to blanket the processing of PHP code under IIS in the same manner in which I blanket PHP code with Apache. If anyone has any suggestions, other than reading PHP's manual which I've read several times which does not cover this, I would greatly appreciate it. I wrote a little 'hack' to mimic modrewrite for IIS. When you get a 404 error page in IIS, you get the URL of the originally requested page in the $_SERVER['QUERY_STRING'] variable. So by creating a custom 404 error page with this knowledge you can mimic the basic functionality of modrewrite: ?php /* Simple PHP script that imitates mod_rewrite for IIS 6.0 Set this script to be your 404 error document in the folder where you want mod_rewrite to be enabled Your rule can contain regular expressions in the Perl 5 syntax (PCRE). You can use references in your target ($1, $2, etc) to refer back to parts of your rule. */ $rule = /(.*?)\/content\/([a-zA-Z0-9]+)\/([0-9]+)/m; // Original URL that is typed in the browser $target = /oilpowered.com/index.php?type=$2id=$3; // Redirect to the new URL. Only relative URLs! $qs = $_SERVER['QUERY_STRING']; $url = substr( $qs, strpos( $qs, ; )+1 ); // TODO: $page - preg_replace() in the if clause, to save one regexp? if( preg_match( $rule, $url ) 0 ) { $page = preg_replace( $rule, $target, $url ); header( Referer: . $_SERVER['HTTP_REFERER'] ); header( Location: . $page ); } ? Hope this helps, Tjoek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] this may be a daft question but.....defining indexes
This may be a daft question but I keep getting notices on undefined indexes I'm sorry to tell you, but this implies bad programming-practice. ;) First off: Leveling the error_reporting in the php-ini is NOT a good idea! Have you ever tested osCommerce with error_reporting set to E_ALL? You better don't! So get used to write your applications in error_reporting E_ALL, because this will inform you of every not properly intialized var you are using. Back to the index-problem: The best way to check the indizes is: $p = isset($myArray['this_index_doesnt_even_exist']) ? $myArray['this_index_doesnt_even_exist'] : null; This will check if the index in the given array exists: If, the value will be assigned to the var $p, else null will be returned, thus $p holding null (or any other value you want to assign per default). This will prevend error-output. For more information read the isset()-entry in the official php manual. However, if you are using a third party app and want to get rid of this annoying messages, you can tell php not to output E_NOTICE or E_WARNING levelled messages. You can do this by editing the php.ini-parameter error_reporting. But basically, this is something you should never ever do. Your code should run clean even with error_reporting set to E_ALL. Best regards Thorsten Suckow-Homberg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] REGEX Help Please
On Monday 19 September 2005 09:03 am, Shaun wrote: Hi, I am trying to implement a regular expression so that I have a number between 0.00 and 1.00. the following works except I can go up to 1.99 $regexp = /^[0-1]{1}.[0-9]{2}/; Can anyone help here please? Thanks $regexp = /^(0\.[0-9]{2}|1\.00)/; that should work :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
Thanks Jasper Works perfectly on my Mac now as well. Ken On Sep 19, 2005, at 4:58 PM, Jasper Bryant-Greene wrote: ?php $x = new MyDom(); $x-createScriptElement('howdy.js'); print($x-saveXML()); class MyDom { private $dom; /* __construct() = PHP5 constructor */ function __construct() { $this-dom = new DOMDocument('1.0', 'iso-8859-1'); /* No need to return $this from a constructor */ } function createScriptElement($scriptPath) { $script = $this-dom-createElement('script', ''); $script-setAttribute('type', 'text/javascript'); $script-setAttribute('src', $scriptPath); $this-dom-appendChild($script); /* Doesn't make sense for a createScriptElement() method to also print out the XML, so I made a separate method and called that from the mainline code. */ } function saveXML() { return $this-dom-saveXML(); } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Suggestions for class design
The simplest way to solve this problem is as follows: - Have your Customer class hold only attributes for a customer. This class would only have getter and setter methods. In the Java world, this is referred to as a JavaBean. - Then, have a DAO class that does your data access functions. Here is a sample DAO class: class CustomerDAO { function getCustomer(..) { ... //return a customer } function getCustomers(..) { ... // return a collection of customers } function saveCustomer(..) { ... } } Hope this helps. -- Anas Mughal On 9/19/05, Chris W. Parker [EMAIL PROTECTED] wrote: Hello, Every time I write some classes I always come across the same fundamental problem that I haven't figured out how to solve/approach yet. I'm not exactly sure how to put it into words simply but here goes... Let's take for example a class called 'Customer' that (obviously) manipulates customers in the database. Here is a very basic Customer class. (Data validation and the like are left out for brevity.) class Customer { var $id; var $name; function add_customer() { // create sql statement $sql = INSERT INTO ...; // create db connection $db = DB::singleton(); // execute SQL $db-execute($sql); } function delete_customer() { // create sql statement $sql = DELETE FROM ...; // create db connection $db = DB::singleton(); // execute SQL $db-execute($sql); } function get_customer() { // create sql statement $sql = SELECT ... FROM ...; // create db connection $db = DB::singleton(); // execute SQL $customer = $db-execute($sql); // populate object variables $this-id = $customer['id']; $this-name = $customer['name']; } } (Unless I've already got some major design flaws I think we should be good to go.) Where I get tripped up is when I realize I'll need to at some point get more than one customer at a time and thus I want to add a method called 'get_customers()'. Since an object should be a single instance of something (e.g. ONE customer) how do I justify adding the method 'get_customers()'? Or better yer, how do I properly add a method like that? (A method where instead of using a SQL statement to return ONE customer's data I instead return a record set with more than one customer.) The class in its current state can't handle data like that so I have to then rethink the design and a new object variable called $customers where I store the record set that is in return accessed directly by the calling page itself. With the way I'm working with these objects now they seem less like objects and more like an organized collection of functions. I'd appreciate some actual code recommendations as I have a hard time understanding the abstract descriptions of how objects should work and be designed. Thanks, Chris. Thanks! Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anas Mughal
Re: [PHP] Re: Using DOM object, how?
Even better, you can just extend the DOMDocument class, which is perfect, since I'm basically just adding convenience methods. Thanks all for your help Ken ?php $x = new MyDom(); $x-createScriptElement('howdy.js'); $x-createCSSLinkElement('howdy.css'); $x-createStyledDivElement('bugColumnTitle', I'm a styled piece of text!); print($x-saveXML()); class MyDom extends DOMDocument { function createScriptElement($inPath) { $new_elem = $this-createElementAndAppend('script', null); $new_elem-setAttribute('type', 'text/javascript'); $new_elem-setAttribute('src', $inPath); } function createCSSLinkElement($inPath) { $new_elem = $this-createElementAndAppend('link', null); $new_elem-setAttribute('href', $inPath); $new_elem-setAttribute('rel', 'stylesheet'); $new_elem-setAttribute('media', 'screen'); } function createStyledDivElement($inStyle, $inData) { $new_elem = $this-createElementAndAppend('div', $inData); $new_elem-setAttribute('class', $inStyle); } function createElementAndAppend($inType, $inData) { // setting null inData to an empty string forces a close tag which is what we want $elem_data= ($inData == null) ? '' : $inData ; $new_elem= $this-createElement($inType, $elem_data); $this-appendChild($new_elem); return $new_elem; } } ? On Sep 19, 2005, at 6:13 PM, Ken Tozier wrote: Thanks Jasper Works perfectly on my Mac now as well. Ken On Sep 19, 2005, at 4:58 PM, Jasper Bryant-Greene wrote: ?php $x = new MyDom(); $x-createScriptElement('howdy.js'); print($x-saveXML()); class MyDom { private $dom; /* __construct() = PHP5 constructor */ function __construct() { $this-dom = new DOMDocument('1.0', 'iso-8859-1'); /* No need to return $this from a constructor */ } function createScriptElement($scriptPath) { $script = $this-dom-createElement('script', ''); $script-setAttribute('type', 'text/javascript'); $script-setAttribute('src', $scriptPath); $this-dom-appendChild($script); /* Doesn't make sense for a createScriptElement() method to also print out the XML, so I made a separate method and called that from the mainline code. */ } function saveXML() { return $this-dom-saveXML(); } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
On Monday 19 September 2005 12:25 pm, Ken Tozier wrote: I would be extremely careful with this.. because sadly PHP's XML generator uses the short form whenever possible. script / will *NOT* work in most browsers such as FireFox. script/script Will work. Thanks for the heads up. Looks like if you define the tag like $script= $dom-createElement('script',''); -- empty string It tacks on an end tag. The way that I've been doing this thus far is using XSL. If you use the DOMDocument::loadXML() function and it has anything like that. it will convert it to short form. I design the back XML using Dom calls then throw a xsl at it to spit out my page. very nice clean code that's separated from style. So far, just playing. But ultimately I'd like to generate the whole page using dom calls. It seems much cleaner for what I'm doing than creating a whole bunch of large functions that do nothing more than echo prestyled html. Is this clean enough? :) minimum for one of my pages that uses SQL: ?php include(Document.php); // a DOM Object is auto generated along with an XPath object to go with it. // $Document-gDom() and $Document-gXPath() to gain access to them. $Document = new Document(rootNode); try { $Document-gDb()-connect(Database::SQLITE,../database.db); } catch (DBConnectFailed $dbCF) { die(Failed to connect to the Database.); } $Document-setTitle(This is the title); // Use $Document-setStylesheet(); to set a stylesheet, // defaults to index.xsl. // Here is where you put the page specific code. // XML data nodes used in the XSL template. // This outputs the header(); and the DocType. $Document-outputHeader(); echo $Document; // This will load the XSL document, apply it, and return // The page to be echo'd ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
On Monday 19 September 2005 06:04 pm, Ken Tozier wrote: Not a bad Idea. You might like this function I made then ;) function createElement($parentNode, $name, $elements=array()) { $node = $this-Dom-createElement($name); for ($x=0; $x count($elements); $x++) { if ($elements[$x][0] == .) { $node-nodeValue = $elements[$x][1]; } else { $node-setAttribute($elements[$x][0], $elements[$x][1]); } } $parentNode-appendChild($node); } general all purpose element creator for those of us that hate to call setAttribute a hundred times ;) Even better, you can just extend the DOMDocument class, which is perfect, since I'm basically just adding convenience methods. Thanks all for your help Ken ?php $x = new MyDom(); $x-createScriptElement('howdy.js'); $x-createCSSLinkElement('howdy.css'); $x-createStyledDivElement('bugColumnTitle', I'm a styled piece of text!); print($x-saveXML()); class MyDom extends DOMDocument { function createScriptElement($inPath) { $new_elem = $this-createElementAndAppend('script', null); $new_elem-setAttribute('type', 'text/javascript'); $new_elem-setAttribute('src', $inPath); } function createCSSLinkElement($inPath) { $new_elem = $this-createElementAndAppend('link', null); $new_elem-setAttribute('href', $inPath); $new_elem-setAttribute('rel', 'stylesheet'); $new_elem-setAttribute('media', 'screen'); } function createStyledDivElement($inStyle, $inData) { $new_elem = $this-createElementAndAppend('div', $inData); $new_elem-setAttribute('class', $inStyle); } function createElementAndAppend($inType, $inData) { // setting null inData to an empty string forces a close tag which is what we want $elem_data= ($inData == null) ? '' : $inData ; $new_elem= $this-createElement($inType, $elem_data); $this-appendChild($new_elem); return $new_elem; } } ? On Sep 19, 2005, at 6:13 PM, Ken Tozier wrote: Thanks Jasper Works perfectly on my Mac now as well. Ken On Sep 19, 2005, at 4:58 PM, Jasper Bryant-Greene wrote: ?php $x = new MyDom(); $x-createScriptElement('howdy.js'); print($x-saveXML()); class MyDom { private $dom; /* __construct() = PHP5 constructor */ function __construct() { $this-dom = new DOMDocument('1.0', 'iso-8859-1'); /* No need to return $this from a constructor */ } function createScriptElement($scriptPath) { $script = $this-dom-createElement('script', ''); $script-setAttribute('type', 'text/javascript'); $script-setAttribute('src', $scriptPath); $this-dom-appendChild($script); /* Doesn't make sense for a createScriptElement() method to also print out the XML, so I made a separate method and called that from the mainline code. */ } function saveXML() { return $this-dom-saveXML(); } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Size limits of mysql
Am 2005-09-14 07:37:49, schrieb [EMAIL PROTECTED]: Hi All, I have a simple database with one table with about 6 fields, just holding filenames, filepaths and sizes. Very basic audit for management here. Problem is I import a load of records into this table and it seems to only allow me to put in about 550,000 records.Maybe it's just mysqlFront that can only display that many records or something. Anybody know of a size or record limit in mysql tables? The actual size of the database is about 70Mb. Not huge really. Do you have set limit to your database (MySQL)? I have a database (PostgreSQL) of 130 GByte and the bigest table has 60 GByte with arround 40 colums and more then 8 million rows. Thanks Matthew Greetings Michelle -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSM LinuxMichi 0033/3/8845235667100 Strasbourg/France IRC #Debian (irc.icq.com) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using DOM object, how?
On Sep 19, 2005, at 7:19 PM, Stephen Leaf wrote: On Monday 19 September 2005 06:04 pm, Ken Tozier wrote: Not a bad Idea. You might like this function I made then ;) function createElement($parentNode, $name, $elements=array()) { $node = $this-Dom-createElement($name); for ($x=0; $x count($elements); $x++) { if ($elements[$x][0] == .) { $node-nodeValue = $elements[$x][1]; } else { $node-setAttribute($elements[$x][0], $elements[$x] [1]); } } $parentNode-appendChild($node); } general all purpose element creator for those of us that hate to call setAttribute a hundred times ;) That's pretty slick. I'll have to steal it : ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Php converting jpegs to pjpegs: Help
Can someone tell me why, or better yet how I can make sure that PHP doesn't turn my non-progressive jpegs to pjepgs on upload? Using the code below, if I upload a non-progressive jpeg, PHP tells me that the file uploaded successfully, and the file is of type pjpeg. How can I avoid this problem? MY CODE*** html head titleUntitled Document/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body ?php // specify the file to write to $filename = 'portfolio.xml'; //specify the content to write $somecontent = \r\nportfolioItemimage.$HTTP_POST_FILES['userfile']['name']./image /portfolioItem; //portfolioItemimageimages/bride10.jpg/image/portfolioItem // specify the directory where the uploaded file should end up //$path = 'images/' ; $path = 'PHP_Library/'; // specify the filetypes allowed $allowed = array('image/gif','image/pjpeg','image/jpeg','image/png'); // specify the max filesize in bytes $max_size = 20; ///checks to see if file field is not null if(isset($HTTP_POST_FILES['userfile'])) { if(is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { if($HTTP_POST_FILES['userfile']['size'] $max_size) { if(in_array($HTTP_POST_FILES['userfile']['type'],$allowed)) { if(!file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { if(@rename($HTTP_POST_FILES['userfile']['tmp_name'],$path.$HTTP_POST_FILES[' userfile']['name'])) { if (is_writable($filename)) { if (!$handle = fopen($filename, 'a')) { echo Cannot open file ($filename); exit; } if (fwrite($handle, $somecontent) === FALSE) { echo Cannot write to file ($filename); exit; } echo The file '.$HTTP_POST_FILES['userfile']['name'].' was uploaded successfully; fclose($handle); } //fopen($filename, 'a'); //fwrite ($filename, $somecontent); //fclose($handle); $html_output = 'br'; $html_output .= 'File Name: '.$HTTP_POST_FILES['userfile']['name'].'br'; $html_output .= 'File Size: '.$HTTP_POST_FILES['userfile']['size'].' bytesbr'; $html_output .= 'File Type: '.$HTTP_POST_FILES['userfile']['type'].'br'; //echo this is the name.['name']; $image = $HTTP_POST_FILES['userfile']['name'] ; }else{ $html_output = 'Upload failed!br'; if(!is_writeable($path)) { $html_output = 'The Directory '.$path.' must be writeable!br'; }else{ $html_output = 'an unknown error ocurred.br'; } } }else{ $html_output = 'The file already existsbr'; } }else{ $html_output = 'Wrong file typebr'; } }else{ $html_output = 'The file is too bigbr'; } } }else{ $html_output = 'form method=post enctype=multipart/form-data action='.$_SERVER['PHP_SELF'].''; $html_output .= 'input type=file name=userfile'; $html_output .= 'input type=submit value=upload'; $html_output .= '/form'; } echo 'htmlheadtitleUploader/title/headbody'; echo $html_output; echo '/body/html'; ? /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php converting jpegs to pjpegs: Help
jnoyes wrote: Can someone tell me why, or better yet how I can make sure that PHP doesn't turn my non-progressive jpegs to pjepgs on upload? Using the code below, if I upload a non-progressive jpeg, PHP tells me that the file uploaded successfully, and the file is of type pjpeg. How can I avoid this problem? In my experience this is caused by Internet Explorer, not PHP. Are you using IE to upload the files? If so, have you tried it in Firefox or another browser to see if it's any different? -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] User error handler must not modify error context
Error Message: Fatal error: User error handler must not modify error context in [FILENAME] on line 58 This error seems to occur only when I use: $old_error_handler = set_error_handler ('userErrorHandler'); The error number is pointing to this code: LINE 57: global $mywebsite; LINE 58: if ($_POST['title']) $title = $_POST['title']; LINE 59: elseif ($_GET['title']) $title = $_GET['title']; It's surprising how no one seem to have had this problem before. I've googled it already and all I've come up with are the zend source codes. I've also search the PHP mailing lists, several message boards, etc. Nothing. One code I've seen gave me a clue that it might have only occurred since I'm using PHP 4.4. My site has just been upgraded to this version. In the previous version (4.3.11), my site works just fine. Could this be a bug? If it is, how can I solve it at least until they've released a fixed for it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: about PHP
sir, this is srinivasan i have to know about the php.i.e. how can i view the php pages in windows98 PWS?.could you reply in this regard. thanking you k.srinivasan Gabor Hojtsy [EMAIL PROTECTED] wrote:Dear Srinivasan Kumar, Since your problem has nothing to do with webmastering of the php.net website, it does not belong in here Please contact php-general@lists.php.net (a mailing list) with support questions or see http://php.net/support for more support options. Regards, Gabor Hojtsy Srinivasan Kumar wrote: sir, this is srinivasan i have to know about the php.i.e. how can i view the php pages in windows98 PWS?.could you reply in this regard. thanking you k.srinivasan __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com - Yahoo! for Good Click here to donate to the Hurricane Katrina relief effort.
[PHP] core files
I am trying to copy the files needed to run a php commandline script so that I can send them to a different computer and run as a scheduled task. I do not know what I am missing but for some reason my file commands do not seem to be working. fopen does not work and so fwrite does not work either. I am on a windows machine. My script runs from my core version and it runs on a different computer with an xampplite install but for some reason I have not found the file that I am missing. Any help would be appreciated. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] headers .vs javascript location.href
On Sep 19, 2005, at 5:08 PM, Chris Shiflett wrote: bruce wrote: i'd already asked/explained the error. to reiterate, the error i'm getting is the error that's generated when you try to use the php 'header' function, and it throws a warning/error regarding 'headers already being sent...' If you're absolutely certain that your script produces no output prior to the point where you call header(), then you might want to check to see whether an error is being generated - with display_errors enabled, these are included in the output stream. Also, just copy/paste your exact error here, and also include the lines indicated in the message (and a few lines before/after). I bet someone on this list can spot the problem. Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This is just a guess here bruce, but do you have any whitespace/line breaks before the PHP code starts? If so then you are generating output before you even get to the code. If you are using a config file of any kind you'll also need to make sure it has no whitespace/ line breaks before or after the code blocks. Again: just a guess. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with PHP after MySQL Upgrade
On Sep 19, 2005, at 4:36 PM, Nathan wrote: Here's the issue. I use MySQL as my database backend. I used to have php running fine and I used phpMyAdmin to do any admin functions I needed to on MySQL. I recently upgraded to MySQL 5.x and ever since I've gotten the following error messages. When I try to use extension=php_mysqli.dll This error follows The procedure entry point myslq_stmt_bind_param could not be located in the dynamic link library LIBMYSQL.DLL Then I the following warning: PHP Startup: Unable to load dynamic library 'c:\Program Files\Apache Group\Apache2\PHP\ext\php_mysqli.dll' - The specified procedure could not be found. When I try to use php_mysql.dll I get the following errors. The procedure entry point mysql_thread_end could not be located in the dynamic link library LIBMYSQL.DLL PHP Startup: Unable to load dynamic library 'c:\Program Files\Apache Group\Apache2\PHP\ext\php_mysql.dll' - The specified procedure could not be found. I've uninstalled and reinstalled Apache, PHP, and MyPHPAdmin - and I still get no love. Like I said, worked great before I upgraded to MySQL 5.x -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'm not as familiar with PHP on windows as I am with PHP on *nix, but I can tell you that if you install a new version of MySQL without recompiling PHP, then you're using old libraries that won't work with the new version of MySQL. Unfortunately, I'm not sure how you'd get the DLL's you need since you're not compiling anything and I doubt that MySQL would provide new one's during the installation. Hopefully this gets you on your way. -Joe -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] My sql CC tool help
Hi, I am using my sql control center on windows server. I am able to extract the DB structure but not able to extract the records from the tables. Is there any way to do the same with mysql cc tool. Regards, loveneesh Bansal http://www.bsdinfotech.com/loveneesh.htm
Re: [PHP] Installing under IIS6.0
On Sep 19, 2005, at 9:45 PM, Dan Trainor wrote: Tjoekbezoer van Damme wrote: I've got PHP set up to the point where it will process files ending in .php, but I want to blanket the processing of PHP code under IIS in the same manner in which I blanket PHP code with Apache. If anyone has any suggestions, other than reading PHP's manual which I've read several times which does not cover this, I would greatly appreciate it. I wrote a little 'hack' to mimic modrewrite for IIS. When you get a 404 error page in IIS, you get the URL of the originally requested page in the $_SERVER['QUERY_STRING'] variable. So by creating a custom 404 error page with this knowledge you can mimic the basic functionality of modrewrite: ?php /* Simple PHP script that imitates mod_rewrite for IIS 6.0 Set this script to be your 404 error document in the folder where you want mod_rewrite to be enabled Your rule can contain regular expressions in the Perl 5 syntax (PCRE). You can use references in your target ($1, $2, etc) to refer back to parts of your rule. */ $rule = /(.*?)\/content\/([a-zA-Z0-9]+)\/([0-9]+)/m; // Original URL that is typed in the browser $target = /oilpowered.com/index.php?type=$2id=$3; // Redirect to the new URL. Only relative URLs! $qs = $_SERVER['QUERY_STRING']; $url = substr( $qs, strpos( $qs, ; )+1 ); // TODO: $page - preg_replace() in the if clause, to save one regexp? if( preg_match( $rule, $url ) 0 ) { $page = preg_replace( $rule, $target, $url ); header( Referer: . $_SERVER['HTTP_REFERER'] ); header( Location: . $page ); } ? Hope this helps, Tjoek Hello, and thanks for the reply, Tjoek - However, this really isn't what I'm looking for. I'm simply looking for a way to parse PHP code from within existing HTML pages, so that I can migrate a site from Apache to IIS6.0. Like I said, if I were using Apache, I would just add .html to my AddType directive, and call it good. Is it not this simple under IIS? Thanks -dant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Don't fear the Google, Dan ;-) http://www.neowin.net/forum/index.php?showtopic=369437 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] My sql CC tool help
[EMAIL PROTECTED] wrote: I am using my sql control center on windows server. I am able to extract the DB structure but not able to extract the records from the tables. Is there any way to do the same with mysql cc tool. As this question has nothing at all to do with PHP, maybe you should direct it to a MySQL mailing list: http://lists.mysql.com/ -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: about PHP
On 9/20/05, Srinivasan Kumar [EMAIL PROTECTED] wrote: sir, this is srinivasan i have to know about the php.i.e. Google is your friend! ..the best is to search/read a bit more about PHP. follow these links.. http://www.php.net/tut.php http://www.google.com/search?hl=enlr=oi=defmoreq=define:PHP how can i view the php pages in windows98 PWS?.could please be specific. write a little more, explaining what you want to do with php and your current knowledge in programming. so the others on the list can help you better to solve your issue. ~viraj. you reply in this regard. thanking you k.srinivasan Gabor Hojtsy [EMAIL PROTECTED] wrote:Dear Srinivasan Kumar, Since your problem has nothing to do with webmastering of the php.net website, it does not belong in here Please contact php-general@lists.php.net (a mailing list) with support questions or see http://php.net/support for more support options. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php