[PHP] help me in creating tables on the fly
hello friends, im currently working on creating musical forum. i need to create tables for every song uploaded on the fly to save the comments and rates entered by the viewers. im unable to create tables on the fly. can anyone know how to create tables on the fly .plz tell me . Also, can u tell me the way to how to play the song using php.. i uploaded the songs to mysql database... if u know the same kind of work anywhere in the net as tutorials and help .plza tell me the URL Thanks to all.. Suresh.P - Yahoo! India Matrimony: Find your partner now.
Re: [PHP] help me in creating tables on the fly
Suresh Pandian wrote: hello friends, im currently working on creating musical forum. i need to create tables for every song uploaded on the fly to save the comments and rates entered by the viewers. im unable to create tables on the fly. ... if I upload 1000 songs to your server then that will ammount to a 1000 tables. and a 1000 songs is nothing the whole idea of creating a table for every song is wrong and will get you into trouble (100,000 songs will crash your system), you only need one table to store all the comments for each song - and possible one extra table to store the rates for all songs. can anyone know how to create tables on the fly .plz tell me . all you need to do is generate an sql query with the CREATE TABLE syntax. and then run it the same way you would run a normal query - thsi assumes that youre database actually allows the relevant user to create tables. Also, can u tell me the way to how to play the song using php.. i uploaded the songs to mysql database... if u know the same kind of work anywhere in the net as tutorials and help .plza tell me the URL Google for 'Database design' 'Data Normalization' and stuff like that - you seem to be in need of knowledge regarding how to create a half decent database (one that wont bite you in the ass) Thanks to all.. Suresh.P - Yahoo! India Matrimony: Find your partner now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help me in creating tables on the fly
Suresh Pandian wrote: im currently working on creating musical forum. i need to create tables for every song uploaded on the fly to save the comments and rates entered by the viewers. im unable to create tables on the fly. can anyone know how to create tables on the fly .plz tell me . Also, can u tell me the way to how to play the song using php.. i uploaded the songs to mysql database... if u know the same kind of work anywhere in the net as tutorials and help .plza tell me the URL AHHH! Don't create a table for every song Have a `songs` table containing all of the songs. Something like: CREATE TABLE songs (songID INT UNSIGNED NOT NULL AUTO_INCREMENT, artist VARCHAR(50) NOT NULL, title VARCHAR(50) NOT NULL, PRIMARY KEY(songID)); (simplified) and another table `comments` like this: CREATE TABLE comments (commentID INT UNSIGNED NOT NULL AUTO_INCREMENT, songID INT UNSIGNED NOT NULL, comment TEXT NOT NULL, PRIMARY KEY(commentID), KEY(songID)); and another `ratings` like this: CREATE TABLE ratings (ratingID INT UNSIGNED NOT NULL AUTO_INCREMENT, songID INT UNSIGNED NOT NULL, rating TINYINT UNSIGNED NOT NULL, PRIMARY KEY(ratingID), KEY(songID)); That's why it's called a *relational* database. If you're using InnoDB you can even define the relations between the tables using foreign keys. Go to http://dev.mysql.com/doc/en/mysql/ and have a good read of the MySQL manual, it will be very helpful for you. Please don't just copy-paste the above table definitions, they're meant to be modified to suit your needs. I'll leave your other question to be answered by someone with experience of streaming audio from PHP, as I've never had occasion to do that. -- 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] include file to global scope
Hi, I'm using PHP 5. I have a class operation that includes php files. Is there a way to include this files to global scope? So that difined vars and functions are global accesseble? I saw that some PHP functions have a context parameter, is something like this in "eval" or "include" possible? Thanks, Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file to global scope
Claudio wrote: Hi, I'm using PHP 5. I have a class operation that includes php files. Is there a way to include this files to global scope? So that difined vars and functions are global accesseble? first off I would recommend that you 'pollute' your global scope as little as possible. secondly could you describe what you are trying to do and why exactly - stuff like this has been solved before but its hard to recommend a strategy when one doesn't know what the underlying idea/direction is that said the solution will probably involve the use of the 'global' keyword. I saw that some PHP functions have a context parameter, is something like this in "eval" or "include" possible? I think you mean then 'context' param related to functions that work with streams - this is not AFAIK related to [variable] 'scope'. also eval() sucks (unless there is no other way to do something, in which case its lovely ;-). Thanks, Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Check if an url is a jpg image
Hi, Is it possible to check if an url is a jpg image from php? Thank you for your help. Cheers, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Check if an url is a jpg image
Hi Tommy, Wednesday, October 12, 2005, 10:48:55 AM, you wrote: > Is it possible to check if an url is a jpg image from php? #1 Quick and unreliable: Check if there is a .jpg or .jpeg as the final characters of the URL string. #2 Bit more complex, very expensive: fopen() the URL, download the content to a temporary location, inspect it with native php functions like getimagesize. If your PHP config allows, you can probably perform a getimagesize directly on the URL, but I've not tried this. #3 Trickier, less expensive than #2, but balls-on accurate: fopen() the URL (after suitable validation) and grab the header (the first few KB). JPEG files are easily identified, but come in a variety of flavours. http://www.codeproject.com/bitmap/iptc.asp Cheers, Rich -- Zend Certified Engineer http://www.launchcode.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Run a php script as a separate thread/process
Thank you very much. This is what I ended up with if anyone needs it: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Hidden Form Help
Hi- I'm in a situation where I'm required to deal with a hidden form. The background details are exhausting, but the gist is: one form is auto-generated and lacks proper formatting. It was part of an open source package that DID NOT allow templating. So to keep using the application engine, but provide formatting, I created a CSS class to hide the unformatted form while displaying the formatted form. When submitting data to the database this doesn't seem to cause any issues. It accepts data based on the fieldvalues and ids. But when retrieving data to repopulate the form, what happens is that the hidden form gets the values and the displayed form does not. http://nahic.ucsf.edu/phpESP/survey.php login= Wisconsin Basically, if you complete the required field (state), fill out some random data, hit save, then select "resume" from the info page provided. You'll get back an empty form. But if you look at the code you'll see that the hidden form has the values. So I have a few questions: 1) Is there anyway to echo data from one field to the next, especially if the field (name or id) are exactly the same?? (i.e. field=state value=Wisconsin; if the field state is then repeated somewhere else on the page, can the value, Wisconsin, also be automatically repeated. 2) If yes, to the above can PHP do this and how? or is this something requiring Javascript or some other coding. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Userlogin system seems to override the if statement....
I'm new to this. So I used a tutorial to write this. But it shows "Login ok. Welcome" at once when the page loads. Here is the tutorial: http://www.ss32.x10hosting.com/ss32/files/PHP-logins.pdf There was an error processing your login. Login as: Password: Login ok. Welcome "; } ?> I don't get any further. I must be missing something, but what?? Please help. -Tore W-
[PHP] Issues with backslashes and GET data
I use a php page which is supposed to return records from a database table limited to the servername specicified in a drop down menu. A servername may contain a backslash e.g. Server1\SQL1. When this data is returned from the URL e.g. $server = $_GET['server']; The name is returned as Server1\\SQL1, so the search fails. I've tried using a regular expression to remove one of the backslashes: $server = ereg_replace("\\", "\", $server); but I can't get this to work either. Any suggestions welcome, I'm running out of ideas. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Issues with backslashes and GET data
Have you tried the stripslashes() function? That will "unescape" characters that have been escaped. On Oct 12, 2005, at 8:03 AM, Martin Selway wrote: I use a php page which is supposed to return records from a database table limited to the servername specicified in a drop down menu. A servername may contain a backslash e.g. Server1\SQL1. When this data is returned from the URL e.g. $server = $_GET ['server']; The name is returned as Server1\\SQL1, so the search fails. I've tried using a regular expression to remove one of the backslashes: $server = ereg_replace("\\", "\", $server); but I can't get this to work either. Any suggestions welcome, I'm running out of ideas. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file to global scope
> first off I would recommend that you 'pollute' your global scope as > little as possible. I agree at all! Thats my opinion, and i don't use global variables at all. The problem is, other people do. And if I need to use their code I must include it. > that said the solution will probably involve the use of the 'global' > keyword. Yes, see example files 1 and 2. This files are very simple, but shows the problem. Naturly the decision what file to include an when is complexer than that. The file2.php represents a large standalone "old" php file. Doesn't maintend by me. It works fine. The file1.php5 represents a newer application. File2 will not work, because $abc is not a global var. Ok, I could search for all declared vars and add a global to it. Thats not realy a "nice" solution. Do anyone have a better Idea? Claudio file1.php5: - - file2.php: - - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] pear.php.net
is http://pear.php.net offline? Warning: Invalid argument supplied for foreach() in /usr/local/www/pearweb/include/pear-format-html.php on line 360 Warning: Invalid argument supplied for foreach() in /usr/local/www/pearweb/include/pear-format-html.php on line 360 Warning: Invalid argument supplied for foreach() in /usr/local/www/pearweb/include/pear-format-html.php on line 360 Warning: Invalid argument supplied for foreach() in /usr/local/www/pearweb/include/pear-format-html.php on line 360 Fatal error: Call to undefined function: init_auth_user() in /usr/local/www/pearweb/include/pear-format-html.php on line 112 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: pear.php.net
Claudio wrote: > is http://pear.php.net offline? > > > Warning: Invalid argument supplied for foreach() in > /usr/local/www/pearweb/include/pear-format-html.php on line 360 > > Warning: Invalid argument supplied for foreach() in > /usr/local/www/pearweb/include/pear-format-html.php on line 360 > > Warning: Invalid argument supplied for foreach() in > /usr/local/www/pearweb/include/pear-format-html.php on line 360 > > Warning: Invalid argument supplied for foreach() in > /usr/local/www/pearweb/include/pear-format-html.php on line 360 > > Fatal error: Call to undefined function: init_auth_user() in > /usr/local/www/pearweb/include/pear-format-html.php on line 112 > Very much online, but until someone fixes the code Cheers -- David Robley People own dogs. Cats own people. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Report generators
I was looking for a report generator library and found a good one called agata. What I need (and the library does not provide) is the ability to export the generated report in doc and excel format. The library does exports the reports in openoffice Write format but this would require to post-process the generated file in order to convert it into doc. As for excel, a possible solution would be to use the CSV format but is not a good solution either. Does anybody knows any other library which exports into pdf,doc and excel formats? Thank's in advanced. Anakreon -- Three words describe our society:homo homini lupus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting php to generate a 503
[EMAIL PROTECTED] wrote: I want to write a php page that can return a 503 with some useful information. ?> Is what I've done so far - yet it doesn't work You need to elaborate or define what "works" means to you, because my first assumption is that it works just fine. What behavior are you wanting? By the way, LiveHTTPHeaders is pretty useful for examining HTTP: http://livehttpheaders.mozdev.org/ 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
[PHP] Re: Userlogin system seems to override the if statement....
- sorry my mail reader didn't indent. comments in -- I'm new to this. So I used a tutorial to write this. But it shows "Login ok. Welcome" at once when the page loads. Here is the tutorial: http://www.ss32.x10hosting.com/ss32/files/PHP-logins.pdf There was an error processing your login. }else{ ?> Login ok. Welcome "; you will end up here if $err==1 Since you set $err=1; just before the if block begins, this is as expected. You might find the section on if statements in the PHP manual has some useful examples which might make things clearer: http://uk2.php.net/if The tutorial you are following is a bit ropey to be honest if this is the dtandard of the code in it. } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Issues with backslashes and GET data
Martin Selway wrote: A servername may contain a backslash e.g. Server1\SQL1. When this data is returned from the URL e.g. $server = $_GET['server']; The name is returned as Server1\\SQL1, so the search fails. Sounds like magic_quotes_gpc is enabled. Disable it. I've tried using a regular expression to remove one of the backslashes: $server = ereg_replace("\\", "\", $server); There is a function called stripslashes() that does this. Also, you should not use a regular expression function when matching literal strings. Regular expressions are for matching patterns. Use something like str_replace(). 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] include file to global scope
Is it possible to process the file in second php instance? An only get its output? Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] pear.php.net
I know this was asked already, but I am going to ask once more... Is pear.php.net online? Here's why I ask: pear list-upgrades XML_RPC_Client: Connection to RPC server pear.php.net:80 failed. Connection refused Also, browsing to pear.php.net results in a page cannot be displayed error. Thanks! Alex Moen Operations Technology Specialist NDTC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] pear.php.net
[snip] I know this was asked already, but I am going to ask once more... Is pear.php.net online? Here's why I ask: pear list-upgrades XML_RPC_Client: Connection to RPC server pear.php.net:80 failed. Connection refused Also, browsing to pear.php.net results in a page cannot be displayed error. [/snip] Based on the overwhelming evidence I would have to say that it is offline for the moment. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include file to global scope
Claudio wrote: Is it possible to process the file in second php instance? An only get its output? yes - but its heavy to do (which ever way you do it). basically you need to either call a commandline php script via exec() (or something similar) e.g. exec('php /path/2/your/script.php'); // read the manual to // find out how to get you output/data or also go through the command line and use a tool like 'wget' to call another url e.g: exec('wget http://domain.com/script.php'); OR you could use file_get_contents() (or something similar to do what wget does directly from within php $output = file_get_contents('http://domain.com/script.php'); lots of possibilities - given what you are trying to do I doubt that any possiblity is optimal - shoehorning other applications into your own as standalone modules is an art form ;-) Claudio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pear.php.net
Jay Blanchard wrote: [snip] I know this was asked already, but I am going to ask once more... Is pear.php.net online? Here's why I ask: pear list-upgrades XML_RPC_Client: Connection to RPC server pear.php.net:80 failed. Connection refused Also, browsing to pear.php.net results in a page cannot be displayed error. [/snip] Based on the overwhelming evidence I would have to say that it is offline for the moment. we cannot rule out the possibility that Alex' IP addr has been singled out for discrimination ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] pear.php.net
> -Original Message- > From: Jochem Maas [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 12, 2005 10:03 AM > To: Jay Blanchard > Cc: 'Alex Moen'; php-general@lists.php.net > Subject: Re: [PHP] pear.php.net > > > Jay Blanchard wrote: > > [snip] > > I know this was asked already, but I am going to ask once more... Is > > pear.php.net online? Here's why I ask: > > > > pear list-upgrades > > XML_RPC_Client: Connection to RPC server pear.php.net:80 > failed. Connection > > refused > > > > Also, browsing to pear.php.net results in a page cannot be > displayed error. > > [/snip] > > > > Based on the overwhelming evidence I would have to say that > it is offline > > for the moment. > > > > we cannot rule out the possibility that Alex' IP addr has > been singled out for > discrimination ;-) > hehe... Pick on Alex day, huh? I can ping pear.php.net, but the webserver seems to be ignoring me... Maybe you're right! ;) Alex Moen Operations Technology Specialist NDTC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] pear.php.net
Problem solved... The webserver on pear.php.net is working again. Thanks to whoever fixed it! Alex Moen Operations Technology Specialist NDTC > -Original Message- > From: Alex Moen [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 12, 2005 10:09 AM > To: 'Jochem Maas' > Cc: php-general@lists.php.net > Subject: RE: [PHP] pear.php.net > > > > > -Original Message- > > From: Jochem Maas [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, October 12, 2005 10:03 AM > > To: Jay Blanchard > > Cc: 'Alex Moen'; php-general@lists.php.net > > Subject: Re: [PHP] pear.php.net > > > > > > Jay Blanchard wrote: > > > [snip] > > > I know this was asked already, but I am going to ask once > more... Is > > > pear.php.net online? Here's why I ask: > > > > > > pear list-upgrades > > > XML_RPC_Client: Connection to RPC server pear.php.net:80 > > failed. Connection > > > refused > > > > > > Also, browsing to pear.php.net results in a page cannot be > > displayed error. > > > [/snip] > > > > > > Based on the overwhelming evidence I would have to say that > > it is offline > > > for the moment. > > > > > > > we cannot rule out the possibility that Alex' IP addr has > > been singled out for > > discrimination ;-) > > > > hehe... Pick on Alex day, huh? > > I can ping pear.php.net, but the webserver seems to be > ignoring me... Maybe > you're right! ;) > > Alex Moen > Operations Technology Specialist > NDTC > > -- > 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] Removing Items from an Array
Hi all, I'm really struggling here! I have a large, multi-dimensional array that I want to "clean-up" a bit before committing to a database. I want to remove quite a bit of the array but using the KEYs not the values. I know the keys I want to keep and I know the keys I want to get rid of. I want to keep the structure and sequence of the array in tact. All of the array traversing functions in PHP seem to either: only work on the values, or do not allow the removal of elements of the array! Can anyone offer a clue bat to a tired old array walker! Thanks Alan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SOAP WSDL location
This is a minor thing that's been troubling me, making it difficult to deploy a salesforce.com SOAP client across multiple projects. Salesforce is a particular interest because its WSDL files are NOT available directly online - you have to download and save local copies manually. When constructing a SOAPClient object, the WSDL parameter provided is treated like a URL (because it will usually BE a URL). For 'local' URLs, it searches the current directory, including any relative path that it uses. However, because it is fundamentally a URL and not a file request like an include, it does not search the include path. The net result of this is that I'm having to copy my WSDL files into every place that my class library is called from because the URL resolution will only ever look in the calling directory and not in the include path that allowed it to find my classes. An alternative would be to allow providing the WSDL as a literal string, probably read using file_get_contents() which does support using the include path. A worse solution is to provide the WSDL contents as the response to a separate HTTP call (i.e. act like the WSDL is online after all). This would work, but it's way less efficient. I can't use an absolute path as it's deployed in multiple configurations on multiple servers, and config is bad enough already. Now before I report this as a bug/feature request, does anyone have any better ideas? Marcus -- Marcus Bointon Synchromedia Limited: Putting you in the picture [EMAIL PROTECTED] | http://www.synchromedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing Items from an Array
On Wed, Oct 12, 2005 at 05:24:11PM +0100, Alan Lord wrote: > I'm really struggling here! I have a large, multi-dimensional array that > I want to "clean-up" a bit before committing to a database. How big an array? You could just go create another array of the same structure and copy the values across (and the keys too if it's an associative array) then remove all references to the old array and commit the new one to the database.. Paul -- Rogue Tory http://www.roguetory.org.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing Items from an Array
If I understand what you're asking, then maybe this will help: $arrset1 = array("Apples" => 3, "Oranges" => 5, "Apricots" => 1); $arrset2 = array("Couches" => 6, "Chairs" => 2, "Benches" => 5); $alldataarr["Fruits"] = $arrset1; $alldataarr["Furniture"] = $arrset2; Say we want to remove "Chairs", and let's do it the hard way: foreach ($alldataarr as $key => $data) { foreach ($data as $subkey => $subdata) { if ($subkey == "Chairs) { unset($alldataarr[$key][$subkey]); } } } using foreach $arr as $key => $data you can get the key/index name as well as the actual value stored in that part of your array. Then all you have to do is refer back up to the main array using the current $key/$subkey values as your indexes. Basic example, but I think you can modify this to work with what you're doing. Let me know if you have any questions about this example. -TG = = = Original message = = = Hi all, I'm really struggling here! I have a large, multi-dimensional array that I want to "clean-up" a bit before committing to a database. I want to remove quite a bit of the array but using the KEYs not the values. I know the keys I want to keep and I know the keys I want to get rid of. I want to keep the structure and sequence of the array in tact. All of the array traversing functions in PHP seem to either: only work on the values, or do not allow the removal of elements of the array! Can anyone offer a clue bat to a tired old array walker! Thanks Alan ___ 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
Re: [PHP] ICQ
Al Hafoudh wrote: is it possible to connect to icq, send messages and etc? thanx I looked all over that place for such a function some time back. I did find several, but all were very old. The problem was they were all based on the ICQ account number. Thinking about allowing such through the ICQ network was an invitation to easy spamming. Just write a script rolling through numbers and sending a message. I believe ICQ disabled this feature. If you find out differently, please post your findings back to this list as I have a client with this very request which I was unable to fulfill. Best, John Hinton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Optimize PDF on upload?
Any PHP modules available that will optimize PDF files on upload? Thanks, D ** HTC Disclaimer: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. **
[PHP] outputting xml with DOM and ampersands
I am trying to output a file using DOM with php5. It gives me an error with something like the following: farm lettuces with reed avocado, crème fraîche, radish and cilantro It does have the encoding set to utf-8. When I switch it to utf-16, it gives me an error on the $dom->saveXML(); Any ideas about how to fix this? -jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing Items from an Array
Id like to continue where TG left off ... hth. [EMAIL PROTECTED] wrote: If I understand what you're asking, then maybe this will help: $arrset1 = array("Apples" => 3, "Oranges" => 5, "Apricots" => 1); $arrset2 = array("Couches" => 6, "Chairs" => 2, "Benches" => 5); $alldataarr["Fruits"] = $arrset1; $alldataarr["Furniture"] = $arrset2; Say we want to remove "Chairs", and let's do it the hard way: foreach ($alldataarr as $key => $data) { foreach ($data as $subkey => $subdata) { if ($subkey == "Chairs) { unset($alldataarr[$key][$subkey]); } } } using foreach $arr as $key => $data you can get the key/index name as well as the actual value stored in that part of your array. Then all you have to do is refer back up to the main array using the current $key/$subkey values as your indexes. $filter = array( 'Fruits'=> array('Apples' => 1, 'Oranges' => 1), 'Furniture' => array('Couches' => 1, 'Chairs' => 1), ); $alldataarr = array(); $alldataarr["Fruits"] = array("Apples" => 3, "Oranges" => 5, "Apricots" => 1); $alldataarr["Furniture"] = array("Couches" => 6, "Chairs" => 2, "Benches" => 5); foreach ($alldataarr as $key => $data) { if (!isset($filter[$key]) { // we want it all;. continue; } $alldataarr[$key]= array_intersect_keys($data, $filter[$key]); } // heres one I prepared earlier: /** * array_intersect_keys() *^--- the internal function (php5.x+?) has no 's' * * returns the all the items in the 1st array whose keys are found in any of the other arrays * * @return array() */ function array_intersect_keys() { $args = func_get_args(); $originalArray = $args[0]; $res= array(); if(!is_array($originalArray)) { return $res; } for($i=1;$i $data) { if (isset($originalArray[$key]) && !isset($res[$key])) { $res[$key] = $originalArray[$key]; } } } return $res; } Basic example, but I think you can modify this to work with what you're doing. Let me know if you have any questions about this example. -TG = = = Original message = = = Hi all, I'm really struggling here! I have a large, multi-dimensional array that I want to "clean-up" a bit before committing to a database. I want to remove quite a bit of the array but using the KEYs not the values. I know the keys I want to keep and I know the keys I want to get rid of. I want to keep the structure and sequence of the array in tact. All of the array traversing functions in PHP seem to either: only work on the values, or do not allow the removal of elements of the array! Can anyone offer a clue bat to a tired old array walker! Thanks Alan ___ 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] Any good free easy converting tool?
Hi there! Someone know of any good free tool for converting from Access to Mysql. I just need to import certain tables into an already existance database. /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Any good free easy converting tool?
On 10/12/05, Gustav Wiberg <[EMAIL PROTECTED]> wrote: > Hi there! > > Someone know of any good free tool for converting from Access to Mysql. I > just need to import certain tables into an already existance database. > > /G > http://www.varupiraten.se/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Hey Gustav!!! I use Navicat... i think they have a free trail package for their software... it's the best that I can find out there!! Good luck! Joe -- Joe Harman - Do not go where the path may lead, go instead where there is no path and leave a trail. - Ralph Waldo Emerson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Any good free easy converting tool?
Hi there! I need to do a one time convert from an Access-databasetable to an MySQL-database-table. Is the MyODBC the only way? /G - Original Message - From: "Jay Blanchard" <[EMAIL PROTECTED]> To: "'Gustav Wiberg'" <[EMAIL PROTECTED]> Sent: Wednesday, October 12, 2005 8:56 PM Subject: RE: [PHP] Any good free easy converting tool? [snip] Someone know of any good free tool for converting from Access to Mysql. I just need to import certain tables into an already existance database. [/snip] Isn't the MyODBC thingie free? -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.14/129 - Release Date: 2005-10-11 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Any good free easy converting tool?
- Original Message - From: "Joe Harman" <[EMAIL PROTECTED]> To: Cc: "Gustav Wiberg" <[EMAIL PROTECTED]> Sent: Wednesday, October 12, 2005 9:00 PM Subject: Re: [PHP] Any good free easy converting tool? On 10/12/05, Gustav Wiberg <[EMAIL PROTECTED]> wrote: Hi there! Someone know of any good free tool for converting from Access to Mysql. I just need to import certain tables into an already existance database. /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hey Gustav!!! I use Navicat... i think they have a free trail package for their software... it's the best that I can find out there!! Good luck! Joe -- Joe Harman - Do not go where the path may lead, go instead where there is no path and leave a trail. - Ralph Waldo Emerson -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.14/129 - Release Date: 2005-10-11 Hi there! Thanx! /G http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Removing Items from an Array
Thanks for the replies gents. I have cludged together something from your solutions but it isn't yet working. I've been staring at multi-dim arrays all day and am getting tired, so I'll carry on tomorrow. Thanks again, Alan > -Original Message- > From: Jochem Maas [mailto:[EMAIL PROTECTED] > Sent: 12 October 2005 19:18 > To: [EMAIL PROTECTED] > Cc: php-general@lists.php.net; [EMAIL PROTECTED] > Subject: Re: [PHP] Removing Items from an Array > > Id like to continue where TG left off ... > > hth. > > [EMAIL PROTECTED] wrote: > > If I understand what you're asking, then maybe this will help: > > > > $arrset1 = array("Apples" => 3, "Oranges" => 5, "Apricots" => 1); > > $arrset2 = array("Couches" => 6, "Chairs" => 2, "Benches" => 5); > > > > $alldataarr["Fruits"] = $arrset1; > > $alldataarr["Furniture"] = $arrset2; > > > > Say we want to remove "Chairs", and let's do it the hard way: > > > > foreach ($alldataarr as $key => $data) { > > foreach ($data as $subkey => $subdata) { > > if ($subkey == "Chairs) { > > unset($alldataarr[$key][$subkey]); > > } > > } > > } > > > > using foreach $arr as $key => $data you can get the > key/index name as well as the actual value stored in that > part of your array. Then all you have to do is refer back up > to the main array using the current $key/$subkey values as > your indexes. > > > > $filter = array( > 'Fruits'=> array('Apples' => 1, 'Oranges' => 1), > 'Furniture' => array('Couches' => 1, 'Chairs' => 1), ); > > $alldataarr = array(); > $alldataarr["Fruits"] = array("Apples" => 3, "Oranges" => 5, > "Apricots" => 1); $alldataarr["Furniture"] = array("Couches" > => 6, "Chairs" => 2, "Benches" => 5); > > foreach ($alldataarr as $key => $data) { > if (!isset($filter[$key]) { > // we want it all;. > continue; > } > $alldataarr[$key]= array_intersect_keys($data, $filter[$key]); } > > > // heres one I prepared earlier: > > > /** > * array_intersect_keys() > *^--- the internal function (php5.x+?) > has no 's' > * > * returns the all the items in the 1st array whose keys are > found in any of the other arrays > * > * @return array() > */ > function array_intersect_keys() > { > $args = func_get_args(); > $originalArray = $args[0]; > $res= array(); > > if(!is_array($originalArray)) { return $res; } > > for($i=1;$i if(!is_array($args[$i])) { continue; } > foreach ($args[$i] as $key => $data) { > if (isset($originalArray[$key]) && !isset($res[$key])) { > $res[$key] = $originalArray[$key]; > } > } > } > > return $res; > } > > > > > > > > Basic example, but I think you can modify this to work with > what you're doing. > > > > Let me know if you have any questions about this example. > > > > -TG > > > > > > > > = = = Original message = = = > > > > Hi all, > > > > I'm really struggling here! I have a large, multi-dimensional array > > that I want to "clean-up" a bit before committing to a database. > > > > I want to remove quite a bit of the array but using the > KEYs not the > > values. I know the keys I want to keep and I know the keys > I want to > > get rid of. I want to keep the structure and sequence of > the array in tact. > > > > All of the array traversing functions in PHP seem to > either: only work > > on the values, or do not allow the removal of elements of the array! > > > > Can anyone offer a clue bat to a tired old array walker! > > > > Thanks > > > > Alan > > > > > > ___ > > 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] Possible bug with imagettftext and imageft text when imagealphablending is false
I have been attempting to write a dynamic text replacement script that would generate transparent PNGs using gd, and it works fine except when one of the characters in a font has parts of it that overhang into the previous characters. You can see what I mean in this test script: The result can be seen at http://ethilien.net/tests/text.php When you compare the text with what it should look like when I comment out the imagealphablending($img, false); line here http://ethilien.net/tests/text2.php you can see that the end of the 'u' is cut off. I think that this is because the lower-left slash of the 'x' overlaps it and causes it to be overwritten. This might be a bug in GD and not PHP, but I wanted to see if anyone has encountered this problem before or if I'm just not doing something right. Thanks, -Connor McKay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ampersand in dom with utf-8
I'm now getting this error: XML Parsing Error: undefined entity with the following entity at the first ampersand: farm lettuces with reed avocado, crème fraîche, radish and cilantro Why is an ampersand considered an undefined entity? The xml version is: Any thoughts please? -jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC
On Tue, October 11, 2005 11:41 am, GamblerZG wrote: > Recently, I asked my hosting provider when they are going to switch to > PHP5. They replied that it will not happen any time soon, since they > will install PHP5 only on new servers. Their reasoning was simple: So ask them to move your account from the old server to the new server and you get PHP5. No big deal. > function class_method($var){ } > ?> > class clazz implements Something{ > function method($var) { > } > } > ?> You'd need to have: http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] onChange js running a php function
On Tue, October 11, 2005 3:11 pm, Dan McCullough wrote: > Its been awhile since I tried this so I was wondering if anyone had > any luck with this. > > I need to get a list of tables from a database, which means I have to > run a function, I would like to have an onChange event run when I > change my selection in a select menu, that would send the value for > the select menu to a php function. > can that be done? Yes, but... You can do it with XmlHttpRequest, or even just changing your "location" in JavaScript. But... A) This doesn't really make any difference to the PHP code -- It's all in the JS, so you should probably research in JS forums. B) It's going to be DOG-SLOW if every menu change has to make a round-trip to the web server and get stuff from the database, unless it's a limited install on a LAN or other high-speed-only network. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] actually the è not the ampersand
so, the problem isn't the ampersand but rather the è in the following: farm lettuces with reed avocado, crème fraîche, radish and cilantro I'm not sure how php / DOM handles these non-standard other entities. How would / could I escape this? do I need to convert it to something else to make DOM happy (say grave) and then convert it back when outputted? It seems like there might be a way to use createEntityReference but searching through google shows no examples. arg. I'm using php 5.0.3 -jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array_slice and for loop problem
Hello, I'm using a for loop to iterate through an array and slice parts of the array and add into another array. When array_slice is called the variable $i is not being substituted with the current value of $i and the $output array is empty after running the script. Can someone look at the code below and give me a clue as to why this substitution is not happening? If I uncomment the "echo $i;" statement the value of $i is printed just fine. Thanks, Rod Here's my code: $number = count ($int_range[start]); //echo $number; for ($i = 0; $i <= $number; $i++) { //echo $i; $output = array_slice ($textArray, $int_range[start][$i], $int_range[end][$i]); } foreach ($output as $value) { echo $value; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] pecl hosting is in a pickel...
Has anyone noticed/experienced the fact that the pecl site is spotty today? I think I was able to download one module all day in and out of db connect errors. I really need to get a module off of there. Is there some loop I can jump through to get it? Thanks, - Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] actually the è not the ampersand
jonathan wrote: so, the problem isn't the ampersand but rather the è in the following: farm lettuces with reed avocado, crème fraîche, radish and cilantro I'm not sure how php / DOM handles these non-standard other entities. How would / could I escape this? do I need to convert it to something else to make DOM happy (say grave) and then convert it back when outputted? It seems like there might be a way to use createEntityReference but searching through google shows no examples. arg. I have to do this to create XML documents for our company, and built this function for it. You're welcome to use/modify it to fit your needs. function convertString ( $string ) { $find_array = array ( "/"/", "/&/", "/", "/>/", "/ /", "/¡/", "/¢/", "/£/", "/¤/", "/¥/", "/¦/", "/§/", "/¨/", "/©/", "/ª/", "/«/", "/¬/", "//", "/®/", "/¯/", "/°/", "/±/", "/²/", "/³/", "/´/", "/µ/", "/¶/", "/·/", "/¸/", "/¹/", "/º/", "/»/", "/¼/", "/½/", "/¾/", "/¿/", "/À/", "/Á/", "/Â/", "/Ã/", "/Ä/", "/Å/", "/Æ/", "/Ç/", "/È/", "/É/", "/Ê/", "/Ë/", "/Ì/", "/Í/", "/Î/", "/Ï/", "/Ð/", "/Ñ/", "/Ò/", "/Ó/", "/Ô/", "/Õ/", "/Ö/", "/×/", "/Ø/", "/Ù/", "/Ú/", "/Û/", "/Ü/", "/Ý/", "/Þ/", "/ß/", "/à/", "/á/", "/â/", "/ã/", "/ä/", "/å/", "/æ/", "/ç/", "/è/", "/é/", "/ê/", "/ë/", "/ì/", "/í/", "/î/", "/ï/", "/ð/", "/ñ/", "/ò/", "/ó/", "/ô/", "/õ/", "/ö/", "/÷/", "/ø/", "/ù/", "/ú/", "/û/", "/ü/", "/ý/", "/þ/", "/ÿ/" ); $replace_array = array ( '"', '&', '<', '>', ' ', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷',
[PHP] Re: Userlogin system seems to override the if statement....
did u give proper username and password to login with? On 10/12/05, twistednetadmin <[EMAIL PROTECTED]> wrote: > I'm new to this. So I used a tutorial to write this. But it shows "Login > ok. > Welcome" at once when the page loads. Here is the tutorial: > http://www.ss32.x10hosting.com/ss32/files/PHP-logins.pdf > include ("DBconnection"); > > > session_start(); > $err = 0; > echo $err; //just to check. Shows 0 > $sql_login = sprintf("SELECT 'name', 'pass' FROM DB > WHERE 'name'='%s' AND 'pass'='%s'", @$_GET['name'],@md5($_GET['pass'])); > $login = mysql_query($sql_login) or die(mysql_error()); > if (mysql_num_rows($login) == 0) { > $GLOBALS['MM_username'] == @$_GET['name']; > echo $err; //just to check. Shows 0 > session_register("MM_username"); > echo $err; //just to check. Shows 0 > $err = 1; > > > } > echo $err; //just to check. Shows 1 > ?> > > if ($err != 1) { > if ($err == 2) { ?> > There was an error processing your login. > > > > > > > Login as: > > > > > Password: > > > > > > > > > > }else{ > ?> > Login ok. Welcome echo ""; > } > ?> > > I don't get any further. I must be missing something, but what?? > > Please help. > > -Tore W- > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include file to global scope
yes, its possible, consider this: /** * @param $file_to_include path to php file you want to get its content * @return included contents */ function get_output($file_to_include){ ob_start(); include $file_to_include; return ob_get_clean(); } of course, you may extend this function to better fit into your situation. Good luck. On 10/12/05, Claudio <[EMAIL PROTECTED]> wrote: > Is it possible to process the file in second php instance? > An only get its output? > > Claudio > > -- > 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] Obsession with BC, take 2
Since nobody ansvered the real question my previous message, I will re-phrase it. PHP developers assume that PHP5 will be frequently used to parse PHP4 scripts. Why? And what's so horrible about using separate engines to run php 4 and 5 scripts? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC, take 2
On Wed, 2005-10-12 at 17:31, GamblerZG wrote: > Since nobody ansvered the real question my previous message, I will > re-phrase it. > > PHP developers assume that PHP5 will be frequently used to parse PHP4 > scripts. Why? And what's so horrible about using separate engines to run > php 4 and 5 scripts? You can use separate engines. The topic has been addresses many times already. Set up a second instance of apache and use the ProxyPass system to pass control from the primary apache server to a PHP5 enabled apache server. Ultimately though, the answer to why people want backward compatibility, is because they want their libraries and applications to be available to the widest possible audience. 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
Re: [PHP] actually the è not the ampersand
do you then have to do the reverse operation to get it back for rendering. Since it was erroring on me during DOM creation, I feel like I'm going around it to put it into a format it likes but then on display via XSL transformation, I will have to convert it back. Or am I missing something? thanks again for your help. jonathan On Oct 12, 2005, at 2:17 PM, John Nichel wrote: jonathan wrote: so, the problem isn't the ampersand but rather the è in the following: farm lettuces with reed avocado, crème fraîche, radish and cilantro I'm not sure how php / DOM handles these non-standard other entities. How would / could I escape this? do I need to convert it to something else to make DOM happy (say grave) and then convert it back when outputted? It seems like there might be a way to use createEntityReference but searching through google shows no examples. arg. I have to do this to create XML documents for our company, and built this function for it. You're welcome to use/modify it to fit your needs. function convertString ( $string ) { $find_array = array ( "/"/", "/&/", "/", "/>/", "/ /", "/¡/", "/¢/", "/£/", "/¤/", "/¥/", "/¦/", "/§/", "/¨/", "/©/", "/ª/", "/«/", "/¬/", "//", "/®/", "/¯/", "/°/", "/±/", "/²/", "/³/", "/´/", "/µ/", "/¶/", "/·/", "/¸/", "/¹/", "/º/", "/»/", "/¼/", "/½/", "/¾/", "/¿/", "/À/", "/Á/", "/Â/", "/Ã/", "/Ä/", "/Å/", "/Æ/", "/Ç/", "/È/", "/É/", "/Ê/", "/Ë/", "/Ì/", "/Í/", "/Î/", "/Ï/", "/Ð/", "/Ñ/", "/Ò/", "/Ó/", "/Ô/", "/Õ/", "/Ö/", "/×/", "/Ø/", "/Ù/", "/Ú/", "/Û/", "/Ü/", "/Ý/", "/Þ/", "/ß/", "/à/", "/á/", "/â/", "/ã/", "/ä/", "/å/", "/æ/", "/ç/", "/è/", "/é/", "/ê/", "/ë/", "/ì/", "/í/", "/î/", "/ï/", "/ð/", "/ñ/", "/ò/", "/ó/", "/ô/", "/õ/", "/ö/", "/÷/", "/ø/", "/ù/", "/ú/", "/û/", "/ü/", "/ý/", "/þ/", "/ÿ/" ); $replace_array = array ( '"', '&', '<', '>', ' ', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ' ); $string = htmlentities ( strip_tags ( preg_replace ( "/\n|\r|\r \n/", " ", $string ) ), ENT_QUOTES ); $string = preg_replace ( $find_array, $replace_array, $string ); return $string; } -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Run a php script as a separate thread/process
Tommy, r u serious? this ain't what you called 'thread or process', just something like an user agent, like any web browser. On 10/12/05, Tommy Jensehaugen <[EMAIL PROTECTED]> wrote: > Thank you very much. This is what I ended up with if anyone needs it: > > function runSeparateThread($strHost, $strPath="/") { > $fFile = fsockopen($strHost, 80, $intError, $strError); > if ($fFile) { > $out = "GET ".$strPath." HTTP/1.1\r\n"; > $out .= "Host: ".$strHost."\r\n"; > $out .= "Connection: Close\r\n\r\n"; > if(!fwrite($fFile, $out)){ >$result = "runSeparateThread():fwrite(). Could not write:'".$out."'. > Host:'".$strHost."'. Path:'".$strPath."'"; > } else { >$result = true; > } > fclose($fFile); > } else { > $result = "runSeparateThread():fsockopen(): Could not connect to > ".$strHost." (".$intError.") ".$strError."."; > } > return $result; > } > ?> > > -- > 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] How can I connect a remote server from phpmyadmin?
Hello, I have PhpMyAdmin 2.6.3 , MySQL 4.1.13 running in my Windows 2000. I installed them using Apache friends XAMPP, so I didn¡¯t do any configuration myself. Currently if I go to http://127.0.0.1/phpmyadmin, then it automatically shows my local MySQL db and tables. Now I need to connect remote server(it has MySQL) and do some DB Admin of that server. How can I connect to that server from phpmyadmin? I¡¯ve been trying to find if there any kind of connect panel in phpmyadmin, but no fruit yet. I really appreciate you guys help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: array_slice and for loop problem
Are you trying to put each return from array_slice into $output as an array? You need to replace $output = array_slice... with $output[] = array_slice... Also, you cannot just echo an array (even of characters). It must be a string, or else echo will only produce the output 'Array'. Hope this helps, -Connor McKay Rodney Green wrote: Hello, I'm using a for loop to iterate through an array and slice parts of the array and add into another array. When array_slice is called the variable $i is not being substituted with the current value of $i and the $output array is empty after running the script. Can someone look at the code below and give me a clue as to why this substitution is not happening? If I uncomment the "echo $i;" statement the value of $i is printed just fine. Thanks, Rod Here's my code: $number = count ($int_range[start]); //echo $number; for ($i = 0; $i <= $number; $i++) { //echo $i; $output = array_slice ($textArray, $int_range[start][$i], $int_range[end][$i]); } foreach ($output as $value) { echo $value; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How can I connect a remote server from phpmyadmin?
You need to edit the config.inc.php file in the phpmyadmin directory and set the appropriate server address/username/password information for your remote server. You might have to set a remote server up in cpanel for this to work however. MI SOOK LEE wrote: Hello, I have PhpMyAdmin 2.6.3 , MySQL 4.1.13 running in my Windows 2000. I installed them using Apache friends XAMPP, so I didn¡¯t do any configuration myself. Currently if I go to http://127.0.0.1/phpmyadmin, then it automatically shows my local MySQL db and tables. Now I need to connect remote server(it has MySQL) and do some DB Admin of that server. How can I connect to that server from phpmyadmin? I¡¯ve been trying to find if there any kind of connect panel in phpmyadmin, but no fruit yet. I really appreciate you guys help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Hidden Form Help
To answer your questions: 1) No, there is no way to make data show up in both fields because the script you are currently using is probably echoing the data directly into a value attribute of the elements themselves. Also, by making two different elements in the same form have the same name, and two different page elements have the same id, you are introducing a level of instability into the DOM that could result in no data being submitted at all if some browsers do not handle multiple occurrences of the same id in a page the same way (such as submitting the value from the first occurrence of the name rather than the last, resulting in the input in the hidden form being used). 2) Javascript would be your only hope of doing this, but as I said regarding the DOM, their is no way to independently access two page elements with the same id, so even Javascript cannot do this. I would recommend that, even though the application does not allow templating, you can still change its source code for displaying the form to allow you to template it that way. Hope this helps, -Connor Mckay Alnisa Allgood wrote: Hi- I'm in a situation where I'm required to deal with a hidden form. The background details are exhausting, but the gist is: one form is auto-generated and lacks proper formatting. It was part of an open source package that DID NOT allow templating. So to keep using the application engine, but provide formatting, I created a CSS class to hide the unformatted form while displaying the formatted form. When submitting data to the database this doesn't seem to cause any issues. It accepts data based on the fieldvalues and ids. But when retrieving data to repopulate the form, what happens is that the hidden form gets the values and the displayed form does not. http://nahic.ucsf.edu/phpESP/survey.php login= Wisconsin Basically, if you complete the required field (state), fill out some random data, hit save, then select "resume" from the info page provided. You'll get back an empty form. But if you look at the code you'll see that the hidden form has the values. So I have a few questions: 1) Is there anyway to echo data from one field to the next, especially if the field (name or id) are exactly the same?? (i.e. field=state value=Wisconsin; if the field state is then repeated somewhere else on the page, can the value, Wisconsin, also be automatically repeated. 2) If yes, to the above can PHP do this and how? or is this something requiring Javascript or some other coding. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How can I connect a remote server from phpmyadmin?
Ethilien said the following on 10/12/05 15:55: You need to edit the config.inc.php file in the phpmyadmin directory and set the appropriate server address/username/password information for your remote server. You might have to set a remote server up in cpanel for this to work however. And of course the mysql server has to be configured to allow remote access for the user(s) involved. - Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Store a variable name in a database field.
Most likely you are using some template system that require using of {{whatever}} as template varibles. if you want to change {{whatever}} to something else, maybe you should configure your template processing as well, just let it not to find {{whatever}} but the pattern you prefered, and also replace {{whatever}} with that pattern. another tip, if you want to use `$' as literal , i.e. not interpretered by php engine, quote the string with single quote. like this: $str_val='$something'; , or like this: $str_val="\$something"; in both case, you will get a literal sting `$something'. On 10/11/05, Liam Delahunty <[EMAIL PROTECTED]> wrote: > I'm sure this is a pretty basic question, but I have searched for a > decent answer and can't find one. > > I have a client that want to be able to write newsletters > (newsleters_tbl.email_body) and use fields from his contact table, so > as we grind through the contact list for newsletters subscribers it > may pull out $first_name, or $last_name, or perhaps the address and so > on, and send an individual email and have it in the $email_body field > from another table. > > $email_body is a free form text field, and he wants to be able to type > in anything he desires and have it pulled from the contact table. > > I've tried with and without addslashes, and htmlentities. Is there a > solution or I will I have to resort to getting him to use > {{$first_name}} etc. > > Lastly, if I have to use {{whatever}} then what's the reason I can't > use $field_name in the database? > > -- > Kind regards, > Liam Delahunty > > -- > 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] Obsession with BC, take 2
Robert Cummings wrote: On Wed, 2005-10-12 at 17:31, GamblerZG wrote: Since nobody ansvered the real question my previous message, I will re-phrase it. PHP developers assume that PHP5 will be frequently used to parse PHP4 scripts. Why? And what's so horrible about using separate engines to run php 4 and 5 scripts? You can use separate engines. The topic has been addresses many times already. Yes, but separating PHP 4 and 5 is still a non-trivial task. For example, IIRC, FreeBSD's port system does not allow you to install both mods at the same time. Besides, developers do not expect PHP to be used that way, so they are likely to sacrifice certain features for the sake of compatibility. -- Best regards, Roman S.I. http://sf.net/projects/naturalgine/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC, take 2
Robert Cummings schrieb: > You can use separate engines. The topic has been addresses many times > already. Set up a second instance of apache and use the ProxyPass system > to pass control from the primary apache server to a PHP5 enabled apache > server. I always thought this complexity is why people are not doing this. I read about patching the PHP5 sources so the internal names for the module do not collide with those for PHP4. Then it's possible for bothe modules to coexist in a single Apache instance. Why ist this not made standard behaviour? Oliver Zaan: "There is much cruelty in the universe." John: "Yea, We seem to have the treasure map to it" [FarScape 121] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Trouble moving directory
I'm having trouble moving some directories. My script works fine on some directories but doesn't move others. It seems to have trouble with directories with non alphanumeric charters. I'm running Red Hat FC2. I'm trying to move the directory basically like this... Is there some way to escape the characters in the directories? For example if i put a "\" in front of blank spaces it takes care of those (same for "'","(" etc.) but that obviously doesn't take care of everything. I'm hoping there is something easy i'm overlooking here that will escape all the characters. -k. __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] outputting xml with DOM and ampersands
On Wednesday 12 October 2005 12:40 pm, jonathan wrote: > I am trying to output a file using DOM with php5. > > It gives me an error with something like the following: > farm lettuces with reed avocado, crème > fraîche, radish and cilantro Are you doing a: DOMDocument::loadXML('farm lettuces with reed avocado, crème fraîche, radish and cilantro'); You may have to manually convert the & to & tho I thought it did an automatic convertion. > > It does have the encoding set to utf-8. When I switch it to utf-16, > it gives me an error on the $dom->saveXML(); > > Any ideas about how to fix this? > > -jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trouble moving directory
-k. wrote: I'm having trouble moving some directories. My script works fine on some directories but doesn't move others. It seems to have trouble with directories with non alphanumeric charters. I'm running Red Hat FC2. I'm trying to move the directory basically like this... $source_dir = escapeshellarg( '/some/dir/Dir That Won't Move/' ); $dest_dir = '/some/other/dir/'; $dest_dir = escapeshellarg( '/some/other/dir/' ); $cmd = escapeshellcmd("mv ".$source_dir." ".$dest_dir); $result = shell_exec($cmd); ?> Is there some way to escape the characters in the directories? For example if i put a "\" in front of blank spaces it takes care of those (same for "'","(" etc.) but that obviously doesn't take care of everything. I'm hoping there is something easy i'm overlooking here that will escape all the characters. -- 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] Any good free easy converting tool?
Why don't you just import from Access to CSV and use LOAD DATA query on MySQL? ""Gustav Wiberg"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > - Original Message - > From: "Joe Harman" <[EMAIL PROTECTED]> > To: > Cc: "Gustav Wiberg" <[EMAIL PROTECTED]> > Sent: Wednesday, October 12, 2005 9:00 PM > Subject: Re: [PHP] Any good free easy converting tool? > > > On 10/12/05, Gustav Wiberg <[EMAIL PROTECTED]> wrote: >> Hi there! >> >> Someone know of any good free tool for converting from Access to Mysql. I >> just need to import certain tables into an already existance database. >> >> /G >> http://www.varupiraten.se/ >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > Hey Gustav!!! > > I use Navicat... i think they have a free trail package for their > software... it's the best that I can find out there!! > > Good luck! > Joe > -- > Joe Harman > - > Do not go where the path may lead, go instead where there is no path > and leave a trail. - Ralph Waldo Emerson > > > -- > No virus found in this incoming message. > Checked by AVG Anti-Virus. > Version: 7.0.344 / Virus Database: 267.11.14/129 - Release Date: > 2005-10-11 > > Hi there! > > Thanx! > > /G > http://www.varupiraten.se/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing passwords in $_SESSION
On Tue, 2005-10-11 at 00:25 +0200, Oliver Grätz wrote: > Dan Brow schrieb: > > Thanks, figured that would be the case. Can't for life of me think why I > > wanted to do that, must have had a brain infarction. I want to have an > > expired session prompt so people can log back in with out having to > > start at the login page. Would having the users login saved in $_SESSION > > be alright? prompt them for their password and compare it with the > > password in the DB be fine? I want to reduce the amount of typing > > someone has to do when a session expires. > > Why don't you leave the decision if they want to type to the user? > My browser keeps track of what I entered into every login form I ever > visited... This app is going to be in a Doctors office I don't want people storing passwords on systems that have patient records. Dan. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Small regex help?
Can anyone suggest the correct regex to replace col1,col2... with count(*) and strip out everything just before ORDER BY? so for this: SELECT col1,col2... FROM tbl WHERE filter1 filter2 ORDER BY order1,order2 I would get this: SELECT count(*) FROM tbl WHERE filter1 filter2 Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trouble moving directory
--- Jasper Bryant-Greene <[EMAIL PROTECTED]> wrote: > $source_dir = escapeshellarg( '/some/dir/Dir That Won't Move/' ); Unfortunately escapeshellarg doesn't work for all cases, it will escape the " ' " in that example but it doesn't escape other characters such as " ) ". So... $source_dir = escapeshellarg( '/some/dir/Dir That (Won't Move)/' ); ...fails as well. Any other ideas? -k. __ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Template Security Advice (WASP - http://wasp.sourceforge.net)
Hi, Tuesday, October 11, 2005, 3:37:13 PM, you wrote: BF> I'm finishing up my WASP framework 1.0 release (http:// BF> wasp.sourceforge.net) and I'm trying to decide the best way to lay BF> out the template directories. BF> WASP uses HTML_Template_Flexy for its template system. The templates BF> are compiled using "Chunk" classes that each refer to a html template. BF> The way it works now, the directory structure of applications is BF> |_ /webroot/module/templates BF> where module is where the php classes are stored, and templates is BF> where the html templates are stored. The templates used to be stored BF> in a seperate directory outside of the web root, as such BF> |_ /templates/ BF> |_ /webroot/ModuleDir BF> however it becomes cumbersome to keep track of which templates go to BF> which php classes, so for organization sake having the template BF> directory located beneath each module directory is easier to navigate. BF> My problem is, anyone who realizes a particular application uses WASP BF> can go to a url, say http://blah/module, and look at the html files BF> in the template directory (ex. http://blah/module/templates). Is it BF> too much of a security issue to justify this useful organization? BF> Theoretically the addition of an .htaccess file in the templates BF> directories could solve the problem, but is that compounding the BF> issue even more? I guess I'm asking for someone to tell me it's ok BF> to do it this way, but if nobody agrees I can change it back. BF> Thanks for the input. BF> -Brian BF> /** BF> * Brian Fioca BF> * Chief Scientist / Sr. Technical Consultant BF> * PangoMedia - http://pangomedia.com BF> * @work 907.868.8092x108 BF> * @cell 907.440.6347 BF> */ What about: |_ /templates/ModuleDir |_ /webroot/ModuleDir Or even better if the modules should not be accessed directly |_ /Modules/ModuleDir |_ /Modules/ModuleDir/templates/ |_ /webroot/ ModuleDir -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Small regex help?
Can anyone suggest the correct regex to replace col1,col2... with count(*) and strip out everything just before ORDER BY? so for this: SELECT col1,col2... FROM tbl WHERE filter1 filter2 ORDER BY order1,order2 I would get this: SELECT count(*) FROM tbl WHERE filter1 filter2 $str = "SELECT col1,col2... FROM tbl WHERE filter1 filter2 ORDER BY order1,order2"; $str = ereg_replace("^SELECT .* FROM (.*) ORDER BY .*", "SELECT COUNT(*) FROM \\1", $str); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Small regex help?
Hmmm, "/SELECT .* FROM (.*) WHERE (.*) ORDER BY .*/Ui", "SELECT count(*) FROM \$1 WHERE \$2" Might work, but haven't tried it... Guy Brom wrote: Can anyone suggest the correct regex to replace col1,col2... with count(*) and strip out everything just before ORDER BY? so for this: SELECT col1,col2... FROM tbl WHERE filter1 filter2 ORDER BY order1,order2 I would get this: SELECT count(*) FROM tbl WHERE filter1 filter2 Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is DOM the right thing for the job?
Hey, I've got a set of classes which represent an HTML form. Right now the Elements return their string representation to the parent, which wraps those in the form tag and supplementary formatting HTML. This method works, but it creates an internal limit as to the design of the form. I'm hoping to use the DOM to allow each element to return a DOMElement, which the form object can put into it's own DOMElement that represents the form. I've run into a few snags, and was hoping someone could help, or maybe point at a viable solution which I haven't considered yet. Snag #1) The DOMDocument seems to represent an entire page, all I'd like to do is represent a Form tag and it's internal HTML. I can actually get it to work that way, but it seems like it's the wrong way to go about things. Snag #2) The creation of a DOMElement object is very limited without being associated with a DOMDocument, I'd like to create an independent DOMElement inside the Element class, including possible sub-DOMElements, without having to create the DOMDocument in the Form object.. I realize after writing this that these don't seem like very serious snags, but I jsut dont' have a fuzzy feeling about the way this would work if I implemented it knowing what I've stated here. Any assistance would be greatly appreciated. Thanks! Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with Javascript:...submit()
while ($row = mysql_fetch_array($sql_result)) { echo" ".$row['LITERATURE_title']." - ".$row['res_fname']." ".$row['res_lname']." ... Everything works as long as $row['LITERATURE_title'] is one word, see this variable contains the names of books, and if the books name is "Heaven" for instance it works fine but as soon as the title is something like "PHP for Dummies" it doesnt work and i get a error on page message, I tried using numbers as the form name but then the same thing happens. Any ways around this? thanx Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Peninsula University of Technology or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Javascript:...submit()
Johan Grobler wrote: while ($row = mysql_fetch_array($sql_result)) { echo" ".$row['LITERATURE_title']." - ".$row['res_fname']." ".$row['res_lname']." ... Everything works as long as $row['LITERATURE_title'] is one word, see this variable contains the names of books, and if the books name is "Heaven" for instance it works fine but as soon as the title is something like "PHP for Dummies" it doesnt work and i get a error on page message, I tried using numbers as the form name but then the same thing happens. If you've got a row ID number or something, just call the form "lit[id]" (replacing [id] with the ID number), because I don't think a form name can start with a number. Otherwise you could sha1() the title and use that as the identifier, or simply remove all spaces... -- 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: ampersand in dom with utf-8
both `è' and `î' are not entities in charset utf-8, use `è' and `î' instead. On 10/13/05, jonathan <[EMAIL PROTECTED]> wrote: > I'm now getting this error: > > XML Parsing Error: undefined entity > > with the following entity at the first ampersand: > farm lettuces with reed avocado, crème > fraîche, radish and cilantro > > Why is an ampersand considered an undefined entity? The xml version > is: > > Any thoughts please? > > -jonathan > > -- > 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] Problem with Javascript:...submit()
I'm just taking a wild guess... but I'm guessing that if you set a name with spaces, it'll be replaced with "_"(underscore). A couple of ways around this is to 1) figure out a way to assign a one-word name for all your books(e.g. Code, ID number, etc.) 2) generate a hash code(e.g. md5($row['LITERATURE_title'])) will generate a one word(no spaces). If this is going to be a library application, you can always use "ISBNX"(no spaces, no dashes), since the idea is that every book has a unique ISBN number Johan Grobler wrote: while ($row = mysql_fetch_array($sql_result)) { echo" ".$row['LITERATURE_title']." - ".$row['res_fname']." ".$row['res_lname']." ... Everything works as long as $row['LITERATURE_title'] is one word, see this variable contains the names of books, and if the books name is "Heaven" for instance it works fine but as soon as the title is something like "PHP for Dummies" it doesnt work and i get a error on page message, I tried using numbers as the form name but then the same thing happens. Any ways around this? thanx Disclaimer This e-mail transmission contains confidential information, which is the property of the sender. The information in this e-mail or attachments thereto is intended for the attention and use only of the addressee. Should you have received this e-mail in error, please delete and destroy it and any attachments thereto immediately. Under no circumstances will the Cape Peninsula University of Technology or the sender of this e-mail be liable to any party for any direct, indirect, special or other consequential damages for any use of this e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Removing Items from an Array
could Alan give samples about the input and expected output of the black box? then we can consider implement it. On 10/13/05, Alan Lord <[EMAIL PROTECTED]> wrote: > Thanks for the replies gents. > > I have cludged together something from your solutions but it isn't yet > working. I've been staring at multi-dim arrays all day and am getting > tired, so I'll carry on tomorrow. > > Thanks again, > > Alan > > > -Original Message- > > From: Jochem Maas [mailto:[EMAIL PROTECTED] > > Sent: 12 October 2005 19:18 > > To: [EMAIL PROTECTED] > > Cc: php-general@lists.php.net; [EMAIL PROTECTED] > > Subject: Re: [PHP] Removing Items from an Array > > > > Id like to continue where TG left off ... > > > > hth. > > > > [EMAIL PROTECTED] wrote: > > > If I understand what you're asking, then maybe this will help: > > > > > > $arrset1 = array("Apples" => 3, "Oranges" => 5, "Apricots" => 1); > > > $arrset2 = array("Couches" => 6, "Chairs" => 2, "Benches" => 5); > > > > > > $alldataarr["Fruits"] = $arrset1; > > > $alldataarr["Furniture"] = $arrset2; > > > > > > Say we want to remove "Chairs", and let's do it the hard way: > > > > > > foreach ($alldataarr as $key => $data) { > > > foreach ($data as $subkey => $subdata) { > > > if ($subkey == "Chairs) { > > > unset($alldataarr[$key][$subkey]); > > > } > > > } > > > } > > > > > > using foreach $arr as $key => $data you can get the > > key/index name as well as the actual value stored in that > > part of your array. Then all you have to do is refer back up > > to the main array using the current $key/$subkey values as > > your indexes. > > > > > > > $filter = array( > > 'Fruits'=> array('Apples' => 1, 'Oranges' => 1), > > 'Furniture' => array('Couches' => 1, 'Chairs' => 1), ); > > > > $alldataarr = array(); > > $alldataarr["Fruits"] = array("Apples" => 3, "Oranges" => 5, > > "Apricots" => 1); $alldataarr["Furniture"] = array("Couches" > > => 6, "Chairs" => 2, "Benches" => 5); > > > > foreach ($alldataarr as $key => $data) { > > if (!isset($filter[$key]) { > > // we want it all;. > > continue; > > } > > $alldataarr[$key]= array_intersect_keys($data, $filter[$key]); } > > > > > > // heres one I prepared earlier: > > > > > > /** > > * array_intersect_keys() > > *^--- the internal function (php5.x+?) > > has no 's' > > * > > * returns the all the items in the 1st array whose keys are > > found in any of the other arrays > > * > > * @return array() > > */ > > function array_intersect_keys() > > { > > $args = func_get_args(); > > $originalArray = $args[0]; > > $res= array(); > > > > if(!is_array($originalArray)) { return $res; } > > > > for($i=1;$i > if(!is_array($args[$i])) { continue; } > > foreach ($args[$i] as $key => $data) { > > if (isset($originalArray[$key]) && !isset($res[$key])) { > > $res[$key] = $originalArray[$key]; > > } > > } > > } > > > > return $res; > > } > > > > > > > > > > > > > > Basic example, but I think you can modify this to work with > > what you're doing. > > > > > > Let me know if you have any questions about this example. > > > > > > -TG > > > > > > > > > > > > = = = Original message = = = > > > > > > Hi all, > > > > > > I'm really struggling here! I have a large, multi-dimensional array > > > that I want to "clean-up" a bit before committing to a database. > > > > > > I want to remove quite a bit of the array but using the > > KEYs not the > > > values. I know the keys I want to keep and I know the keys > > I want to > > > get rid of. I want to keep the structure and sequence of > > the array in tact. > > > > > > All of the array traversing functions in PHP seem to > > either: only work > > > on the values, or do not allow the removal of elements of the array! > > > > > > Can anyone offer a clue bat to a tired old array walker! > > > > > > Thanks > > > > > > Alan > > > > > > > > > ___ > > > 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php