Re: [PHP] MySQL, MD5 and SHA1
Andrew Ballard wrote: On Tue, Apr 21, 2009 at 8:34 AM, Grega Leskovsek mavri...@gmail.com wrote: provided I want to store hash of a password in MySQL ... Using MySQL, the whole check can be achieved with a SQL query, since the MD5 function is provided as part of the database query language ... Can I use also SHA1 or must I use MD5? Thanks in advance, -- When the sun rises I receive and when it sets I forgive - http://users.skavt.net/~gleskovs/ All the Love, Grega Leskov'sek I would encode the value in PHP and pass the hash to MySQL rather than passing the password in open text as part of the query and letting MySQL calculate the hash. That way the sensitive data has already been hashed and you don't have to worry about whether the communication between PHP and MySQL travels over an unencrypted network connection -- now or in the future. Andrew In addition, you don't want the password showing up in a general query log for the server. -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $_GET verses $_POST
Ron Piggott wrote: How do I know when to use $_GET verses $_POST? Is there a pre defined variable that does both? Ron One of the things usually left out of this discussion is the actual intended use for each of these. I submit the following 2 reference links: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.1 http://www.w3.org/2001/tag/doc/whenToUseGet.html -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Anyone know of a project like Redmine written in PHP?
mike wrote: On Wed, Mar 18, 2009 at 8:30 AM, Jan G.B. ro0ot.w...@googlemail.com wrote: Mantis is a pain in the a*** (for non technical persons). +1 had some annoying bugs, too. it's only really a bug tracker last i checked anyhow. trac or redmine is more what would be beneficial. OP asked for PHP. Trac is python and Redmine is Ruby. They've added twitter support, VCS support, and wiki support lately and are working on the major 1.2 upgrade now. -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Anyone know of a project like Redmine written in PHP?
mike wrote: On Wed, Mar 18, 2009 at 1:22 PM, Micah Gersten news.php@micahscomputing.com OP asked for PHP. Trac is python and Redmine is Ruby. They've added twitter support, VCS support, and wiki support lately and are working on the major 1.2 upgrade now. i am the OP :) i know. i was just adding trac as another example. Sorry, didn't notice it was you, but you did ask for PHP and Trac isn't. -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Anyone know of a project like Redmine written in PHP?
mike wrote: http://www.redmine.org/ Looks pretty useful; I want one in PHP though. Anyone? Mantis Bug Tracker has some of the features you are looking for: http://www.mantisbt.org/ -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: 2 forms, same page, 1st is file upload - works in IE, 'dies' in non-IE browsers
scubak1w1 wrote: Hello, Banging my head against this one... Briefly: - I have two forms on the same page - both forms are: action=?php print $_SERVER['PHP_SELF']; ? method=post - both forms gave unique ids - both forms have a hidden file of the type input type=hidden name=_add_new_module_details value=1 / which is checked directly below the form with an if(array_key_exists('_add_new_module_details', $_POST)) { ...} method - first form is a file upload - 2nd form is a details submit - submit button on 2nd form is only 'turned on' (via AJAX) once the user has uploaded file file - 2nd form validated fields contents, via an onsubmit - after 2nd form successuly submitted, head off back to another page In Internet Destroyer, the page works just fine (i.e., both forms fire as expected) In the non-IE browsers I have tried (Firefox, Chrome, Opera), the first form uploads the file properly, the 2nd form's submit is 'turned on' by AJAX - BUT the submit button on the 2nd form doesn't seem to do anything - i.e., the onsubmit is not being triggered, etc, etc help! smile Thanks in advance: GREG Have you checked the Javascript error console in Firefox? -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Replies to list - Was (Re: [PHP] PHP 5.2.9 - 5.2.9-1 and curl)
Jochem Maas wrote: we use Reply-All because hitting Reply doesn't reply to the list but to the OP ... and discussions should generally stay on the list. This is true unless you're reading the list as a newsgroup. :) -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Database Abstraction Class
Michael A. Peters wrote: Anywhoo, that being said, does anyone have a suggestion for a good database abstraction class? Preferably one that already has decent support for several open source databases? Try Doctrine: http://www.doctrine-project.org/ From the website: What is Doctrine? Doctrine is an object relational mapper (ORM) for PHP 5.2.3+ that sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication. -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Database Abstraction Class
Shawn McKenzie wrote: Micah Gersten wrote: Michael A. Peters wrote: Anywhoo, that being said, does anyone have a suggestion for a good database abstraction class? Preferably one that already has decent support for several open source databases? Try Doctrine: http://www.doctrine-project.org/ From the website: What is Doctrine? Doctrine is an object relational mapper (ORM) for PHP 5.2.3+ that sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains flexibility without requiring unnecessary code duplication. Wow, a proprietary language that I get to learn on top of the two that do the job and that I already know! Bonus! Not trying to be an ass, I haven't used doctrine, but they need some marketing help. My point is that the ability to write queries in a proprietary dialect is not really a feature. I think the point is, that you can use a DB engine neutral query language which improves portability. -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Frameworks
HallMarc Websites wrote: First time caller; long time listener.. I have been looking at various PHP MVC frameworks; Limb3, Symphony, Mojavi, Navigator, WACT, etc. I'm looking for any input anyone might have regarding which framework seems to be the most promising? Thanks, Marc I'm currently using Zend PHP Framework + Doctrine ORM. Symfony has a little better integration with Doctrine. I chose the Zend PHP Framework because of the rapid release schedule and large feature set. You might want to check the archives as this discussion has come up before. -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP Frameworks
Chetan Rane wrote: HI I also was looking for various frameworks and came across a very nice framework, which is feature rich as well as very fast You can see more details at http://www.yiiframework.com/ Chetan Dattaram Rane | Software Engineer | Persistent Systems chetan_r...@persistent.co.in | Cell: +91 94033 66714 | Tel: +91 (0832) 30 79014 Innovation in software product design, development and delivery- www.persistentsys.com -Original Message- From: Micah Gersten [mailto:news.php@micahscomputing.com] Sent: Monday, March 09, 2009 9:52 AM To: php-general@lists.php.net Subject: [PHP] Re: PHP Frameworks HallMarc Websites wrote: First time caller; long time listener.. I have been looking at various PHP MVC frameworks; Limb3, Symphony, Mojavi, Navigator, WACT, etc. I'm looking for any input anyone might have regarding which framework seems to be the most promising? Thanks, Marc I'm currently using Zend PHP Framework + Doctrine ORM. Symfony has a little better integration with Doctrine. I chose the Zend PHP Framework because of the rapid release schedule and large feature set. You might want to check the archives as this discussion has come up before. Please keep on list by hitting reply-all. Someone else already mentioned yii framework. -- Micah -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax
Martin Zvarík wrote: Chris napsal(a): Terion Miller wrote: Need syntax help when it comes to using a timestamp. What I'm trying to say in my query WHERE clause is to select records if the timestamp on the record is in the past 7 days from NOW() $query .= WHERE stamp NOW()-7 ; I have no clue here on this the lay language is WHERE stamp is within the past 7 days how to php that? lol Has nothing at all to do with php. http://dev.mysql.com/doc/refman/5.0/en/datetime.html http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html $query .= WHERE stamp .(time()-7*3600*24); Using something like that is disastrous for DST and Leap Seconds... Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Having Trouble With Session Variable in Query Statement
Paul M Foster wrote: On Mon, Feb 23, 2009 at 12:34:58PM -0800, revDAVE wrote: Hi folks, I'm trying to make an update query with a session variable... It creates this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in ... Q: the session var shows ok on the page : ID ?php echo $_SESSION['now_poid']; ? - so how do I fix the error? == ?php require_once('../Connections/dblink.php'); if(!session_id()) session_start(); $amt = 18; $id1 = 8; $_SESSION['thisid']=8; $id2 = $_SESSION['thisid'] ; //these 3 work $updateSQL =UPDATE `mytable` SET thetotal=$amt WHERE id=8; $updateSQL =UPDATE `mytable` SET thetotal=$amt WHERE id=$id1; $updateSQL =UPDATE `mytable` SET thetotal=$amt WHERE id=$id2; // uses $_SESSION['thisid'] //but this does not.. $updateSQL =UPDATE `mytable` SET thetotal=$amt WHERE id=$_SESSION['thisid']; Don't single quote values inside array brackets when the whole expression is in double quotes. You've got: ... $_SESSION['thisid']; Do this instead: ... $_SESSION[thisid]; Paul Better off doing this so you don't get into the habit of not using quotes around array params: ... {$_SESSION['thisid']}; See this: http://us2.php.net/manual/en/language.types.string.php#language.types.string.parsing Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com
Re: [PHP] php validate user password
onlist this time... tedd wrote: snip I think the MD5() hash is a pretty good way and if the weakness is the user's lack of uniqueness in determining their passwords, then we can focus on that problem instead of looking to another hash. And besides, the solution presented was to create a salt and use that -- that's just another step in the algorithm process not much different than what I propose. Cheers, tedd The MD5 hash IS the problem. The problem isn't the uniqueness of the passwords, but rather the uniqueness of the hash. The solution is to use another hash that does not have the same collision issues. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] CLI not obeying php.ini
Philip Thompson wrote: In my php.ini, I have error_reporting = E_ALL ~E_NOTICE When I run a script from the command line, I get a lot of notices even when I said I don't want them. Also, in my script, I specified error_reporting(E_ERROR) in attempts to explicitly tell it what I want. It doesn't work either. Why am I still getting notices?! BTW, I don't receive notices via a web browser, just CLI. I double-checked to see what INI file was loaded and it's the one I expected to see: [pthomp...@pthompson scripts]$ php --ini Configuration File (php.ini) Path: /etc Loaded Configuration File: /etc/php.ini Thoughts on what's happening would be awesome! Thanks in advance. ~Philip Run this to find out which ini file is being parsed: php -i | grep ini Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] Mutiple SQL request
Jim Lucas wrote: snip I would add a second column to that admin_lastping KEY KEY `admin_lastping` (`admin_lastping`, `admin_id`) Since you are using both columns in your where clause, they both need to be specified /in the same/ index for and index to be used. Otherwise, some random index might be used. But you will get the best performance if both are listed in the same index. This is definitely not true in MySQL 5 and I'm sure other RDBMS systems. MySQL 5 can use more than 1 index per table now. Also, if you're using the InnoDB engine, the Primary Key is stored in the secondary index, so specifying it explicitly is unnecessary. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MicroSlow Software (was: Re: Hidden costs of PHP arrays?)
Clancy wrote: One could reasonably hope that the same could be said for every part of the programming chain, but it is one of the ironies of modern computing that computers get faster and faster, memory gets cheaper and cheaper, programming appears to get simpler and simpler, yet the programs get slower and slower. I have a fairly modern (maybe 2yo) computer, and use XP professional 5.1. Not long ago I switched to Office 2007 12.0, and when I did so I was appalled to discover that if I had a document loaded into Word, and hit Ctrl A, I could watch the highlighting scroll down the screen! As a former assembly language programmer I have some idea of the vast amount of thumb twiddling which is going on behind-the-scenes when I make some apparently simple request like the one to get my phone number. Undoubtedly most of this occurs in the murky depths of the operating system, but if there were any simple way to avoid adding to it unnecessarily it would be nice to know about it. I would venture to say that it's Microsoft Software that is slower with every release. PHP, Apache, MySQL, and Linux always improve their newer builds for speed whenever possible. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New PHP User with a simple question
Paul M Foster wrote: On Mon, Jan 26, 2009 at 12:03:20AM -0600, Micah Gersten wrote: Paul M Foster wrote: snip In case this has yet to be answered to your satisfaction... Your page will *have* to reload when the user presses the button, but the majority of content can look the same, except for the content you want to change. /snip This is absolutely not true. You can make the button call a PHP script with AJAX and just update the textbox. Check out: http://xajaxproject.org Please show me how *without Javascript* and *only with PHP* you can change the content on a page interactively as the user described *without* reloading the whole page. Xajax contains Javascript, which is how it manages this feat. For Pete's sake people, this is a *new* PHP user who wanted a *simple* solution to a relatively simple webpage problem. He's not looking for a Javascript solution, or a framework solution, or an OOP solution. He's not necessarily looking for a bulletproof, high security solution. He's a *new* PHP user. He just wants to figure out how to do this simple thing. Give him a *simple* answer. If you have to give him provisos about security, OOP, or Javascript afterward, fine. Paul I'm not saying that he should use it. I'm saying that *YOUR *claim was false. You should watch what you say. You said you *HAVE* to reload which is not true. I said nothing about without JavaScript. I agree that he shouldn't necessarily use that. That's why I snipped his stuff out and just quoted you. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com
Re: [PHP] New PHP User with a simple question
Paul M Foster wrote: On Mon, Jan 26, 2009 at 12:53:55PM -0600, Micah Gersten wrote: Paul M Foster wrote: snip Please show me how *without Javascript* and *only with PHP* you can change the content on a page interactively as the user described *without* reloading the whole page. Xajax contains Javascript, which is how it manages this feat. For Pete's sake people, this is a *new* PHP user who wanted a *simple* solution to a relatively simple webpage problem. He's not looking for a Javascript solution, or a framework solution, or an OOP solution. He's not necessarily looking for a bulletproof, high security solution. He's a *new* PHP user. He just wants to figure out how to do this simple thing. Give him a *simple* answer. If you have to give him provisos about security, OOP, or Javascript afterward, fine. Paul I'm not saying that he should use it. I'm saying that *YOUR *claim was false. You should watch what you say. You said you *HAVE* to reload which is not true. I said nothing about without JavaScript. I agree that he shouldn't necessarily use that. That's why I snipped his stuff out and just quoted you. Since he asked the question on a *PHP* list, I assumed he wanted a *PHP* solution, not a Javascript one. I also assumed that the OP was not a Javascript programmer, since as a Javascript programmer, the solution should have been obvious in Javascript. Ergo, my statements were in the context of a *PHP* solution to his question. Moreover, his question indicated that he didn't understand some basic fundamentals of the PHP execution model. Throwing a framework or Javascript solution at him would have been like putting a 14 year old behind the wheel of a Ferrari. But fair warning to all list members and future newbies who post here: If you ask for a solution on *this* list, and you give indications that you're not familiar with how PHP works with HTTP and HTML, then I will give you a PHP-based solution, and avoid Javascript, Java, C, Perl, Python, Ruby, Ruby on Rails, .NET, C++, C#, ECMAScript, Algol, PL/1, assembler, APL, Fortran, COBOL, frameworks and other assorted odds and ends which *might* do what you want, but aren't what you asked for. (Of course, I might give you a LISP/Scheme solution, though. ;-) Paul It's fine if you want to give a pure PHP solution, but please don't make false statements when doing so. Keep in mind that there are archives and someone reading them might think something is impossible when it in reality is very simple. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dirty Button
tedd wrote: At 7:02 PM + 1/25/09, Ashley Sheridan wrote: Tedd, what about having it reset if you then go back and select the original option without submitting, i.e. you originally selected and submitted on A, then selected B, then selected A again? That's a good idea. Now I just have to figure out how to make it all-encompassing enough to handle one, or more, selection-control and compare current values with the values that were previously selected. Oh, the holes we dig for ourselves. :-) Cheers, tedd What about an onChange javascript function that checks all the boxes that need input. Call it whenever any of the inputs change and in the onSubmit for the form, check it again. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New PHP User with a simple question
Paul M Foster wrote: snip In case this has yet to be answered to your satisfaction... Your page will *have* to reload when the user presses the button, but the majority of content can look the same, except for the content you want to change. /snip This is absolutely not true. You can make the button call a PHP script with AJAX and just update the textbox. Check out: http://xajaxproject.org Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: 64bit vs. 32bit
Ross McKay wrote: You'll also use a little more RAM due to pointer and integer sizes. However, Linux will be able to address more RAM on a 3GB system. Linux can already address all the RAM on a 32 bit system with PAE. The advantage of 64 bit with regards to RAM is that a single process can address more than 2.5 - 2.7 GB of RAM. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing HTML href-Attribute
Depending on the goal, using the base tag in the head section might help: http://www.w3.org/TR/REC-html40/struct/links.html#h-12.4 Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Edmund Hertle wrote: Hey, I want to parse a href-attribute in a given String to check if there is a relative link and then adding an absolute path. Example: $string = 'a class=sample [...additional attributes...] href=/foo/bar.php '; I tried using regular expressions but my knowledge of RegEx is very limited. Things to consider: - $string could be quite long but my concern are only those href attributes (so working with explode() would be not very handy) - Should also work if href= is not using quotes or using single quotes - link could already be an absolute path, so just searching for href= and then inserting absolute path could mess up the link Any ideas? Or can someone create a RegEx to use? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Security question
Frank Stanovcak wrote: VamVan vamsee...@gmail.com wrote in message news:12eb8b030901141421u6741b943q396bc784136b7...@mail.gmail.com... On Wed, Jan 14, 2009 at 2:22 PM, Frank Stanovcak blindspot...@comcast.netwrote: This is mostly to make sure I understand how sessions are handled correctly. As far as sessions are concerned the variable data is stored on the server (be it in memory or temp files), and never transmitted accross the net unless output to the page? So this means I should be able to store the username and password for a program in session vars for quick validations, and if I force rentry of the password for sensitive areas (every time) even if someone mannages to spoof the sesid all they will have access to is non sensitive areas? This also assumes I, at least, quick validate at the start of every page immideately after starting the session. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Password should never be stored anywhere in clear text. You can store md5 version in session or database. As long as password is encrypted ure fine and safe. Thanks, V Thanks V So if I store the hash in the db, and in the session var then I should be resonably safe provided I salt the hash prior to storing it? Yes, but don't use md5. There are lookups available to help someone crack it. Try sha1: http://us3.php.net/sha1 Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch vs elseif
Jochem Maas wrote: switch (true) { case ($x === $y): // something break; case ($a != $b): // something break; case (myFunc()): // something break; case ($my-getChild()-hasEatenBeans()): // something break; } evil ... but it works. This is a misuse of the switch statement. Switch is meant to compare values to a single variable as stated on the manual page: http://us2.php.net/switch Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Unique Object Instance ID..?
Can you use something like APC to cache the instance variable so that it's persistent across different sessions? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Nathan Rixham wrote: Colin Guthrie wrote: 'Twas brillig, and Nathan Rixham at 10/01/09 23:31 did gyre and gimble: all I need is a completely unique id for each object instance that can never be repeated at any time, even in a multiserver environment (and without using any kind of incremented value from a db table or third party app) thoughts, ideas, recommendations? While it's not guaranteed to be unique the general technique used in these situations is to use a UUID. The chances of a clash are slim (2x10^38 ish combinations). You can generate a uuid via mysql SELECT UUID() or via the PHP Pecl extension php-uuid. The other way of doing it would be to insert a row into a database row with an auto-increment field and use the value of that auto-incrment field as your identifier (SELECT LAST_INSERT_ID() in mysql or via the db layers API). HTHs Col cheers for the input; uuid it has to be I guess; don't want it reliant on any third party software or db so pecl is out, as is mysql - looks like I'm going to have to (and probably enjoy) making a uuid function to generate type 4 random uuids. only other thought is to combine all the instance variables, hash the combination of them and save that together with a timestamp.. considering -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot
Richard Heyes wrote: it' may seem like a small amount of space but when you have 8 char(255) columns in a table with 10 million rows you'd noticed the difference considerably. It is a small amount of space. Perhaps it was necessary in the days when 1Gb Hdds were a luxury, but those days are long gone. In the example you gave you're still only wasting approx 1 GB. Hardly a lot these days when you consider you buy a consumer 500Gb Hdd for £50. You also have to remember that server drives are more expensive as they are of higher quality than consumer disks. They require a lot more MTBF than your normal hard drive at your local computer store. Also, if you waste 1GB in 1 column, imagine how much wasted space there is in the whole DB. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot
Nathan Rixham wrote: Richard Heyes wrote: Also I could be missing something, but I can't see the advantage in VARCHAR since space is not really a concern these days. char is fixed length and padded. If you don't fill up the space, the db does it for you (even though it seems it's internal only). http://dev.mysql.com/doc/refman/5.0/en/char.html When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed. So where's the advantage of VARCHAR ? storage size richard, as if you use char(100) then a string(4) will still use the space of string(100); whereas with varchar(100) it's only take up it's real space of string(4). it' may seem like a small amount of space but when you have 8 char(255) columns in a table with 10 million rows you'd noticed the difference considerably. Actually string(4) in a varchar(100) will take up 5 bytes, but that's still better than 100. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] (auto) session expire
Shiplu wrote: This is a very common issue. I searched and found many sites talking about this. but no good solution. Well the problem is I want to set my session will expire after 10 minutes of inactivity. Just like an banking site. When user is inactive for 10 minutes the session will expire. In fact the browser will delete the cookie. The browser will delete the cookie because it was told by the server. I used these lines session_cache_expire(APP_SESSION_TIMEOUT); session_set_cookie_params(APP_SESSION_TIMEOUT*60); ini_set(session.gc_maxlifetime, APP_SESSION_TIMEOUT * 60); session_start(); It runs at the very beginning of my application. APP_SESSION_TIMEOUT has value 10 which is in minutes. The problem is it works good in FF3. But not in IE. Any Idea how to resolve it? or any standard way to fix it? Why are you setting the session max lifetime on the server to 60 * your timeout? Set it to your timeout and the server will get rid of the session. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot
Frank Stanovcak wrote: It's been a while since I've programed (VB was on version 4) I was wondering if any one could tell me what the diff is between char, varchar, and text in mysql. I know this isn't a mysql news group, but since I am using php for the interaction it seemed like the place to ask. Thanks in advance, and have a great day! Frank As nice as the guys on the list are, this will be most accurate: http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot
Ross McKay wrote: First, start here: http://dev.mysql.com/doc/refman/5.1/en/string-types.html Stuart wrote: varchar: only the space required for the content of the field is allocated per row but these fields are limited to 255 chars (IIRC) in length. In MySQL, varchar can hold up to 65,535 characters, but the actual maximum size is limited by the maximum row length (65,535 bytes) and the character set (e.g. utf8 uses between one and three bytes per character). Maybe you're thinking of char, which is limited to 255 characters. You're referencing the 5.1 manual. In the 5.0 manual it says that VARCHAR was extended to 65535 in 5.0.3, so you're statement is not entirely correct, nor was Stuart's. That's why I linked him to the 5.0 manual page on data types. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A beginner´s question
Nathan Rixham wrote: Eduardo wrote: Hi, I am Eduardo, a new PHP programmer and an old Cobol veteran. I know that $tastes=$_POST[tastes]; moves the content of tastes from ptextarea rows=5 name=tastes cols=28/textarea/p to $tastes How do I move the content of $tastes to X of echo textarea rows=5 cols=28 readonly name=X\n; ? Thanks, Eduardo echo textarea rows=5 cols=28 readonly name= . $tastes . \n; echo this is how you echo a . $variable . in a string; While that is true, that's probably not what the OP wants. He's probably looking for: echo textarea rows=5 cols=28 readonly name=tastes$tastes/textarea\n; Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A beginner´s question
Micah Gersten wrote: Nathan Rixham wrote: Eduardo wrote: Hi, I am Eduardo, a new PHP programmer and an old Cobol veteran. I know that $tastes=$_POST[tastes]; moves the content of tastes from ptextarea rows=5 name=tastes cols=28/textarea/p to $tastes How do I move the content of $tastes to X of echo textarea rows=5 cols=28 readonly name=X\n; ? Thanks, Eduardo echo textarea rows=5 cols=28 readonly name= . $tastes . \n; echo this is how you echo a . $variable . in a string; While that is true, that's probably not what the OP wants. He's probably looking for: echo textarea rows=5 cols=28 readonly name=tastes$tastes/textarea\n; Thank you, Micah Gersten As Vicente pointed out, there was a problem with what I posted, so here's the fixed version: echo 'textarea rows=5 cols=28 readonly name=tastes',$tastes,/textarea\n; Explanation: Single quotes save from backslashing the quotes. Commas save the concatenation overhead. Quotes around the last block since it uses \n which needs doublw quotes to output. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A beginner´s question
Vicente wrote: ptextarea rows=5 name=tastes cols=28/textarea/p eps, sorry.. Micah Gersten is right. You will need the echo among them. textarea rows=5 name=tastes cols=28 ? echo $tastes;? /textarea Yep, but you caught the quotes mix-up. :) Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IE Problem Detecting Post Variables
Ashley Sheridan wrote: On Fri, 2009-01-02 at 18:06 -0500, Andrew Ballard wrote: On Fri, Jan 2, 2009 at 1:15 PM, Micah Gersten mi...@onshore.com wrote: You might want to consider the button element which allows you to display images, but doesn't send back coordinates. Instead it sends a preset value. http://www.w3.org/TR/html401/interact/forms.html#h-17.5 Thank you, Micah Gersten If you mean an INPUT element with the type=button, then yes. (Although it will no longer be a submit button, so you'll have to capture the click and perform the submit using Javascript which leads back to accessibility issues, etc.) If you mean a BUTTON element of the type=submit, then not exactly. It *will* send a preset value for sure, but that preset value will differ depending on the browser. I've found that while FF will send the value you set in the value=... attribute, IE will send the actual text of the button. Thus, button name=test value=blueMy Button Text/button will send 'test=blue' in FF, but 'test=My+Button+Text' in IE. I'm assuming this is because for INPUT type=submit buttons, the text content of the button IS the value in the value=... attribute. Whatever the reason, that was a fun lesson to track down the first time I had people tell me a page I wrote didn't work in IE. Andrew Lets all march forward and renounce IE as a useful piece of software! Ash www.ashleysheridan.co.uk Agreed. According to the spec, the FF action is correct. I just heard IE's user share dropped below 70%. One day we will hopefully be able to say goodbye to it. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IE Problem Detecting Post Variables
You might want to consider the button element which allows you to display images, but doesn't send back coordinates. Instead it sends a preset value. http://www.w3.org/TR/html401/interact/forms.html#h-17.5 Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com L. Herbert wrote: I find the html/php option simpler and more accessible. I've got it working now. I only needed to use unique input names and test for the posted variable according to w3c standards. Here is the relevant w3c definition: When a pointing device is used to click on the image, the form is submitted and the click coordinates passed to the server. The x value is measured in pixels from the left of the image, and the y value in pixels from the top of the image. The submitted data includes name.x=x-value and name.y=y-value where name is the value of the name attribute, and x-value and y-value are the x and y coordinate values, respectively. PHP modifies the posted variable name to name_x, name_y to comply with PHP's variable naming convention requirements. Thanks to those all responded for pointing me in the right direction. On Jan 1, 2009, at 11:25 AM, Phpster wrote: What about using the onclick to set a js variable to be sent to the server? That should be more cross server compliant. Bastien Sent from my iPod On Dec 31, 2008, at 8:37 PM, L. Herbert lherb...@iluvmydesign.com wrote: Bastien, Thanks for your response. The curious thing is that the value is passed when using FF, but not passed when using IE. Here is the relevant form html: div id=switch-theme form action= method=post labelFlip It!/label input name=style type=image src=images/switch-button-grey.gif title=Default Theme id=style1 value=default / input name=style type=image src=himages/switch-button-default.gif title=Alternate Theme id=style2 value=alternate / /form /div The action attribute is left blank so the form posts to the current page. The theme switcher script is at the top of each page and intercepts the posted variables. Any thoughts? On Dec 31, 2008, at 11:02 AM, Phpster wrote: Try checking to see if the value was passed with var_dump($_REQUEST) Also try (!empty($_REQUEST['style'])) Bastien Sent from my iPod On Dec 31, 2008, at 10:24 AM, L. Herbert lherb...@iluvmydesign.com wrote: Hello all, Anyone have insight to share on the following issue: I have a simple theme switcher script that functions as expected in FF, Safari, etc. but does not work in IE 6 or 7. It appears that the posted form variables are not detected in IE. I am using the following check within the script: if(isset($_REQUEST['style'])) { $style = $_REQUEST['style']; } Thanks in advance for your assistance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP telnet server
Luke Slater wrote: Hi everyone, I'm trying to rewrite an old MUD in PHP; the reasons for this are that the original is written in C and most files in the codebase run over 2000 lines with at least 20 of them, which makes it very hard to change anything. Plus, the web interface is also written in C, and needless to say that's just nasty! So I was looking at sockets in PHP, and thinking about the semantics of it all. I was looking at this article: http://devzone.zend.com/article/1086-Writing-Socket-Servers-in-PHP And thought 'wow this looks like it might be pretty easy actually!' But then I reached the first hurdle point: ' /* Accept incoming requests and handle them as child processes */ $client = socket_accept($sock); ' Surely the point of a MUD is that the requests are shared? I also looked up telnet servers in PHP on google quite extensively, and there seems to be no real information out there? I would imagine that I'm looking for the wrong thing, however. In short I'm looking for the basic idea on how a MUD server would be implemented in PHP. Thanks in advance for anything, Luke Slater How about AJAX and sessions instead of having TCP sockets? http://xajaxproject.org/ Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] =.='' what wrong ? just simple code, however error.
http://us3.php.net/manual/en/function.number-format.php Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com LKSunny wrote: i need accuracy, how to ? Thank You. Per Jessen p...@computer.org ¼¶¼g©ó¶l¥ó·s»D:gjg4fk$58...@saturn.local.net... LKSunny wrote: ? $credithold = 100; for($i=1;$i=1000;$i++){ $credithold -= 0.1; echo $creditholdbr /; } //i don't know why, when run this code, on 91.3 after expect is 91.2, however..91.2001 //who can help me ? and tell me why ? It's a floating point rounding error. If you don't need the accuracy, just round it to what you need. /Per Jessen, Zurich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IE Problem Detecting Post Variables
L. Herbert wrote: The problem is that the variable is passed in one instance with FF and not with IE. Thus my quandary. Here's the form html: div id=switch-theme form action= method=post labelFlip It!/label input name=style type=image src=images/switch-button-grey.gif title=Default Theme id=style1 value=default / input name=style type=image src=himages/switch-button-default.gif title=Alternate Theme id=style2 value=alternate / /form /div Any thoughts? How is this being submitted? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] system() Question
Nathan Nobbe wrote: On Sun, Dec 28, 2008 at 8:40 PM, Micah Gersten mi...@onshore.com mailto:mi...@onshore.com wrote: Nathan Nobbe wrote: good point dan, and just to add further clarification, thats b/c the function specifies $return_var is passed by reference in the formal parameter. when you include the along w/ an actual parameter (during function invocation) thats referred to as call-time-pass-by-reference in php, and its typically frowned upon. in fact, i think its being removed from a future version of php. -nathan You don't call system using the ampersand. The reference is declared in the function definition. There's no reason for this to be frowned upon. well i dont think they deprecated it for shits--giggles. http://us.php.net/manual/en/language.references.pass.php its disabled by default in php.ini; wonder why.. ;) What you are referring to is the old PHP4 style of explicit pass-by-reference in function usage which is frowned upon. no im referring to call-time-pass by reference, which works just as well in php5; as long as you enable it in php.ini (or one of the other various ways). and also, for clarification, marking parameters as pass-by-reference works during method definition in php4 as well, of course. -nathan I think I was confused here about your response. After re-reading a few times, I see that you were enhancing Dan's response by explaining what call-time pass by reference is, not saying that the function is used that way. My apologies. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about version control.. sorta..
Richard Heyes wrote: The other issue is that I run Windows. So if there's something nice and WinGUI, that'd be nice. Please no you should be running linux You should be running linux. Muhaha. responses. I don't have anything against Linux or Mac, they're great systems. But I have my reasons for running Windows. There's definitely a Gui for CVS. TurtleCVS IIRC. Presumably there's one for SVN. TortoiseCVS and TortoiseSVN on Windows Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] system() Question
Nathan Nobbe wrote: good point dan, and just to add further clarification, thats b/c the function specifies $return_var is passed by reference in the formal parameter. when you include the along w/ an actual parameter (during function invocation) thats referred to as call-time-pass-by-reference in php, and its typically frowned upon. in fact, i think its being removed from a future version of php. -nathan You don't call system using the ampersand. The reference is declared in the function definition. There's no reason for this to be frowned upon. What you are referring to is the old PHP4 style of explicit pass-by-reference in function usage which is frowned upon. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] runtime access to static variable
Jack Bates wrote: How do I access a static variable when I do not know the name of the class until runtime? I have the following example PHP: ket% cat test.php ?php class Test { public static $STEPS = array( 'foo', 'bar'); } $className = 'Test'; var_dump($className::$STEPS); ket% Unfortunately when I run it I get: ket% php test.php Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /home/jablko/trash/test.php on line 13 ket% I can call a static function using call_user_func(array($className, 'functionName')), and I can access a class constant using constant($className.'::CONSTANT_NAME'). How do I access a static variable? Check this out: http://us2.php.net/manual/en/language.oop5.static.php It actually won't work until 5.3.0 when they add late static binding. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Phpmyadmin password
It flance wrote: Hi, I lost phpmyadmin password. Is there anyway to recover it? Thank you PHPMyAdmin uses MySQL's internal authentication. Log into your MySQL server and reset your password. http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good PHP book?
O'reillys Learning PHP 5: http://oreilly.com/catalog/9780596005603/index.html Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com jeffery harris wrote: Hi guys/gals. I'm a first time user. Does anyone know of a good php book? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Foreign Keys Question
Colin Guthrie wrote: The ON DELETE CASCADE option is key here... DELETE FROM students where student_id=1 will remove all traces of that student from the db... all the course they've attended, all the instructors who have taught them etc. keeps things nice and tidy without having to put the structure in your code all over the place. Col Why would you want to delete the instructors when deleting the student? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dates and Mysql
VamVan wrote: Hello Gang, I have a Mysql table which has timestamp for the date the record was created. I was wondering how is it possible for me to query the table to retrieve all the records that are one week less than the time stamp? Thanks, V I'm assuming you meant get records one week less than the current system timestamp. date('Y-m-d G:i:s', strtotime('1 week ago')); Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
Robert Cummings wrote: On Tue, 2008-12-09 at 00:16 +, Nathan Rixham wrote: Ashley Sheridan wrote: On Mon, 2008-12-08 at 23:23 +, [EMAIL PROTECTED] wrote: Presumable, the EXISTS sub-query can be optimized sometimes to just stop processing the sub-query and kick things back out to the outer query. IN has to process them all and find them all. Don't forget the special case use as well: IF NOT EXISTS `universe` THEN bigbang() Ash www.ashleysheridan.co.uk any chance of writing the implementation of that bigbang() function? If nothing exists and a universe is created via a big bang... does it make a sound? Can we realistically call it a big bang if it doesn't make a sound? Couldn't we call it the big light show? But then again... if nothing exists and a universe is created via a big light show... does it matter? Can it be perceived? Is this just a proverbial pandrödinger's box? You can't implement the bigbang() function if you don't exist. Cheers, Rob. The function doesn't say who's doing the creating, it just checks for the existence of the universe. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
Robert Cummings wrote: On Mon, 2008-12-08 at 19:46 -0600, Micah Gersten wrote: Robert Cummings wrote: On Tue, 2008-12-09 at 00:16 +, Nathan Rixham wrote: Ashley Sheridan wrote: On Mon, 2008-12-08 at 23:23 +, [EMAIL PROTECTED] wrote: Presumable, the EXISTS sub-query can be optimized sometimes to just stop processing the sub-query and kick things back out to the outer query. IN has to process them all and find them all. Don't forget the special case use as well: IF NOT EXISTS `universe` THEN bigbang() Ash www.ashleysheridan.co.uk any chance of writing the implementation of that bigbang() function? If nothing exists and a universe is created via a big bang... does it make a sound? Can we realistically call it a big bang if it doesn't make a sound? Couldn't we call it the big light show? But then again... if nothing exists and a universe is created via a big light show... does it matter? Can it be perceived? Is this just a proverbial pandrödinger's box? You can't implement the bigbang() function if you don't exist. Cheers, Rob. The function doesn't say who's doing the creating, it just checks for the existence of the universe. How do you know? Are you... God? ;) Cheers, Rob. Sorry, term foul-up. I meant the statement doesn't say who's doing the creating, it just checks for existence of the universe. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A MySQL Question
German Geek wrote: On Tue, Dec 9, 2008 at 2:46 PM, Micah Gersten [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Robert Cummings wrote: On Tue, 2008-12-09 at 00:16 +, Nathan Rixham wrote: Ashley Sheridan wrote: On Mon, 2008-12-08 at 23:23 +, [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Presumable, the EXISTS sub-query can be optimized sometimes to just stop processing the sub-query and kick things back out to the outer query. IN has to process them all and find them all. Don't forget the special case use as well: IF NOT EXISTS `universe` THEN bigbang() Ash www.ashleysheridan.co.uk http://www.ashleysheridan.co.uk any chance of writing the implementation of that bigbang() function? If nothing exists and a universe is created via a big bang... does it make a sound? Can we realistically call it a big bang if it doesn't make a sound? Couldn't we call it the big light show? But then again... if nothing exists and a universe is created via a big light show... does it matter? Can it be perceived? Is this just a proverbial pandrödinger's box? You can't implement the bigbang() function if you don't exist. Cheers, Rob. The function doesn't say who's doing the creating, it just checks for the existence of the universe. Lol, I agree, the function bigbang() doesn't need to be implemented (or it could be empty if it needs to be there for this line to work), because by definition, the universe must exist, if this statement is to exist. Who says this statement is run in this universe? Who says it's not for a simulator? Guys, I think this is taking it a bit far... You new here? ;) Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Objects and Arrays Conversion
VamVan wrote: Hello All, I was stuck with this issue. So just felt the need to reach out to other strugglers. May be people might enjoy this: Here is the code for object to array and array to object conversion: function object_2_array($data) { if(is_array($data) || is_object($data)) { $result = array(); foreach ($data as $key = $value) { $result[$key] = object_2_array($value); } return $result; } return $data; } function array_2_object($array) { $object = new stdClass(); if (is_array($array) count($array) 0) { foreach ($array as $name=$value) { $name = strtolower(trim($name)); if (!empty($name)) { $object-$name = $value; } } } return $object; } have fun ! Thanks This page at the bottom describes your array_2_object function as a simple typecast: http://us2.php.net/manual/en/language.types.object.php $object = (object) $array; As for the object to array, the same thing applies: http://us2.php.net/manual/en/language.types.array.php $array = (array) $object; Not sure if these are PHP 5 only or not. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about corrupt db?
Terion Miller wrote: could a corrupt db make php pages stop functioning? My pages no longer go anywhere, I went back found the original scripts and still it didn't fix the problem (thought I had messed the code up) so it has to be something external of the code its doing this locally on my box and on the live server. thanks terion Have you checked the PHP error logs? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array/iteration issue!!
Robert Cummings wrote: On Thu, 2008-11-27 at 19:36 -0800, bruce wrote: hey robert!! thanks. and yeah, you're right, it's not the best.. so tell me, given that i'm ripping through this on the fly, and i can have the structure in any way i choose. this is just to simulate/populate some test tbls.. what's a better way to create an array structure to have a collegename, followed by some deptnames, followed by some classnames for the depts... perhaps something like this?? $a = array ( college = foo, array ( dept = physics, class = array ( class1 = sss, class2 = sffgg ) ), array ( dept = english, class = array ( class1 = sss, class2 = sffgg ) ) ); Not quite. The following is probably what you want: ?php $colleges = array ( array ( 'name' = 'Blah Blah University', 'depts' = array ( array ( 'name'= 'physics', 'classes' = array ( 'sss', 'sffgg', ), ), array ( 'name'= 'english', 'classes' = array ( 'sss', 'sffgg', ), ), ), ), array ( 'name' = 'Glah Gleh University', 'depts' = array ( array ( 'name'= 'physics', 'classes' = array ( 'sss', 'sffgg', ), ), array ( 'name'= 'english', 'classes' = array ( 'sss', 'sffgg', ), ), ), ), ); foreach( $colleges as $college ) { $collegeName = $college['name']; foreach( $college['depts'] as $dept ) { $deptName = $dept['name']; foreach( $dept['classes'] as $className ) { echo $collegeName, $deptName, $className\n; } } } ? Cheers, Rob. This is actually a much smaller data structure. $colleges = array ( 'Blah Blah University' = array ( 'physics' = array ( 'sss', 'sffgg', ), 'english' = array ( 'sss', 'sffgg', ) ), 'Glah Gleh University' = array ( 'physics' = array ( 'sss', 'sffgg', ), 'english' = array ( 'sss', 'sffgg', ), ) ); foreach( $colleges as $collegeName = $depts ) { foreach( $depts as $deptName = $classes) { foreach( $classes as $className ) { echo $collegeName, $deptName, $className\n; } } } Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: anchor name on URL
Ashley Sheridan wrote: On Tue, 2008-11-18 at 23:51 +, Richard Heyes wrote: Yeah, but it will mean that there will still be about 3 different rendering versions of IE out there by the time it comes out; 7, 8 and 9 (I'm fairly sure 6 will have gone to that good ol' web in the sky by that time) Sure, but depending on how closely it follows WebKit, could make testing on IE9, Safari and Chrome a breeze. -- Richard Heyes Don't forget Konqueror in that list ;) It's not exactly the same engine after Apple forked it from KHTML, but it's quite close, and both Konqueror and Safari are said to be working a little more closely than before to share the work done to the rendering engines since the fork. I'm waiting for the day when Firefox starts using Google's V8 scripting engine! Ash I'd rather all the engines follow the W3C standards so that you just have to make sure your web page is compliant. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] while question
Jay Blanchard wrote: [snip] ...foreach... [/snip] You could also use a for loop if you wanted to count; for($i = 0; $i count($array); $i++){ echo $i . \n; } This is not good because you are calling count every loop iteration. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PECL HTTP Extension
Perhaps you should try the PECL list: [EMAIL PROTECTED] Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Rui Quelhas wrote: Since i'm not obtaining any kind of response from people o first answered me. I guess is better to talk through here. To my first message, Micah Gersten asked me if i've placed the extension path on 'php.ini' my answer was yes, i've tried to do that but it still wasn't loading the extension. Jochem Maas advised me to place the complete path to the extension like this 'extension=/usr/lib/php/extensions/no-debug-non-zts-20060613/http.so', i've also tried it, again with no success. In the last response, Thodoris told me to place in the php.ini the line 'extension_dir=.;/usr/lib/php/extensions/no-debug-non-zts-20060613;/usr/lib/php/modules', adding again the extension directive 'extension=http.so'. Well, seems like there is no such path like '/usr/lib/php/modules', for the sound of it, the closest match i get is '/usr/include/php/ext/' (path with the header files of each extension) or '/usr/libexec/apache2' (path also with '.so' files regarding apache modules). Either way, i've changed the unexisting path by each one of these and again nothing happened. I don't know what else i can do. Could somebody that has installed PECL extensions successfuly on Leopard help me? I just need to know what i must do in the inicialization files (php or apache) just like i was installing my first extension and having the fact that there is the native Leopard 'php.ini.default' already in place. Regards Rui Quelhas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange results
Craige Leeder wrote: So, I have this class which contains a method LoadIO. I was doing some debugging as to why a condition wouldn't pass like I thought it would, and It's starting to piss me off. The three echo's near the bottom are not printing what it should. The middle echo is not even printing static text. Here's the definition: /*** * Public Method LoadIO * INCOMPLETE * @param $fpType Integer * @param $fpName String * @throws FileException * @return Object *** * LoadIO handles the loading of IO modules. IO modules are stored in * - /system/IO/ // System IO files * - /IO/// User defined third party modules ***/ const mciInput = 0; const mciOutput = 1; public function loadIO($fpType, $fpName) { global $gcIOPath, $gcSystemPath; // // Check paramaters for syntatic validity // if ( $fpType != Ember::mciInput $fpType != Ember::mciOutput ) { throw new Exception('Invalid \'fpType\' paramater', 1002); } // // Variable assignment // $fType = ($fpType == self::mciInput) ? 'Input' : 'Output'; $fFile = $gcIOPath . $fType . '/' . $fpName . '.php'; // Check User IO Path first. // If it does not exist there, check the System IO Path if ( !file_exists($fFile) ) { $fFile = $gcSystemPath . 'IO/' . $fType . '/' . $fpName . '.php'; if ( !file_exists($fFile) ) { throw new Exception(File '$fpName.php' not found., 1001); } } if ( !(include_once $fFile) ) throw new Exception(File '$fFile' could not be included.); echo 'stage 1br /'; echo - $fpType - is equal to self::mciInput br /; echo 'stage 2br /'; if ( $fpType == self::mciInput ) { echo 5; array_push($this-maInput, new $fpName); echo 'it\'s done'; } } The Call: $Page-loadIO(Ember::mciOutput, 'html'); The Output: stage 1 0stage 2 HELP! I think you meant this: echo - $fpType - is equal to self::mciInput br /; to be echo - . $fpType . - is equal to . self::mciInput . br /; Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mySQL query question
If you're just adding one, there is no reason to retrieve the data, process it, and update it. You can just update the number. http://dev.mysql.com/doc/refman/5.0/en/update.html Also, you should read the MySQL manual on default values: http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Michael S. Dunsavage wrote: okay I want to pull an integer from a database called confirm_number, add 1 and repost it back to the database here's the code I'm using. $queryconfirm=SELECT confirm_number from contacts ORDER BY contact DESC LIMIT 1; $confirmresult=$queryconfirm; now here's the problem I want to add 1 to confirm_number: $confirm_number=$confirmresult; $confirm_number+=1; Now all this does is set the confirm_number record to 1 in the database. So I assume that $queryconfirm somehow is not being passed to confirm_number? But, while we're here the confirm_number is supposed to be 5 digits long and the +1 should make it 10001, 10002, 10003 etc how would I set the original number to 1000 to begin with? Or should I just set that in the database record its self when I'm ready to use the website? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Startup: Unable to load dynamic library
Thiago H. Pojda wrote: On Wed, Nov 12, 2008 at 2:21 PM, Thodoris [EMAIL PROTECTED] wrote: Although I don't develop under windows and I should say that this OS has been developing my allergies I would suggest to use WAMP. Which is Windows-Apache-MySQL-PHP enviroment that you might find very useful and it might make things easier for you. -- Thodoris Thodoris, I don't like developing on windows either, but I find it to be worse when using WAMP. When I first started developing PHP I used to use WAMP and also tried EasyPHP. Although things were easier at first, IMO they add too much stuff in conf files that make things confuse when you need to make some specific changes. Thanks for your suggestion :) You should try Xampp then. http://apachefriends.org They've segregated the apache config files to make things easier. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] pdt-2.0 error
Try the zend list: [EMAIL PROTECTED] Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com András Csányi wrote: Hi all! I don't know which is the right place to make an bugreport. I installed on my linux desktop the pdt-2.0 all-in-one but i have a nice, big exception. :( So, my question is, where can I send an bugreport? Thank you for help and patience! András -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: pdt-2.0 error
Maciek Sokolewicz wrote: András Csányi wrote: Hi all! I don't know which is the right place to make an bugreport. I installed on my linux desktop the pdt-2.0 all-in-one but i have a nice, big exception. :( So, my question is, where can I send an bugreport? Thank you for help and patience! András I've never heard of pdt whatever it is. It's definitly not a part of the PHP project, so to answer your question: not here. So, where you ask? tried to google it yet ? That's where... - Tul PDT is a plugin for the Eclipse Platform. The Zend people made a special PDT 2.0 All-in-one build, that's why I said the zend list. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PECL HTTP Extension
Rui Quelhas wrote: Hi guys. I'm running PHP 5.2.6 (cli) on Mac OS X 10.5.5 and i've tried to install and configure the http pecl extension like the tutorial in your web site, i've used pecl to install it, i've also tried to compile it manually. Everything got installed correctly, there is the http.so file in the extensions dir (/usr/lib/php/extensions/no-debug-non-zts-20060613/), the path is loaded by php/apache and i've added the line extension=http.so in php.ini file. However the extension isn't loaded by php. I've wrote a simple script that uses extension_loaded('http') function and i get a false response. I need to use desperatly functions like http_request(...) for a college project so i would appreciate a quick response from you. If you could just provide me with a more specific Leopard tutorial tha would be great. Giving an antecipated thank you for any kind of answer. Regards, and keep up the good work! Rui Quelhas Is that extensions directory in your path in php.ini? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents urlencode spaces: yeah right?
Dee Ayy wrote: PHP Version 5.1.6 $contents = file_get_contents(http://user:[EMAIL PROTECTED]/some/path/htmlfile.html); //WORKS $contents = file_get_contents(http://user:[EMAIL PROTECTED]/some/path/htmlfile with spaces.html); //FAILS(1) $contents = file_get_contents(http://user:[EMAIL PROTECTED]/some/path/nonhtmlfile.ext); //WORKS $contents = file_get_contents(http://user:[EMAIL PROTECTED]/some/path/nonhtmlfile with spaces.ext);//FAILS(2) $contents = file_get_contents(urlencode(http://user:[EMAIL PROTECTED]/some/path/eitherfile with spaces.ext)); //FAILS BUT I DON'T REALLY CARE $contents = file_get_contents(urlencode(http://user:[EMAIL PROTECTED]/some/path/eitherfilenospaces.ext)); //FAILS BUT I DON'T REALLY CARE $contents = file_get_contents(http://user:[EMAIL PROTECTED]/some/path/.urlencode(eitherfile with spaces.ext)); //FAILS WTF(1) $contents = file_get_contents(http://user:[EMAIL PROTECTED]/some/path/eitherfile+with+spaces.ext); //FAILS WTF(2) br / bWarning/b: file_get_contents(http://[EMAIL PROTECTED]/some/path/eitherfile+with+spaces.ext) [a href='function.file-get-contents'function.file-get-contents/a]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in b/the/script/index.php/b on line b(the file_get_contents line)/bbr / Yes, the files are there. file_get_contents docs: Note: If you're opening a URI with special characters, such as spaces, you need to encode the URI with urlencode(). WTF?!?! How do I get FAILS(1) and FAILS(2) to work, in light of FAILS WTF(1) and FAILS WTF(2)? Have you tried to output the result of urlencode and paste the whole thing in a browser to make sure that it works? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP - Web/list Question...
Stut wrote: On 9 Nov 2008, at 07:16, Robert Cummings wrote: On Sat, 2008-11-08 at 20:26 -0800, bruce wrote: I've got a question/issue that I want to bounce off the list. I have a list that extends over multiple pages. there might be 200 items, and i don't want to have the items listed on the same page as it would be too long. i can break the list up, so i can have it be displayed over multiple pages. however, i want the user to select different items from the list. given that the selected items might be over different pages, what's the best way of keeping a running track of the items that have been selected?? I could have each page be a form, and do a post/get where i then keep track of the selected items from page to page, but that would appear to get ugly. i'm looking for pointers to other sites/code that might have already implemented this kind of scenario. thoughts/pointers would be appreciated... Accumulate them in the session. When done, and before final action you could let them view a summary of selected items and allow deletion of any entries they don't want. Unless they're likely to select hundreds of items I'd either go with a persisted GET var or a cookie. No need to drag server-side storage into this. -Stut Server side storage is meant to be used. The session was one of the greatest things that PHP has given to the web programming world. It should not be feared. Also, why clutter up someone's machine with stuff held in a cookie? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP - Web/list Question...
Stut wrote: On 9 Nov 2008, at 18:14, Robert Cummings wrote: On Sun, 2008-11-09 at 18:00 +, Stut wrote: On 9 Nov 2008, at 07:16, Robert Cummings wrote: On Sat, 2008-11-08 at 20:26 -0800, bruce wrote: I've got a question/issue that I want to bounce off the list. I have a list that extends over multiple pages. there might be 200 items, and i don't want to have the items listed on the same page as it would be too long. i can break the list up, so i can have it be displayed over multiple pages. however, i want the user to select different items from the list. given that the selected items might be over different pages, what's the best way of keeping a running track of the items that have been selected?? I could have each page be a form, and do a post/get where i then keep track of the selected items from page to page, but that would appear to get ugly. i'm looking for pointers to other sites/code that might have already implemented this kind of scenario. thoughts/pointers would be appreciated... Accumulate them in the session. When done, and before final action you could let them view a summary of selected items and allow deletion of any entries they don't want. Unless they're likely to select hundreds of items I'd either go with a persisted GET var or a cookie. No need to drag server-side storage into this. Well he did say he had multiple pages. Maybe he's only displaying 5 per page though. Still, sessions are easier to manage than GET vars since you don't need to append them to every form action URL to accumulate them. Session is managed transparently by PHP in most cases an amounts to the approximate overhead of an include. Seriously? You'd rather use sessions than explode, modify and implode an array of numbers on each request? You really see that as a valuable developer time-saver? The mind boggles, but as I've said before and probably will again it's always a personal choice, I'm just suggesting alternatives. -Stut Also, by storing the information server side, there is less of a chance of the user tampering with the data. Storing stuff in the session also saves on network bandwidth of sending and retrieving the data with each request. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP - Web/list Question...
Robert Cummings wrote: On Sun, 2008-11-09 at 12:26 -0600, Micah Gersten wrote: Stut wrote: On 9 Nov 2008, at 18:14, Robert Cummings wrote: On Sun, 2008-11-09 at 18:00 +, Stut wrote: On 9 Nov 2008, at 07:16, Robert Cummings wrote: On Sat, 2008-11-08 at 20:26 -0800, bruce wrote: I've got a question/issue that I want to bounce off the list. I have a list that extends over multiple pages. there might be 200 items, and i don't want to have the items listed on the same page as it would be too long. i can break the list up, so i can have it be displayed over multiple pages. however, i want the user to select different items from the list. given that the selected items might be over different pages, what's the best way of keeping a running track of the items that have been selected?? I could have each page be a form, and do a post/get where i then keep track of the selected items from page to page, but that would appear to get ugly. i'm looking for pointers to other sites/code that might have already implemented this kind of scenario. thoughts/pointers would be appreciated... Accumulate them in the session. When done, and before final action you could let them view a summary of selected items and allow deletion of any entries they don't want. Unless they're likely to select hundreds of items I'd either go with a persisted GET var or a cookie. No need to drag server-side storage into this. Well he did say he had multiple pages. Maybe he's only displaying 5 per page though. Still, sessions are easier to manage than GET vars since you don't need to append them to every form action URL to accumulate them. Session is managed transparently by PHP in most cases an amounts to the approximate overhead of an include. Seriously? You'd rather use sessions than explode, modify and implode an array of numbers on each request? You really see that as a valuable developer time-saver? The mind boggles, but as I've said before and probably will again it's always a personal choice, I'm just suggesting alternatives. -Stut Also, by storing the information server side, there is less of a chance of the user tampering with the data. Storing stuff in the session also saves on network bandwidth of sending and retrieving the data with each request. Nah, the problem is the same. Tamper with the GET data or tamper with the POST date before it goes into the session. Need to check the incoming data regardless. Cheers, Rob. Yes, but once it's in the session, it should be ok. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: strtotime
Bastien Koert wrote: 2008/11/8 Maciek Sokolewicz [EMAIL PROTECTED] gilles wrote: Avec la version 4 de php, strtotime(20080950) fonctionne correctement en allant sur le mois d'octobre, alors qu'en version 5: 19700101. Merci de votre aide This is an ENGLISH list, please rephrase your question in english and people might understand. Cette liste est une liste anglaise, reformulent svp votre question en anglais svp. merci, - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I'll translate In PHP4, strtotime works fine in PHP5 strtotime gives a result of 19700101 when the data entered was strtotime(20080950) What does work fine mean? 20080950 isn't normal, so what is the expected result? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random number generator
WEISD wrote: That is strange. I get pretty balanced results on this computer. ?php $histogram = array_fill(1, 10, 0); $iterations = 20; for ($i = 0; $i $iterations; ++$i) { ++$histogram[round(rand(1, 10))]; } print_r($histogram); ? Andrew Simple code, ?php $number = rand(1, 10); include(footer$number.html); ? You can see it in action here at the bottom of the page there is a footer. Each footer is the same right now except I have numbered them for testing. As I refresh the page, I get footer10 almost always with an occasional 2 or 4 here and there... http://www.weisd.com/store2/WINHD-9022.php Which PHP version are you running? After 4.2.0, it should be random each call. Otherwise, use srand(); Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random number generator
Stephen wrote: On Thu, 11/6/08, WEISD [EMAIL PROTECTED] wrote: That is strange. I get pretty balanced results on this computer. ?php $histogram = array_fill(1, 10, 0); $iterations = 20; for ($i = 0; $i $iterations; ++$i) { ++$histogram[round(rand(1, 10))]; } print_r($histogram); ? Andrew Simple code, ?php $number = rand(1, 10); include(footer$number.html); ? You can see it in action here at the bottom of the page there is a footer. Each footer is the same right now except I have numbered them for testing. As I refresh the page, I get footer10 almost always with an occasional 2 or 4 here and there... http://www.weisd.com/store2/WINHD-9022.php Computer functions to generate random numbers are not designed to do what their name suggests. Software testing requires repeatability, and this includes random number generation. Without knowing how PHP seeds the generator it is difficult to predict what it will do. I still think taking the last digit of the current time is your best solution. Stephen The PHP developers understood the random problem and the need for predictability, so they did 2 things. 1. Randomly seed the random number generator every time 2. Allow you to set the seed for predictability http://us.php.net/srand Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] removing text from a string
Ashley Sheridan wrote: On Wed, 2008-11-05 at 11:52 -0500, Wolf wrote: 1. Some Text here 2. Another Line of Text 3. Yet another line of text 340. All the way to number 340 And I want to remove the Number, period, and blank space at the begining of each line. How can I accomplish this? Opening the file to modify it is easy, I'm just lost at how to remove the text.: ?php $filename = results.txt; $fp = fopen($filename, r) or die (Couldn't open $filename); if ($fp) { while (!feof($fp)) { $thedata = fgets($fp); //Do something to remove the 1. //print the modified line and \n } fclose($fp); } ? I'd go with a regular expression any day for something like this. *groan* ?php $filename = results.txt; $fp = fopen($filename, r) or die (Couldn't open $filename); if ($fp) { while (!feof($fp)) { $thedata = fgets($fp); //Do something to remove the 1. $findme= ; $pos=strpos($thedata,$findme); $thedata_fixed=trim(substr($thedata,$findme)); //print the modified line and \n echo $thedata_fixed.\n; } fclose($fp); } ? See, no regex needed and no matter the size of the '##. ' it will always find the first and then chop it from there to the end, then you trim it up and you get the text. Wolf Thats a lot of code when a couple of lines and a regex will do ;) Ash www.ashleysheridan.co.uk Yep, with a regex, it's real easy (untested code): ?php $fileData = file_get_contents(text,txt); $newFileData = preg_replace('/^\d+?\.\s?(.*$)/m','/$1/', $fileData); file_put_contents(newfile.txt, $newFileData); ? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] removing text from a string
Yep, with a regex, it's real easy (untested code): ?php $fileData = file_get_contents(text,txt); $newFileData = preg_replace('/^\d+?\.\s?(.*$)/m','/$1/', $fileData); file_put_contents(newfile.txt, $newFileData); ? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com I guess I forgot to proofread also. filename should have a period, not a comma. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: 答复: [PHP]COOKIE or coding
As Todd said, PHP is decoding the URL encoded cookie. The cookie has a '+' in it, because the HTTP headers cannot submit a space. That's why when you use Javascript, it shows you what's in the cookie, but when you use PHP, it shows the space. Which behavior do you prefer? If you want to see the +, the use this: http://us3.php.net/urlencode Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Zhao chunliang[chunliang.zhao] wrote: First thanks for Todd 's help I do have some questions. 1.Open the url : http://127.0.0.1/showCookie.php ShowCookie.php code: ?php echo scriptalert(' . $_COOKIE['TCSPUBLICJAUTHM'] .');/script; ? it's pop-up show : [TCSPUBLICJAUTHM] = USER_ID=/zhW/2QXY/GUtIN7m4 dNQ== 2. The same window, input the string javascript:alert(document.cookie); and enter, it's pop-up show: [TCSPUBLICJAUTHM] = USER_ID=/zhW/2QXY/GUtIN7m4+dNQ== So, I think it's being changed by PHP, not be HTML Decoded by Browser. And the string in Cookie , we should be reluctant to change. -Original Message- From: Zhao chunliang[chunliang.zhao] [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2008 3:52 AM To: php-general@lists.php.net Subject: 答复: [PHP]COOKIE or coding 1.Open the url : http://127.0.0.1/showCookie.php ShowCookie.php code: ?php var_dump($_COOKIE); ? That's print: [TCSPUBLICJAUTHM] = USER_ID=/zhW/2QXY/GUtIN7m4 dNQ== 2. The same window, input the string javascript:alert(document.cookie); and enter, it's show : That's print: [TCSPUBLICJAUTHM] = USER_ID=/zhW/2QXY/GUtIN7m4+dNQ== Notice the +. In certain situations in PHP, it will be HTML Decoded. This means the + will turn into whitespace. Try this for an example: index.php: ?php echo $_GET['d']; ? Then visit http://yourhost/yourdirectory/index.php?d=Hello+World ... it should display Hello World instead of Hello+World. 3. now , I change the showCookie.php ?php echo scriptalert(' . $_COOKIE['TCSPUBLICJAUTHM'] . ');/script; var_dump($_COOKIE); ? That's print: [TCSPUBLICJAUTHM] = USER_ID=/zhW/2QXY/GUtIN7m4 dNQ== As you can see, the only difference is the + has been replaced by whitespace. I think the cookie in php being changed. It is, but it's not as drastic as you would think. There is an expected behavior (+ to ) that you can deal with in your algorithm via substitution, encoding, etc. HTH, Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] find a word in a string
http://php.net/strstr Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Richard Kurth wrote: is the a php function to find a word in a string and report back that it was found -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reaching network share with libssh2 functions
If it's a permissions issue, it's related to Windows. Is it a user share or a system share? Can you access the shares when you log directly into the windows box? Have you tried command line ssh to see if it's specifically related to the PHP library? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Jacob Overgaard wrote: Hi all I have a php script which connects to a copssh server installed on a Windows 2000 SP4 machine. However, the trouble is that I can not see the contents of the shared network folders when connecting through ssh2_exec. If I use putty instead, there is no problem seeing these folders. I guess that it is something to do with lack of permission, but I am not sure how to solve this problem, so I hoped for some assistance from this forum as it seems to be related to the use of libssh2 functions. Best wishes Jacob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] basic php question...
Is anything changing on the page? If not, AJAX might be the way to go, http://xajaxproject.org Otherwise, pass the parameters you want to foo.php and have it redirect to the proper page with the proper arguments. Another alternative, is to store the parameters in the session and pass them from foo.php without passing them to it. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com bruce wrote: hi guys...foo i've got a button that i want to select, and i want the app to process some logic, and then return the user to the page. my question is how?? something like base page: a href=foo.phpbutton link/a foo.php -process logic -return the user to the base page, with the same querystring that was initially used to generate the initial base page foo.php doesn't have any display function, just the logic thoughts/sample php pages/psuedo code chunks... thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reaching network share with libssh2 functions
Have you turned on error logging? What code are you using? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Jacob Overgaard wrote: Thanks, Micah I can access the share when I log directly in to the windows machine with a bash shell. It seems isolated to the PHP library. Thanks, Jacob Citat af Micah Gersten [EMAIL PROTECTED]: If it's a permissions issue, it's related to Windows. Is it a user share or a system share? Can you access the shares when you log directly into the windows box? Have you tried command line ssh to see if it's specifically related to the PHP library? Thank you, Micah Gersten Jacob Overgaard wrote: Hi all I have a php script which connects to a copssh server installed on a Windows 2000 SP4 machine. However, the trouble is that I can not see the contents of the shared network folders when connecting through ssh2_exec. If I use putty instead, there is no problem seeing these folders. I guess that it is something to do with lack of permission, but I am not sure how to solve this problem, so I hoped for some assistance from this forum as it seems to be related to the use of libssh2 functions. Best wishes Jacob -- 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] PHP Auth
Steve Marquez wrote: Greetings, What is the best way to create authentication for MySQL info displayed on PHP pages. Thanks, Best is relative. How many users do you expect? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] General Mysql Connect
Ashley Sheridan wrote: On Thu, 2008-10-30 at 08:55 +1100, Chris wrote: Waynn Lue wrote: I sent an email to the mysql list, but it reminded me of a question I had for people structuring their PHP code. What's the general way that people structure their connections? Right now, I spawn off two mysql_connect calls at the top of the file that includes my database calls, using true for the fourth parameters, so as to create two new connections. Then I use those two connections for two different databases I have to query from. Is it better just to use mysql_select_db within the query function every time for the same connection? Should I use mysql_connect every time without using true, so as to re-use connections. Should I be using pconnect instead? I spent some time looking for answers to these questions, but am getting conflicting answers. Some people think relying on the re-use of these functions is good, some think that explicit management is better. In general, how have people on the list found them? For example, is having constant mysql_select_db calls a problem? Are they connecting as the same user and on the same server? Then you can replace with a mysql_select_db call. If they aren't both of those, you have no choice. No idea if it'll make much of a difference (performance wise etc) but I'd leave it as two connections. -- Postgresql php tutorials http://www.designmagick.com/ How difficult would it be to converge the 2 databases into one? This would obviously use less memory (not sure exactly how big the footprint of each connection is though) and will slightly speed up page display time (as you only have to wait for one connection to be made rather than two) Ash www.ashleysheridan.co.uk Generally you want separation of data. MySQL doesn't have a problem accessing another DB on the same server with the same connection. Also, how would database convergence use less memory? . Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] General Mysql Connect
Ashley Sheridan wrote: On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote: Ashley Sheridan wrote: On Thu, 2008-10-30 at 08:55 +1100, Chris wrote: Waynn Lue wrote: I sent an email to the mysql list, but it reminded me of a question I had for people structuring their PHP code. What's the general way that people structure their connections? Right now, I spawn off two mysql_connect calls at the top of the file that includes my database calls, using true for the fourth parameters, so as to create two new connections. Then I use those two connections for two different databases I have to query from. Is it better just to use mysql_select_db within the query function every time for the same connection? Should I use mysql_connect every time without using true, so as to re-use connections. Should I be using pconnect instead? I spent some time looking for answers to these questions, but am getting conflicting answers. Some people think relying on the re-use of these functions is good, some think that explicit management is better. In general, how have people on the list found them? For example, is having constant mysql_select_db calls a problem? Are they connecting as the same user and on the same server? Then you can replace with a mysql_select_db call. If they aren't both of those, you have no choice. No idea if it'll make much of a difference (performance wise etc) but I'd leave it as two connections. How difficult would it be to converge the 2 databases into one? This would obviously use less memory (not sure exactly how big the footprint of each connection is though) and will slightly speed up page display time (as you only have to wait for one connection to be made rather than two) Ash www.ashleysheridan.co.uk Generally you want separation of data. MySQL doesn't have a problem accessing another DB on the same server with the same connection. Also, how would database convergence use less memory? . Thank you, For arguments sake, open 1000 database connections, all to different databases. Now tell me that each connection doesn't have a footprint. At the end of the day, whist it may seem fine for a script to have 2 connections open, the least open the better. Imagine 100 users simultaneously accessing a page that opens 10 connections. Suddenly you have 200 connections open, not a great idea. If you could amalgamate the db's, you'd have half as many connections open. If you're still having trouble understanding why having two database connections open is bad (regardless of whether they are on the same server or not) the I think web development is the wrong career for you. Ash www.ashleysheridan.co.uk The answer in your case is not to combine the DBs necessarily, but consolidate the connections used. Like I said, you can use 2 MySQL DBs on the same connection in PHP. There's no reason to sacrifice separation of data. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] General Mysql Connect
Ashley Sheridan wrote: On Wed, 2008-10-29 at 19:43 -0500, Micah Gersten wrote: Ashley Sheridan wrote: On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote: Ashley Sheridan wrote: On Thu, 2008-10-30 at 08:55 +1100, Chris wrote: Waynn Lue wrote: I sent an email to the mysql list, but it reminded me of a question I had for people structuring their PHP code. What's the general way that people structure their connections? Right now, I spawn off two mysql_connect calls at the top of the file that includes my database calls, using true for the fourth parameters, so as to create two new connections. Then I use those two connections for two different databases I have to query from. Is it better just to use mysql_select_db within the query function every time for the same connection? Should I use mysql_connect every time without using true, so as to re-use connections. Should I be using pconnect instead? I spent some time looking for answers to these questions, but am getting conflicting answers. Some people think relying on the re-use of these functions is good, some think that explicit management is better. In general, how have people on the list found them? For example, is having constant mysql_select_db calls a problem? Are they connecting as the same user and on the same server? Then you can replace with a mysql_select_db call. If they aren't both of those, you have no choice. No idea if it'll make much of a difference (performance wise etc) but I'd leave it as two connections. How difficult would it be to converge the 2 databases into one? This would obviously use less memory (not sure exactly how big the footprint of each connection is though) and will slightly speed up page display time (as you only have to wait for one connection to be made rather than two) Ash www.ashleysheridan.co.uk Generally you want separation of data. MySQL doesn't have a problem accessing another DB on the same server with the same connection. Also, how would database convergence use less memory? . Thank you, For arguments sake, open 1000 database connections, all to different databases. Now tell me that each connection doesn't have a footprint. At the end of the day, whist it may seem fine for a script to have 2 connections open, the least open the better. Imagine 100 users simultaneously accessing a page that opens 10 connections. Suddenly you have 200 connections open, not a great idea. If you could amalgamate the db's, you'd have half as many connections open. If you're still having trouble understanding why having two database connections open is bad (regardless of whether they are on the same server or not) the I think web development is the wrong career for you. Ash www.ashleysheridan.co.uk The answer in your case is not to combine the DBs necessarily, but consolidate the connections used. Like I said, you can use 2 MySQL DBs on the same connection in PHP. There's no reason to sacrifice separation of data. Thank you, Micah Gersten I'm sure if you look at the OP codes on your suggestion, you'd still use the same memory as having two separate connections open, unless you closed one first. Thing is, opening and closing database connections has its own overheads. Ash www.ashleysheridan.co.uk How is using one connection the same as having 2 open? You just change databases if you want to, or use the fully qualified table name (database.table) in your query. What extra overhead is there in that? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] General Mysql Connect
Ashley Sheridan wrote: On Wed, 2008-10-29 at 19:49 -0500, Micah Gersten wrote: Ashley Sheridan wrote: On Wed, 2008-10-29 at 19:43 -0500, Micah Gersten wrote: Ashley Sheridan wrote: On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote: Ashley Sheridan wrote: On Thu, 2008-10-30 at 08:55 +1100, Chris wrote: Waynn Lue wrote: I sent an email to the mysql list, but it reminded me of a question I had for people structuring their PHP code. What's the general way that people structure their connections? Right now, I spawn off two mysql_connect calls at the top of the file that includes my database calls, using true for the fourth parameters, so as to create two new connections. Then I use those two connections for two different databases I have to query from. Is it better just to use mysql_select_db within the query function every time for the same connection? Should I use mysql_connect every time without using true, so as to re-use connections. Should I be using pconnect instead? I spent some time looking for answers to these questions, but am getting conflicting answers. Some people think relying on the re-use of these functions is good, some think that explicit management is better. In general, how have people on the list found them? For example, is having constant mysql_select_db calls a problem? Are they connecting as the same user and on the same server? Then you can replace with a mysql_select_db call. If they aren't both of those, you have no choice. No idea if it'll make much of a difference (performance wise etc) but I'd leave it as two connections. How difficult would it be to converge the 2 databases into one? This would obviously use less memory (not sure exactly how big the footprint of each connection is though) and will slightly speed up page display time (as you only have to wait for one connection to be made rather than two) Ash www.ashleysheridan.co.uk Generally you want separation of data. MySQL doesn't have a problem accessing another DB on the same server with the same connection. Also, how would database convergence use less memory? . Thank you, For arguments sake, open 1000 database connections, all to different databases. Now tell me that each connection doesn't have a footprint. At the end of the day, whist it may seem fine for a script to have 2 connections open, the least open the better. Imagine 100 users simultaneously accessing a page that opens 10 connections. Suddenly you have 200 connections open, not a great idea. If you could amalgamate the db's, you'd have half as many connections open. If you're still having trouble understanding why having two database connections open is bad (regardless of whether they are on the same server or not) the I think web development is the wrong career for you. Ash www.ashleysheridan.co.uk The answer in your case is not to combine the DBs necessarily, but consolidate the connections used. Like I said, you can use 2 MySQL DBs on the same connection in PHP. There's no reason to sacrifice separation of data. Thank you, Micah Gersten I'm sure if you look at the OP codes on your suggestion, you'd still use the same memory as having two separate connections open, unless you closed one first. Thing is, opening and closing database connections has its own overheads. Ash www.ashleysheridan.co.uk How is using one connection the same as having 2 open? You just change databases if you want to, or use the fully qualified table name (database.table) in your query. What extra overhead is there in that? Thank you, Micah Gersten Having one connection open at a time has only the overhead of the opening and closing of connections. As far as I know, you can't have two databases open on one connection, but please correct me if I am wrong. Ash www.ashleysheridan.co.uk With MySQL, you can change the DB from query to query with mysql_select_db. The alternative as I stated in my last post is to use the fully qualified table name (database.table) in your query. MySQL doesn't care which DB you have open if you do that. In both of these cases, the same connection is used. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] General Mysql Connect
Ashley Sheridan wrote: On Wed, 2008-10-29 at 19:57 -0500, Micah Gersten wrote: Ashley Sheridan wrote: On Wed, 2008-10-29 at 19:49 -0500, Micah Gersten wrote: Ashley Sheridan wrote: On Wed, 2008-10-29 at 19:43 -0500, Micah Gersten wrote: Ashley Sheridan wrote: On Wed, 2008-10-29 at 19:25 -0500, Micah Gersten wrote: Ashley Sheridan wrote: On Thu, 2008-10-30 at 08:55 +1100, Chris wrote: Waynn Lue wrote: I sent an email to the mysql list, but it reminded me of a question I had for people structuring their PHP code. What's the general way that people structure their connections? Right now, I spawn off two mysql_connect calls at the top of the file that includes my database calls, using true for the fourth parameters, so as to create two new connections. Then I use those two connections for two different databases I have to query from. Is it better just to use mysql_select_db within the query function every time for the same connection? Should I use mysql_connect every time without using true, so as to re-use connections. Should I be using pconnect instead? I spent some time looking for answers to these questions, but am getting conflicting answers. Some people think relying on the re-use of these functions is good, some think that explicit management is better. In general, how have people on the list found them? For example, is having constant mysql_select_db calls a problem? Are they connecting as the same user and on the same server? Then you can replace with a mysql_select_db call. If they aren't both of those, you have no choice. No idea if it'll make much of a difference (performance wise etc) but I'd leave it as two connections. How difficult would it be to converge the 2 databases into one? This would obviously use less memory (not sure exactly how big the footprint of each connection is though) and will slightly speed up page display time (as you only have to wait for one connection to be made rather than two) Ash www.ashleysheridan.co.uk Generally you want separation of data. MySQL doesn't have a problem accessing another DB on the same server with the same connection. Also, how would database convergence use less memory? . Thank you, For arguments sake, open 1000 database connections, all to different databases. Now tell me that each connection doesn't have a footprint. At the end of the day, whist it may seem fine for a script to have 2 connections open, the least open the better. Imagine 100 users simultaneously accessing a page that opens 10 connections. Suddenly you have 200 connections open, not a great idea. If you could amalgamate the db's, you'd have half as many connections open. If you're still having trouble understanding why having two database connections open is bad (regardless of whether they are on the same server or not) the I think web development is the wrong career for you. Ash www.ashleysheridan.co.uk The answer in your case is not to combine the DBs necessarily, but consolidate the connections used. Like I said, you can use 2 MySQL DBs on the same connection in PHP. There's no reason to sacrifice separation of data. Thank you, Micah Gersten I'm sure if you look at the OP codes on your suggestion, you'd still use the same memory as having two separate connections open, unless you closed one first. Thing is, opening and closing database connections has its own overheads. Ash www.ashleysheridan.co.uk How is using one connection the same as having 2 open? You just change databases if you want to, or use the fully qualified table name (database.table) in your query. What extra overhead is there in that? Thank you, Micah Gersten Having one connection open at a time has only the overhead of the opening and closing of connections. As far as I know, you can't have two databases open on one connection, but please correct me if I am wrong. Ash www.ashleysheridan.co.uk With MySQL, you can change the DB from query to query with mysql_select_db. The alternative as I stated in my last post is to use the fully qualified table name (database.table) in your query. MySQL doesn't care which DB you have open if you do that. In both of these cases, the same connection is used. Thank you
Re: [PHP] General Mysql Connect
Waynn Lue wrote: With MySQL, you can change the DB from query to query with mysql_select_db. The alternative as I stated in my last post is to use the fully qualified table name (database.table) in your query. MySQL doesn't care which DB you have open if you do that. In both of these cases, the same connection is used. That brings me back to the original point, is there a performance decrease to continually calling mysql_select_db? And shouldn't connections that are being made during the processing of a php script (which runs for no more than two seconds) be lasting at least until the end of the script, instead of getting errors like Lost connection to server? The only overhead of constantly using mysql_select_db is 2 function calls to make a query instead of just using the database name in the query. However, this should not be that expensive. Yes, connections should be available for the whole script if you don't destroy them. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] General Mysql Connect
Ashley Sheridan wrote: On Wed, 2008-10-29 at 20:12 -0500, Micah Gersten wrote: Waynn Lue wrote: With MySQL, you can change the DB from query to query with mysql_select_db. The alternative as I stated in my last post is to use the fully qualified table name (database.table) in your query. MySQL doesn't care which DB you have open if you do that. In both of these cases, the same connection is used. That brings me back to the original point, is there a performance decrease to continually calling mysql_select_db? And shouldn't connections that are being made during the processing of a php script (which runs for no more than two seconds) be lasting at least until the end of the script, instead of getting errors like Lost connection to server? The only overhead of constantly using mysql_select_db is 2 function calls to make a query instead of just using the database name in the query. However, this should not be that expensive. Yes, connections should be available for the whole script if you don't destroy them. Thank you, Micah Gersten I'm just thinking about how other languages work with regards to databases. I'm pretty sure that opening extra database connections, regardless of whether they are on the same server or not, you will incur extra opcodes. ColdFusion does it with MSSQL, and I'm guessing that PHP on Windows using MSSQL or MySQL is going to be fairly the same. Linux could be different, but why would the developers of the connection driver write totally different code for both OS's? Ash www.ashleysheridan.co.uk With MySQL, you don't need a new DB connection to use a second DB. I think that's the problem your having Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex validation
VamVan wrote: Hello Team of Nerds, I need help in writing a regular expression for this: invalid character set is: INVALID_STRING={/,*,+,(,),'\',:,;,~,..,.@,@.}; I want to a pregmatch for these characters on my whole email address and if match is found I need to return false. Thank you If your trying to filter E-Mail addresses, then filter_var is what you should use: http://php.net/filter_var Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex validation
Keep in mind that ereg will disappear with PHP 6. You might want to use the preg functions: http://www.making-the-web.com/2007/09/21/becoming-php-6-compatible/ Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com VamVan wrote: Thank Guys, I at least got part of it working , not the double words but almost everything else than that: function _email_validate($mail_address){ $invalid_charset_pattern = [(*+?)|~:;{}/ ]; if(ereg($invalid_charset_pattern, $mail_address)){ return false; }else{ return true; } } Thanks for the inputs On Tue, Oct 28, 2008 at 3:31 PM, Nitsan Bin-Nun [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Good to know filter_var() exists in PHP5 Unless you have PHP5 you better validate the string in the way of checking if it is fit's to your allowed characters and not checking if it contains the NOT allowed charaters. You better use: [a-z0-9A-Z\_\.]+ instead of [^\)\(\*\[EMAIL PROTECTED] and I haven't started yet with the weirdy ones HTH, Nitsan On Wed, Oct 29, 2008 at 12:10 AM, Yeti [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: If your trying to filter E-Mail addresses, then filter_var is what you should use: http://php.net/filter_var If the OP (original poster) got PHP5+ -- 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] Regex validation
What are you talking about with a cookie and an E-Mail address? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com VamVan wrote: Yeah, I understand that its allowed in RFC. But unfortunately I use SSO layer which decrypts the Cookie to get email address. This is where it messes up. So I have decided not to allow people to use that as well. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex validation
How is anything but your webserver decrypting the $_POST data? PHP should get it after that as is. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com VamVan wrote: SSO process: $_POST the Email Address and password Get Authenticated, Get the COOKIE ( Through Oracle IDM suite SOAP call) Decrypt the COOKIE ( Through Oracle Enterprise business suite SOAP call) and get the profile Info Thats what happens now. But there is a glitch in the decryption algorithm we currently have. And when we decrypt + or some thing else comes with funny characters and does not authenticate. So I need to restrict them for now. When the algorithm gets corrected then I will use standard RFC. On Tue, Oct 28, 2008 at 5:41 PM, Micah Gersten [EMAIL PROTECTED] wrote: What are you talking about with a cookie and an E-Mail address? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com VamVan wrote: Yeah, I understand that its allowed in RFC. But unfortunately I use SSO layer which decrypts the Cookie to get email address. This is where it messes up. So I have decided not to allow people to use that as well. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clean data
Are you using MySQL abstraction? That's the easiest way to control what data goes into your DB in a central place. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com blackwater dev wrote: I have a project now where we would like to properly remove unwanted data before it goes into the db such as ` and of course slashes. The problem is I have tons of pages. Is there an easy way to add in a clean up routine on the db side to clean it going in and coming out without having to touch each page that inserts it into the db and each page that presents it? I'm using a MySQL db. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clean data
In that case, I suggest you look to the MySQL lists for tips on handling data coming in. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com blackwater dev wrote: Yes, I agree but the code I am inheriting doesn't use abstraction unfortunately. On Mon, Oct 27, 2008 at 9:38 PM, Micah Gersten [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Are you using MySQL abstraction? That's the easiest way to control what data goes into your DB in a central place. Thank you, Micah Gersten http://www.onshore.com blackwater dev wrote: I have a project now where we would like to properly remove unwanted data before it goes into the db such as ` and of course slashes. The problem is I have tons of pages. Is there an easy way to add in a clean up routine on the db side to clean it going in and coming out without having to touch each page that inserts it into the db and each page that presents it? I'm using a MySQL db. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] clear a mysql table
Ronald Wiplinger (Lists) wrote: I need to clear a table (cache) from a database based on the database size. Our web site uses cached pages. Our webhost only allow us 100 MB storage. Usually the database is just 10 MB, but when a search engine crawls our calendar, then the storage is quickly 108 MB. The system reports then mathematically correct: Space left on database -8MB !!! I plan therefore a web page, which is triggered by cron every hour and will just clear the table. Can I use just: mysql_query(DELETE FROM cash) or die(mysql_error()); or do I need to loop through all records? or is there a better solution? How can I get the database size? bye R. Perhaps you should not have search engines index your calendar. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to recieve image from url?
If you're using file_get_contents, why aren't you using file_put_contents? Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Nitsan Bin-Nun wrote: Hi, I have this function: function saveImageFromUrl($image_url, $image_save) { $contents = file_get_contents($image_url); $fp = fopen($image_save, 'w'); fwrite($fp, $contents); fclose($fp); } As you can see it fetches the images contents and write them to new image on my local directory. Is this is the best way to do this? (I don't have curl) Does file_get_contents() uses buffer to get the contents of the image? (in case the server response is slow) There is a better way? Thanks in Advance, Nitsan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Information on Cookies
Don't use cookies, use sessions. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ben Stones wrote: I've read a few videos on cookie security and it makes sense that people can modify cookie values which is a problem I'm trying to figure out to *try* and prevent. What I'll first do is at the top of the page that validates if the cookie values is in the database, but what my next problem is they'd use usernames in the database as the vaues. Are there any preventable measures to prevent cookie forging or what not. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP
The problem with bottom posting is that if you follow the conversation, you have to scroll to find the new content. I guess if you trim and bottom post it's not so bad. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Wolf wrote: By Bottom Posting (common when on a mailing list or NG) it gives greater context as you read through the previous posts and by the time of getting to where the new response is, it is in sync. No skipping back and forth to read to get the context. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable Variables and Super Global Arrays
That's fine as a test, but you never want to get a variable name from a URL in practice. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Richard Heyes wrote: $varname = \$_SERVER['REMOTE_ADDR']; $varvalue = $$varname; That's wrong. Offhand you'll end up printing a string. I tried this: ?php $a = 365; $b = 366; $var = $_GET['var']; echo $$var; ? And it was fine. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable Variables and Super Global Arrays
I mean that it is open for hacking if you pass a variable name through a URL. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com daniel danon wrote: What do you mean? On Sun, Oct 12, 2008 at 5:40 PM, Micah Gersten [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: That's fine as a test, but you never want to get a variable name from a URL in practice. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Richard Heyes wrote: $varname = \$_SERVER['REMOTE_ADDR']; $varvalue = $$varname; That's wrong. Offhand you'll end up printing a string. I tried this: ?php $a = 365; $b = 366; $var = $_GET['var']; echo $$var; ? And it was fine. -- 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: template usage
The problem with smarty is that they are still using PHP4 as their main language so they cannot take advantage of speed improvements in PHP5. So, my suggestion is that if you're stuck with PHP4, go with smarty, otherwise, find another engine that's up to date. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Nathan Rixham wrote: Alain Roger wrote: Hi, i would like to know if you are a lot to use PHP templates for your web application or web sites ? if yes, which one do you use (smarty, pear, yapter, phplib,...) ? and for which reason ? what is/are the advantages over the others ? thanks a lot, I'd vote smarty or using xslt; smarty is very good and nine out of 10 designers I know prefer it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Setcookie()
The question is, why aren't you using a session variable instead of cookies? That's one of the greatest features of PHP. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Ben Stones wrote: What I mean is I cannot use setcookie, I need to check if user credentials are correct first (which is BEFORE setcookie) and if so, set a cookie. I can't do that unless setcookie is first, but I need to check if the user credentials is correct. Furthermore I cannot use setcookie in the header as I want to display a message saying that they have successfully logged in in the correct area of my template. 2008/10/11 Per Jessen [EMAIL PROTECTED] Ben Stones wrote: I'm using cookies for my website script and upon users logging in a cookie is set. Problem for me is that the cookie doesn't work due to headers already sent. Is there anyway of fixing this because, there is no possible way of adding setcookie() to the top of the PHP file when the cookie is holding the username from the POSTed form. This must be a self imposed restriction on your side, coz' otherwise I see no problem. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and getting part of URL
dirname($_SERVER['REQUEST_URI']); Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Jason ML wrote: Hi PHP'ers, PHP 4.4.8 and 5. say I have a url like: http://www.mydomain.tld/jason/index.php In that index.php I want to have a piece of code that runs that tells me the 'jason' part of the URL so that I can run some custom read only queries for 'jason' How can I do this? I know how to do everything except what PHP commands to run to get the info. Thanks! -Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php