|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
#61
|
||||
|
||||
|
Quote:
Also, just think about it. In the code sample given by chads2k2 when the PHP page is loaded it is parsed into HTML. At that point your prompt hasn't even been displayed and the user hasn't even had the chance to set your NAME variable, much less let the PHP engine parse it and place it in the place where you're calling $_GET['NAME']. JavaScript is executed after the page is loaded.
__________________
SELECT COUNT(*) FROM fun WHERE location = 'WORK' AND day_of_week IN ('MON','TUE','WED','THU','FRI'); COUNT ------- 0 |
|
#62
|
||||
|
||||
|
#47 - How do I get PHP to work based upon the location of their IP address.
There are a couple of things that you need to know before you start doing this. The first being that the IP address could be a spoof, or could be based on a proxy server. This means that you will not always be assured to get the IP address of the actual user. The second thing that you must know is that even if you get the IP address it might be from AOL, MSN, Earthlink, ect which setup a block of addresses that always look like they are coming from the United States. So, if you are going to use this information to determine what language to have your website display you might want to consider these. However, if you evaluated the risks and you see nothing wrong with doing what you are doing then here are some links that can help you out with the code and such: http://www.maxmind.com/app/geoip_country They even have a PHP api: http://www.maxmind.com/app/php
__________________
Get A Supplier LLC | Hilarious Comic --- Pretty much retired from the forum. I will get back on every now and then, and maybe answer a few questions. Last edited by chads2k2 : May 2nd, 2006 at 08:06 AM. Reason: Coloring the top |
|
#63
|
||||
|
||||
|
Regarding the above post: It's not a good idea to use IP address as a unique identifier of your user because (among many other reasons) dial-up services in particular give dynamic IP addresses. Basically, every time the user connects they get a new IP address.
|
|
#64
|
||||
|
||||
|
#48 - Resizing an image with PHP
Many have asked this in the past and a couple of people have responded in a way that doesn't actually answer the question. The question being, how do I resize an image with PHP? Yes this will work for larger images going to smaller, but smaller images to larger the math doesn't work out really well. PHP Code:
PHP Code:
Hope that clears it up, Chad Last edited by chads2k2 : May 11th, 2006 at 11:21 AM. Reason: Kicken brought up a good point. |
|
#65
|
||||
|
||||
|
Quote:
Actually, with that code you don't need the GD library at all. Quote:
Also note, that unless the scaling you're doing is minor (as in only around a 50-100 pixel change) then you'd probably be better off using gd to actually resize the image, for two reasons: 1) The quality will almost certainly be better. Browsers generally do a fast resize resulting in a poor but quick resize operation. 2) You save bandwidth because the file size actually is reduced. By having the browser resize the image, the entire file must still be downloaded rather than just a small thumbnail like version.
__________________
Spidermonkey Tutorial; Fight me: http://aoeex.mybrute.com http://www.aoeex.com/gmap.php - Put yourself on the map (Now Updated!) |
|
#66
|
||||
|
||||
|
This should give you most of the detail: http://www.tutorialized.com/tutoria...-with-PHP/11878
__________________
~James [Not currently seeking freelance work] Like philosophy or interested in spirituality? Philosophorum. Game Dev Experts Forums Foresight Linux - Because your desktop should be cool! Linux FAQ FedoraFAQ UbuntuGuide |
|
#67
|
||||
|
||||
|
#50 - Windows Apache MySQL PHP (NOT XAMPP,WAMP,appserv)
Recently there has been far more discussion about security and setting up a server the proper way than I care to think about again. Every answer seems to be some prebuilt solution that everyone swears is the end all to server setup. I disagree completely with using a premade system such as appserv, XAMPP, WAMP, or anyother system that is developed for the sole purpose of double clicking and having the entire system setup correctly the first time. That is not how you setup a server. Nor will it ever be that way. I mean MySQL, PHP, and Apache are free. You would think that one of them would already have thought about incorporating it all into one package, ask yourself why they haven't done so? It comes down to security for one company may not be secure enough for another, one size does not fit all. Some have said that it is hard. That by doing this it will be difficult getting it setup. I agree that in the beginning it is a bit difficult, I mean with all the reading you will have to do. The reading that is required is reading the installation text files and maybe a config file or two. Where even those configuration files are so well commented it's amazing. Take the time to read php.ini file line by line. You will walk away with a greater sense of how the system works, moreso that just having something else configure it for you. I can assure you one thing. If you setup your own server you will gain experience, and knowledge, but more importantly you will gain the self rewarding notion that you took the time to do it right the first time. You didn't cut to the easy way when you had a choice. Every pre-made system was put together in what they think is a "perfect" system. Will it work for your own server? Sure, but will it be the most secured perfect system for your application? No. Ask any hosting company if they use XAMPP, or WAMP, appserv and they will (or should) laugh at you. It is fine (I guess) for localhost checking to ensure that your scripts work. But what will you say if your boss (present, or future) asks you to setup the server for your companies website? Will you tell them that you double clicked a setup.exe file and you're ready to go? Hopefully not. Where to get the stuff: PHP (GET THE ZIP FILE!!!) Apache2 MySQL 4 or 5 Instructions (other than the install.txt file in PHP's zip) Very good tutorial! Well written that has easy instructions. http://www.webmasterstop.com/48.html http://www.apachemysqlphp.com/ Doing it right the first time will make all the difference in the world, Chad Last edited by chads2k2 : July 19th, 2006 at 09:06 AM. Reason: Added another tutorial. |
|
#68
|
||||
|
||||
|
Quote:
Easier, I think, to do a preg_replace with the i modifier: PHP Code:
Faster than jpenn's implementation I think. Although that's pretty good as well. -Dan |
|
#69
|
|||
|
|||
|
You can use the inbuilt function str_ireplace(search, replace, source)
|
|
#70
|
||||
|
||||
|
Quote:
#51 - Can I change the file permisions/attributes in Windows There is attrib command in windows to change the file attributes. Syntax: Code:
ATTRIB [+r|-r] [+a|-a] [+s|-s] [path\file] /s
__________________
Akash Dwivedi "Whatever the mind can conceive and believe, the mind can achieve." Feel good.. ![]() Last edited by helloakash : May 7th, 2007 at 02:54 AM. |
|
#71
|
||||
|
||||
|
#52 - How do I suppress errors in PHP?
I have been seeing this problem come up a lot and figured I would put this in the FAQ of PHP. --- The @ symbol: You can place an @ symbol in front of the function and it will not have the error be displayed. You can view more about this here. --- error_reporting() You can use the function error_reporting() to suppress all errors with: PHP Code:
--- Fool proof way There is one fool proof way of making sure that no errors will show up, that is to test your application throughly. When you test your application as thoroughly as you possibly can you will see most errors (syntax, fatal, ect) and then you can fix your application. You can suppress the errors but you aren't fixing anything, fix the application then if errors exist move to plan B. Remember that errors are coming up for a reason, find out what the error is and fix it. Use one of the above ONLY when your application is ready to go live and you are sure no errors should arise anyway. Hope this helps, Chad |
|
#72
|
||||
|
||||
|
Info Post Only: How to Convert Decimal to Time
This post is not a question, but rather an answer to a question I have seen asked but unanswered around the internet.
How do I convert a decimal to time? PHP Code:
Enjoy!
__________________
Saidan Ryuuza Web Designer | Writer Web Confidence Design Defunct Games Kyou wa Ash!ta no Kinou ![]() -- Failure is not an option! It comes bundled with Windows. |
|
#73
|
||||
|
||||
|
Following on from the above, if you're going to use the @ operator, you should manually test return values.
Eg. some older libraries are happy to chuck a warning if something isn't perfect (like really old versions of the older 'mysql' library which would chuck a warning if you tried to use mysql_fetch_<whatever> on a result object that returned no rows. In fact the easiest way to do this is something like the following: This provides safety and also handles the problem of 'what if i reached the last row?'. I tend to do something similar to the above (wrapped around my homemade database class) in a while loop: The reason the above work is because a non-empty array counts as true in a boolean context, so when you get passed false (the only other possibility than a non-empty array), the loop terminates. My database class returns a resultset class which functions like mysql_fetch_object but has more functionality, and the same applies here, my class returns false if there are no more rows. |
|
#74
|
|||
|
|||
|
__________________
~~ Peter ~~ :: ( Who am I? ) :: ( My Blog: A day (or more) in the life of a CS & Math student... ) :: ( Supporter of the EFF & FSF ) :: ( I'm a GNU/Linux addict and Free Software Advocate. ) :: ( How to Ask Questions the Smart Way ) :: ( The Fedora Project, sponsored by Red Hat ) :: ( GNOME: The Free Software Desktop Project ) :: ( GnuPG Public Key ) :: ( About me on the WIki ) |
|
#75
|
||||
|
||||
|
I apologize if this is posted in the wrong area, I did not realize there was a specific section for answers...
as for mktime and strftime they don't exactly work in the same way. To my knowledge neither are about to handle decimal to time conversion out of the box. mktime requires you to specify hour, min, sec and so on individually. If you know of a shortcut to performing this outside of a function, or a way to optimize the function using either one of these, please let me know. Thanks |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > [NEW USERS] - Answers to Frequently Asked Questions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|