Jump to content

DomenicF

Members
  • Posts

    18
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

DomenicF's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you very much! I understand the basic concept now! EDIT: When I get a chance I'll try and make the code I originally wanted and post it here.
  2. Thanks a lot for your help. So let me try and put this into English, and correct me if I am wrong: The first part of the for loop is the starting point, or integer. The second part of the for loop is the ending point, or integer. The third part tells what to do with the first part until it gets to the second part. Does this sound right?
  3. It's not for a homework/interview question, if it was I wouldn't be here, I'd either be talking to my professor or just not take the job. I already did, but didn't want to post it as it just causes an infinite loop. I really have NO idea what I'm doing, which is why I posted here. for ($i = 5; $i <= 150; 5++) { echo $i; } As I said, I have NO IDEA what I'm doing. I'm a noob. Trying to learn.
  4. Hey guys, I really need help here. For the past hour I've been trying to figure out the for loop, but I honestly just can't. I was wondering if we could learn by example. Here's what I want to for loop to do, perse: $avg = 150; for every 5 added to $avg (150) multiply only what is added by 3 I was wondering what the code is for this, and if this specific problem is more complicated than others. I like learning by example, so I hope someone could help me out.
  5. Thanks, that seems a lot cleaner.
  6. So in the end I just assigned trim() to another variable and got it to work. My code now is as follows: $country = shell_exec('geoip-lookup '.$_SERVER['REMOTE_ADDR']); $output_country = trim($country); if($output_country == "US") { $temp = $temp_F; echo "Fahrenheit<br />"; echo $country."<br />"; var_dump($country); } elseif($output_country != "US") { $temp = $temp_C; echo "Celcius<br />"; echo $country."<br />"; var_dump($country); } else { echo "This is a recording.<br />"; var_dump($country); } Appreciate your time!
  7. I just tried it, and you may be on to something. The output of var_dump is: string(3) "US " So, I changed my code to: $country = shell_exec('geoip-lookup '.$_SERVER['REMOTE_ADDR']); if($country == "US ") { $temp = $temp_F; echo "Fahrenheit<br />"; echo $country."<br />"; var_dump($country); } elseif($country != "US ") { $temp = $temp_C; echo "Celcius<br />"; echo $country."<br />"; var_dump($country); } else { echo "This is a recording.<br />"; var_dump($country); } And I still have the same results. With that being said, I did: trim($country); And it still outputs as 3 characters. So, I'm not sure what's going on.
  8. Yes, it echoes Celcius and when I echo $country it echoes US. I don't have it, but I believe it is a perl module. Here's my host's wiki: http://wiki.dreamhost.com/GeoIP Here is an example output of geoip-lookup: $ geoip-lookup google.com US
  9. Hey guys, My host doesn't support the native GeoIP functions of PHP, so they suggest to use the Perl module that they have installed on the OS to do the work. Here is my code: $country = shell_exec('geoip-lookup '.$_SERVER['REMOTE_ADDR']); if($country == "US") { $temp = $temp_F; echo "Fahrenheit"; } elseif($country != "US") { $temp = $temp_C; echo "Celcius"; } else { echo "This is a recording."; } Now, even when $country is definitely set to US, it still always comes back to Celcius. I've already tried doing the script without the elseif, and it doesn't make a difference. Looking for some help.
  10. You're right, I just wasn't fully understanding the function before. I tried a few things and got it working. Appreciate the link!
  11. I took a look into that, and tried putting it into practice, but could not figure it out. The examples they give aren't very helpful to be honest, would you mind writing an example for me? I would really appreciate it.
  12. If the directory with the images stay the same, but your pages are in different directories, you could just make a separate file with a variable that is set to the directory of the images. For example... $imgdir = "http://yourdomain.com/images"; And on other pages... include_once('image_include.php'); <img src="{$imgdir}/image.jpg" />
  13. Thanks for your response. I have this code right now, but nothing has changed with the output. if (!in_array("-h", $argv) || !in_array("--help", $argv)) { // stuff here } else { echo "Help!"; }
  14. Hello, I have a script that takes two parameters that I retrieve with $argv. But, I see a lot of scripts in other languages that have "--help" and "-h" in them and other options/flags like that, and I'm curious to find out the correct way to add these to my script. Any suggestions?
  15. Thanks, I figured it out. Was a pretty stupid thing I did huh?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.