Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Get Localhost - Very Simple


This is a very simple question I think, but I can't find a straight answer from the php documentation. What is the function or variable that I can use to get localhost information?




View Complete Forum Thread with Replies

Related Forum Messages:
Something Simple!? Sessions - Admin.localhost To Main.localhost
Why does the following code allow me to keep the same session when in
the same sub domain (ie admin.localhost), yet not when I goto another
related domain eg main.localhost?

I would like to have the same session on the related domain. I bet
the solution is really simple <grin>!...

Using IE6. Win NT, Apache 1.3.27, PHP 4.3.2.

php.ini file - shown at end of message (apologies for length).. is
actually a copy of a PHP4.3.0 ini file (problem here?)

hosts file in windows:

127.0.0.1 localhost
127.0.0.1 admin.localhost
127.0.0.1 main.localhost

httpd.conf

setup for VirtualHosts
eg
ServerName admin.localhost.com

// session_test.php -- located in admin.localhost
<?
session_start();
echo "id is " . session_id();
?>
a href="http://admin.localhost/session_test1.php" next

a href="http://main.localhost/session_test2.php" next

// session_test1.php -- located in admin.localhost
<?
session_start();
echo "id is " . session_id();
?>

// session_test2.php -- located in main.localhost
<?
session_start();
echo "id is " . session_id();
?>

View Replies !
Simple Sessions On Localhost
I'm experimenting with sessions on my localhost setup and can't get 'em to fly. I'm setting the session cookie with this in pageone.php: PHP Code:

View Replies !
Localhost Redirectine To "www.localhost.com"
php5, mySQL, apache 2.0.55 -

when I type "http://localhost/somename" in the status bar I can see it redirecting to "http://www.localhost.com/somename". Why is that?

View Replies !
Simple Script For Doing A Simple Photo Album And Journal?
I'm looking to quickly get a photo album online. Very simple, thumbnails,
a few pages, maybe a description, but hopefully a small script that's easy
to edit and work into my existing site. I know about hot scripts, etc. but
I was wondering if any one could recommend one?

Secondly, I also want to setup a journal. It's not really a "blog"
although I guess blog software may work. But it isn't going to be a
message board or anything like that. Just a place to put out random bits
of news. Once again, same premise, I'm trying to find the most simple
script possible that could basically traverse a directory of simple
textfiles and produce a list.

I know all about Blosxom and stuff like that, but I'd like a script that
just did the above and didn't overtake my site like PHPNuke or something
like that. I'll probably roll my own, but I thought I'd check first.

View Replies !
Simple Simple String Question
When I take the input from a textarea and insert it into a mysql-base and then retrieve it and show it, all the line feeds/breaks are gone.

It is shown as one giant string. How can this be fixed, so the text will be shown as it was entered? Does it have something to do with stripslashes/addslashes or am I way off?

View Replies !
Re Localhost
I'm trying to find out what an absolute path to localhost on my computer would be...

On the web, I understand it to be something like this '/home/users/myUsername/public_html/includes/myFile.php', but what about if PHP and apache are installed on a PC?

Or could it just be the windows path to the localhost folder?

View Replies !
Localhost
when my form mails,it show "from: me@localhost",doesn't matter if I say

mail("FROM:me@mymail.co.za", $to, $subject , $message);

or

$to = "info@fullhouse.co.za, $custemail";
$subject = "RoboGuard Order";
$from = "me@mymail.co.za";

Does anyone know why?

View Replies !
PHP Mail - Localhost
Using PHP 4 on Win 95 with Apache. I would like to test the PHP mail function without going to the net using localhost. The system works fine in parsing and returning a HTML form. What do I need to change in order to have the mail locally sent to NS 4.7 or Outlook Express?

The PHP INI file mail function is SMTP = localhost
send_mail from = myaddress@alaska.net

What mail address should be used in the PHP part of the mail form?
mail($to, $subject, $msg, $mailheaders) as $to = "localhost"; ??

I receive the following message back: Warning: Failed to Connect in c:phpweb/form.php on line 18. Line 18 is the above mail($10..... which seems to indicate that it can not find the server or the path to the server.

Please let me know what to alter so that localhost will send the PHP email to the appropriate email client w/o going on the net. i.e. it works just fine when using the net, but local testing would be better.

View Replies !
Cookies On Localhost, How?
I am learning how to set a cookie with php.

I have the following code at the top of my page:

setcookie("user", "name", time()+3600, "/", "", 0);

this works but i would like to know where the cookie is in my cookies folder. Its not named localhost, my computers name or my ip address. What would it be called if you don't set a domain name?

Also, is this the right way to set a cookie on local host? I tried putting localhost as my domain but since i'm using xp and ie6 it doesn't work.

View Replies !
Ip Ban Works On Localhost, Not On Www
I have the following page to ban people from viewing my website...

<?php
$iptest = $_SERVER['REMOTE_ADDR'];
$data="";
$fp = @fopen("../ip.txt", "rb") or die("Couldn't open file");
while(!feof($fp))
{
$data .= fgets($fp, 1024);
}
fclose($fp);
$values = explode("", $data);
if(in_array($iptest, $values))
{
die('You have been banned from this site');
}
?>

The contents of ip.txt are in the following format..
81.59.75.xx
81.27.204.#*$!
80.127.6.xxx
212.32.102.xxx

If i add 127.0.0.1 and run this page from a localhost it bans me successfully but as soon as I upload the page it and add my IP to test it, it does not work on the web!

View Replies !
Session_set_cookie_params On Localhost
I want to test locally and can't get past my cookie protection, is this
right? It doesn't seem to work ...

if ($_SERVER['REMOTE_ADDR']=="127.0.0.1") {
session_set_cookie_params(7200, '/', '.localhost');
} else {
session_set_cookie_params(7200, '/', '.domain.com');
}

View Replies !
Cmod On Localhost...?
Ive set up a localhost server (php, mysql, perl, phpMyAdmin) on my windows98 computer (yes i have gone completely mad...) under the tutorial found @ codingclick.com. Now. I need to do some forum dev work (phpbb.com) and i need to chmod (a + w) the config file for installation purposes. PHP Code:

View Replies !
Mozilla, Localhost
I'm not sure if this is a bug or a problem on my end. All of a sudden, I've run into a problem with Mozilla serving up a certain PHP file. Any PHP file on my server will work fine, except for one that contains: <?php phpinfo(); ?>

The confusing part to all of this is that the file will output properly ONLY if I don't call it using: "http://localhost/phpinfo.php". If I use "127.0.0.1" or any other DNS, it will serve up properly. But when trying to access it via "localhost", Mozilla prompts me on what to do with the file-type, as it does not know how to handle that file-type.

View Replies !
Localhost Problem
is it possible to test my php files from dreamweaver?

i hgave installed apache server and php4.0. i can test my pages in explorer but is it possible to set dreamweaver to open php page when i click on preview?

View Replies !
Localhost, PHP And Email
I am running Apache and PHP on "localhost" (ie. offline), is there a way to
setup PHP to run scripts which may use the mail facility of PHP so that if
a script is supposed to send an email - it sends an email rather than choak
(so you don't know for sure the script actually works until you upload and
test online)?

View Replies !
How To Get The Path From Localhost?
I have the localhost physical path that is

E:www estproject

and __FILE__ that is

Now I'd like to get the relative directory of file.php to the localhost
path:

View Replies !
Cookies On Localhost?
i dont know whether this is a matter of having my global varibles turing off or not. PHP Code:

View Replies !
Php Not Working With 'localhost'
When I run a php file in my browser using an IP address, it renders
just fine. But when I run the php file using 'localhost', it renders
the source code. It's as if it does not recognize it as php. There are
other variables, but I don't want to make a full page post.

In a nutshell:
(http://192.130.0.230/~username/file.php) works
(http://localhost/~username/file.php) does not work.

View Replies !
Localhost Php Strangeness
I have this issue seeing php manipulated images locally. Below is a file called random.php I call on it like so - <img src="images/random/random.php?pic=random"> This works peachy online but it just shows a broken image locally. Code:

View Replies !
Email Via Localhost
I am using xp pro. Php was installed by someone else. Is it possible to retreive user and password.?

Ultimately I would like to test php forms offline by sending data to ms outlook. How is this set up?

View Replies !
Apache/PHP On Localhost
I installed Apache and PHP and it works then I went to whatismyip.com and gave my IP to someone and he typed it in and the error he recieved was "unable to connect". Am I missing something?

View Replies !
Finding Out Localhost
is their any way to find out "localhost" of mysql to get the actual address? If not, is their any way to pull the content of a table off of localhost and connect to mysql on another server and insert the data into a table there?

View Replies !
Mail() On Localhost
I'm trying to get the mail() function to work but running into problems. I have SMTP set to localhost and smtp_port set to 25 then I'm saying

$m=mail('me@hotmail.com','failed login attempt','failed login attempt','From:test@test.com');

and then checking 1) to see if I get the mail, and 2) the value of $m which is zero. What should be the next thing to check? I saw something about an smtp app, which I don't know if I have or not.

View Replies !
Accessing Localhost
Foxserv is a program that makes installation a breeze. I simply want to setup Foxserv so that I can edit dynamic websites locally. The program installed without a hitch, but when I went to access http://localhost/ (for the Foxserv menu), I was asked for a username/password in an authentication screen. It looked like the URL was redirected to http://localhost/localstart.asp.

I believe localstart.asp is related to IIS...right? I don't see why it would automatically redirect itself there. Or why IIS would even come into play for that matter. In Opera, it also mentions something about ccd.mydomain.com in 'comments'...I REALLY can't imagine why my domain would have anything to do with it.

View Replies !
Localhost Issue
$host="localhost";
$password="":

i dont have a password for local host and still its not working. please any suggestions as to what i can do about not putting password a this stage for a mysql connection.

View Replies !
PHP Mail Localhost
i want to send mail from my localhost in php,i try to using my outlookexpress smtp and email parameters but it gives warning like this:

Warning: mail() [function.mail]: SMTP server response: 553 Sorry, that domain isn't in my list of allowed rcpthosts. in D:wampwwwmail.php on line 9

It's possible to send mail from localhost ,then what are the changes php. ini settings for sending mail.

View Replies !
Mysql: Localhost
Whenever I connect to a mysql database, I always connect to 'localhost'. Does that mean that you can connect to a database on another host? If you can, does that mean that I could use the same database for both of my websites (which are hosted with different people)? And if you can, how please? I assume that I would have to create another mysql user, but how would I connect to the database?

View Replies !
Shell_exec On The Localhost?
im expecting notepad to open up when I run the on the localhost???/ But its not

<?php
shell_exec('c:windows
notepad.exe');
?>

View Replies !
FTP And Localhost Security
I'm eye-brows deep into a CMS project that's using PHP on the server, and am trying to find out some definitive info on using PHP's FTP functions and the impact that this will have on security.

My Question:

Does ftp'ing on localhost (transferring a file or changing permissions on the same machine) constitute a security issue?

Its clear to me that any ftp op over the net is inherently insecure (as user+pass, etc are transmitted in clear text), but need to find out if using ftp just on the localhost also suffers from this weakness. Not sure how someone would be able to sniff the packets if all was happening on localhost, but would be nice to *know* and not guess

View Replies !
Localhost Directory
Where is localhost on default? And where you change that?

View Replies !
URLS On Localhost/php
Ive been searching for hours and not found a definitive answer to this - but how can you get IIS (windows xp pro) to read .htaccess files and therefore allow search engine friendly urls?

View Replies !
Localhost Cookies
On localhost I set my cookies with following code:

setcookie('cookiename', 'secret', time()+26297, '/', false);

As you can see, Im passing a boolean false as my domain parameter as browsers don't like domains with less than 2 dots and this is the way to bypass it. The only thing wrong with this method is the cookie is not available to localhost subdomains.

View Replies !
Php Script On Localhost
I downloaded xampp in order to run php on my pc/localhost. I've got php scripts running - but I'm having problems getting emails to send using the mail() php function.

View Replies !
Localhost Constant
I am currently migrating servers and after installing PHP/MySQL I am getting problems with any scripts that attempt a database connection along the lines of: PHP Notice: Use of undefined constant localhost - assumed 'localhost' in /var/www/html/database.php on line XX.

I realise that the fix is to add quotes around each usage of localhost, but as we are hosting many websites for different users who all use the unquoted form of localhost, I would rather set it up as a constant again. why did localhost function as a constant on my old installation (Fedora - MySQL - 4.0.27-standard / PHP 4.3.10), but not on my new installation (Centos - MySQL - 4.1.20 / PHP 4.3.9).

View Replies !
Localhost And Server
I am currently developing on a windows XP machine and upload my code via subversion to a linux server. All was great, until I just tried to test out using Zend Studio.

if ($_SERVER['REMOTE_ADDR']=="127.0.0.1") {
$base_path="../path/";
}
else {
$base_path="/home/account/public_html/path/";
}

Zend studio didn't like 'REMOTE_ADDR' - Undefined index: REMOTE_ADDR, which then meant it couldn't include any files and fell over. I am also having problems using cookies and sessions.

if ($_SERVER['REMOTE_ADDR']=="127.0.0.1") {
session_set_cookie_params(7200);
} else {
session_set_cookie_params(7200, '/', '.example.com');
}

View Replies !
Localhost Not Recognising
I am trying to test a project on my local machine (running Win XP, Apache, PHP, MySQL), but when I send a variable like this: "index.php?sect=login" it wont recognise it and spits out an error saying it is undefined. Is there something I need to change in PHP ini for this to work.

View Replies !
Open Localhost
In my old computer everything worked ok! I set the system (windows XP like in the old computer) to my new computer but cannot open the localhost. I have made everything exactly as before. I installed wampp2 as indicated just exactly as I did it before. Mysql is running, Apache is running, but when I write in browser http:localhost should come the site from phpMyAdmin like before but it doesn't.

View Replies !
SMTP Localhost
I have this error PHP Code:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in class.SimpleMail.php on line 70

Fatal error: Uncaught exception 'Exception' with message 'Sending mail failed.' in class.SimpleMail.php:78 Stack trace: #0 user_transact.php(76): SimpleMail->send('francesko@cot...', 'Mailing list co...', 'Hello ciccio?Ou.', 'From: francesco...') #1 {main} thrown in class.SimpleMail.php on line 78

View Replies !
Session.cookie_domain On Localhost
what should i set session.cookie_domain to in the php.ini file for use on localhost with sessions? I have it currently set to "localhost" but it doesnt work, what can I set it to so it will work with http://localhost or http://127.0.0.1? I already searched for this problem but no luck.

View Replies !
Localhost Testing Speed
I'm currently testing my PHP scripts in two locations. The first is my workplace, where I am using Windows 2000 SP4, and IIS. The other location is my home, where I also use Windows 2000 SP4 and IIS.

The problem, is that when I run PHP scripts on my work PC, it takes a couple of seconds to display the page. But when I do exactly the same script at home, it is near instant.

Are there any configuration changes I should make to IIS or something which may be different. The only real difference between the two machines, is that my work one is on a corporate LAN.

View Replies !
How To Get Imagemagick Working With PHP On Localhost.
Does anyone know how to get Imagemagick working with PHP on localhost. I have Windows XP pro with PHP4.2.2 on Apache.

I have installed ImageMagick and it works ok from the command prompt, but i cant seem to run the commands within PHP from the system() command?

View Replies !
Http://localhost/test.php
I relatively new to PHP. Please help. I installed Apache, PHP. Then when I tried to test it by opening a test.php file with just the phpinfo() function in it doesn't execute the php file which is <? phpinfo(); ?>
instead, sends it for download and when I tried the same with a different filename like test.php3 or test.php4.

View Replies !
Sending Mail Through Localhost
I've already define SMTP and sendmail_from on my ini file but there's still no respond when I tried to send a mail from my script.

View Replies !
How Use Php4 / Php5 In Localhost
I use wmserver that have mysql apache and php4; which solutions are there for to use both in localhost: php4 or php5 according to needs?...

View Replies !
PHP And Apache Localhost With Sessions
is it posible to have sessions functioning on localhost with apache ? I get this warning

Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

I am fairly sure I need to edit the relivent line of the php.ini but I dont know in what way.

View Replies !
Why Is Localhost Added To All My Links ?
Not sure if this is a php, mysql, or apache issue. I use win2k and I
have AMP on my system as a localhost. I use this to test PHP/MYSQL
scripts I write on my local PC.

I render a URL w/PHP by reading the URL string from a mysql field, eg.
on the php web page it shows as eg. www.yahoo.com link

But when I click the link I see that "localhost" is added to the URL
and it goes nowhere. ie. it get localhost added to the front -
localhost/www.yahoo.com

Is there a setting somewhere so that the link is exactly what the link
is and localhost is not added.

View Replies !
Sessions Only Work On Localhost
I've created a website using Win2000 & apache. The site works fine there. I than wanted to move the website on a redhat8 server (using it in a production envoronment), but there I am getting trouble with the sessions I use in the site.

The problem is on the redhat localhost, sessions works fine, but throughout the office network (using win2000 machines) pages don't work because it appears that sessions contain no data or 'wrong' data. E.g.,

A user enters a certain area of the website (the areas I organized using directories). Everytime a user enters a particular direcory I set up a sessions for the user in default.php of the specific directory. I do this because I want the user to enter a directory through the directory's default.php. I create a sesion called $_SESSION['areasection']=", and give it the value of the directory (a,b,c,d,e,...)
example: Code:

View Replies !
Mod_rewrite Confusion (localhost)
If i have the following URL:

http://localhost/coolflix/cart/cart...true&movieid=53

how, using mod_rewrite can i get the URL to show:

http://localhost/coolflix/cart/1/53

View Replies !
Can't Pass Variables By URL On Localhost
I'm developping on localhost (127.0.0.1). When I try to pass parameters from one page to another using the standart way (URL), I just can't retrieve the values. In fact, the isset($varname) returns false. Code:

View Replies !
Problem Running PHP On Localhost
I have installed Apache and PHP (and MySQL) on my own computer so that I can
test
out my scripts without having to keep uploading them to my ISP.
I have created a very simple php script (below) just to test out my set-up.
This works fine when I upload it to the server at my ISP (when I type
something
in the box, it is displayed back to me) but when I run it on my own system,
I get nothing. I can see the value in the querystring in the address bar of
my browser, but the $eek variable does not seem to be being set. Is there
something I need to enable in PHP or Apache to make this work?

<HTML>
<BODY>
<?php
echo $eek;
?>
<FORM>
<INPUT name=eek>
</FORM>
</BODY>
</HTML>

View Replies !
Phpmyadmin Localhost/ip/cache
I got PHPMYADMIN installed locally on my pc and i access it by locahost/phpmyadmin
works fine, but it doesnt show the updates in the db for more than one time...i have worked with the db for over 2 month now and in phpmyadmin it still looks like day one, and i have todo anything manually...not too bad but it would be more comfortable to work with phpmyadmin directly...whats the problem ? cache ? opera does the same thing :/

second problem is when i access my phpmyadmin from another pc with ipphpmyadmin it loads, but when i then select my db it reloads with localhost in the URL line and not with the ip and that of course doesnt work from another pc that is not the localhost.

View Replies !
Cannot Connect To Localhost Using GoDaddy
I'm (trying) to help a friend setup a MySQL db and use some simple
scripts on a site hosted with GoDaddy. I note that GoDaddy appears to
use Microsoft. I have done this:

$connection = mysql_connect("localhost","mydatabase","password")
or die ("Couldn't connect to server.");
$sql = mysql_query("SELECT * FROM dummy");
$row = mysql_fetch_array($sql);
echo $row['name'];
?>

on several Apache servers and it always seems to work. I created the
MySQL database using the GoDaddy control panel (which is very confusing
and poor IMO). I dove into phpAdmin and was able to do stuff. But I
can't get php to connect.



View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved