PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 10 votes, 4.50 average. Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #61  
Old April 4th, 2006, 09:34 AM
mateoc15's Avatar
mateoc15 mateoc15 is offline
C A R D S
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: The 'Ville
Posts: 763 mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 7 h 42 m 24 sec
Reputation Power: 13
Quote:
Originally Posted by chads2k2
#45 - Why can't I use my javascript variables in PHP?

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.
Comments on this post
chadsmith729 agrees: Brilliant!
__________________
Reinventing the wheel again

Reply With Quote
  #62  
Old May 2nd, 2006, 07:05 AM
chadsmith729's Avatar
chadsmith729 chadsmith729 is offline
--Retired--
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Sep 2003
Location: Enjoying forum retirement.
Posts: 3,113 chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)  Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 16 h 31 m 40 sec
Reputation Power: 893
#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 07:06 AM. Reason: Coloring the top

Reply With Quote
  #63  
Old May 2nd, 2006, 07:55 AM
mateoc15's Avatar
mateoc15 mateoc15 is offline
C A R D S
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: The 'Ville
Posts: 763 mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level)mateoc15 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 7 h 42 m 24 sec
Reputation Power: 13
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.

Reply With Quote
  #64  
Old May 11th, 2006, 09:05 AM
chadsmith729's Avatar
chadsmith729 chadsmith729 is offline
--Retired--
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Sep 2003
Location: Enjoying forum retirement.
Posts: 3,113 chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)  Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 16 h 31 m 40 sec
Reputation Power: 893
#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
//imageScale (image Location, new image width, new image height)
//You can choose the new Width, or new Height but not both (if you're going by Height, put a -1 for new Width
//will return an array, element 0 is the new width, element 1 is the new height
function imageScale($image$newWidth$newHeight)
{
   if(!
$size = @getimagesize($image)) die("Unable to get info on image $image");

   
$ratio = ($size[0] / $size[1]);

   
//scale by height
   
if($newWidth == -1)
   {
      
$ret[1] = $newHeight;
      
$ret[0] = round(($newHeight $ratio));
   }else if(
$newHeight == -1){
      
$ret[0] = $newWidth;
      
$ret[1] = round(($newWidth $ratio));
   }else{
      die(
"Scale Error");
   }
   return 
$ret;
}
?>

PHP Code:
////  USES
$resize_array imageScale("images/image_name.jpg",357,-1);
echo 
"<img src='images/$image_name' width='" $resize_array[0] . "' height='" $resize_array[1] . "' alt='Image' />"


Hope that clears it up,
Chad

Last edited by chads2k2 : May 11th, 2006 at 10:21 AM. Reason: Kicken brought up a good point.

Reply With Quote
  #65  
Old May 11th, 2006, 10:18 AM
kicken's Avatar
kicken kicken is offline
Wiser? Not exactly.
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: May 2001
Location: Ft Myers, FL
Posts: 4,003 kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)kicken User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 115392 Folding Title: Super Ultimate Folder - Level 1Folding Points: 115392 Folding Title: Super Ultimate Folder - Level 1Folding Points: 115392 Folding Title: Super Ultimate Folder - Level 1Folding Points: 115392 Folding Title: Super Ultimate Folder - Level 1Folding Points: 115392 Folding Title: Super Ultimate Folder - Level 1Folding Points: 115392 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 2 Weeks 4 Days 16 h 44 m 28 sec
Reputation Power: 414
Send a message via ICQ to kicken Send a message via AIM to kicken Send a message via MSN to kicken
Quote:
Originally Posted by chads2k2
#48 - Resizing an image with PHP


Actually, with that code you don't need the GD library at all.

Quote:
Originally Posted by php manual
Note: The getimagesize() function does not require the GD image library.


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

http://wiser.aoeex.com/ - Long term project (offline due to evil crawlers and lack of content)
http://www.aoeex.com/gmap.php - Put yourself on the map

Reply With Quote
  #66  
Old May 11th, 2006, 12:04 PM
LinuxPenguin's Avatar
LinuxPenguin LinuxPenguin is offline
fork while true;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2005
Location: England, UK
Posts: 5,535 LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)LinuxPenguin User rank is General (90000 - 100000 Reputation Level)  Folding Points: 11590 Folding Title: Novice Folder
Time spent in forums: 1 Month 3 Weeks 1 Day 19 h 23 m 58 sec
Reputation Power: 999
This should give you most of the detail: http://www.tutorialized.com/tutoria...-with-PHP/11878

Reply With Quote
  #67  
Old July 9th, 2006, 08:19 PM
chadsmith729's Avatar
chadsmith729 chadsmith729 is offline
--Retired--
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Sep 2003
Location: Enjoying forum retirement.
Posts: 3,113 chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)  Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1Folding Points: 281422 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 16 h 31 m 40 sec
Reputation Power: 893
#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
Comments on this post
bluedragon agrees: Totally agree : Xampp and the like are great for localhost when starting out . . . but learn how to
do it on your own!
trinisam agrees: Excellent advice...

Last edited by chads2k2 : July 19th, 2006 at 08:06 AM. Reason: Added another tutorial.

Reply With Quote
  #68  
Old October 4th, 2006, 09:36 AM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Beware
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2006
Location: Texas, USA
Posts: 1,435 ManiacDan User rank is First Lieutenant (10000 - 20000 Reputation Level)ManiacDan User rank is First Lieutenant (10000 - 20000 Reputation Level)ManiacDan User rank is First Lieutenant (10000 - 20000 Reputation Level)ManiacDan User rank is First Lieutenant (10000 - 20000 Reputation Level)ManiacDan User rank is First Lieutenant (10000 - 20000 Reputation Level)ManiacDan User rank is First Lieutenant (10000 - 20000 Reputation Level)ManiacDan User rank is First Lieutenant (10000 - 20000 Reputation Level)ManiacDan User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 16 h 53 m 15 sec
Reputation Power: 176
Quote:
Originally Posted by ape2man
#30 How do i str_replace thats not case sensitive

PHP Code:
/* Was submitted by jpenn : Senior Member */

function stri_replace$find$replace$string )
    {
    
$parts explodestrtolower($find), strtolower($string) );

    
$pos 0;

    foreach( 
$parts as $key=>$part )
        {
        
$parts$key ] = substr($string$posstrlen($part));
        
$pos += strlen($part) + strlen($find);
        }

    return( 
join$replace$parts ) );
}

echo 
stri_replace$find$replace$string ); 



Easier, I think, to do a preg_replace with the i modifier:
PHP Code:
 $new_string preg_replace("/$find/i"$replace$original_string); 


Faster than jpenn's implementation I think. Although that's pretty good as well.

-Dan

Reply With Quote
  #69  
Old December 29th, 2006, 08:13 AM
srisa srisa is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Location: Hyderabad, India.
Posts: 480 srisa User rank is Sergeant (500 - 2000 Reputation Level)srisa User rank is Sergeant (500 - 2000 Reputation Level)srisa User rank is Sergeant (500 - 2000 Reputation Level)srisa User rank is Sergeant (500 - 2000 Reputation Level)srisa User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 2 h 9 m 37 sec
Reputation Power: 10
You can use the inbuilt function str_ireplace(search, replace, source)

Reply With Quote
  #70  
Old May 7th, 2007, 01:52 AM
helloakash's Avatar
helloakash helloakash is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: India
Posts: 851 helloakash User rank is Colonel (50000 - 60000 Reputation Level)helloakash User rank is Colonel (50000 - 60000 Reputation Level)helloakash User rank is Colonel (50000 - 60000 Reputation Level)helloakash User rank is Colonel (50000 - 60000 Reputation Level)