i am totaly new to server side scripting and found this niffty script
<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo $ip;
?>
can someone tell me how to save $ip to a file?
also i was wondering what all this file.php?code=code stuff is about
also, i was on greycobra.com and keep encountering the problem of this information i need, for example
http://www.greycobra.com/tutorials.php? ... view&id=53
asks you for your host, database and i don't even know where mySQL surver thingy is or what it is exactly
and
FYI i use http://hosting.mixcat.com/ so.. ya
_________________________________
help=goodness
[SOLVED] needs help with saving a $variable to a file &
Moderator: General Moderators
Re: [SOLVED] needs help with saving a $variable to a file &a
That is how you pass a variable to a scriptasi0917 wrote: also i was wondering what all this file.php?code=code stuff is about
create test.php and put the following code in it:
Code: Select all
<?php
print_r($_REQUEST);
?>This is how php gets user input, to get a specific input do something like:
Code: Select all
<?php
echo ("I like " . $_REQUEST['affection']);
?>This should print out "I like php"
see where I'm going?
That is an issue to take up with hosting.mixcat.comasi0917 wrote: asks you for your host, database and i don't even know where mySQL surver thingy is or what it is exactly
and
FYI i use http://hosting.mixcat.com/ so.. ya
Is your email and ftp and host logins/passwords all the same? If so then your mysql password is probably the same as well, usually the host is "localhost"
Code: Select all
<?php
$link = mysql_connect('localhost', username', 'password')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
?>What this is doing is connecting up to an sql server, sql means simple query language and a sql server basically allows you to interact with a database from your script.
- asi0917
- Forum Commoner
- Posts: 41
- Joined: Thu Nov 25, 2004 10:37 am
- Location: Shoreline, Washington
- Contact:
so why doesn't this work?
????
?>
Code: Select all
<html>
<body>
<a href="http://hosting.mixcat.com/asi0917/welcome.php?=1">
#1</a>
<br>
<a href="http://hosting.mixcat.com/asi0917/welcome.php?=2">
#2</a>
<br>
<?php
echo ("I like " . $_REQUEST['link']);
?>
<?
if ($_REQUEST['link'])===1);
{
echo "you clicked link #1";
}
else
{
echo "you clicked link #2";
}
?>
</body>
</html>?>
2 reasons
1, you didnt name the variable in the url
you did
?=1
you should have done
?link=1
2,
you are improperly using the === operator.
=== means equal AND of the same data type
== just means equal, and is less specific
data which comes trhough $_REQUEST is generally of data type string
you are saying
if $_REQUEST['link'] is equal to and the same type, as integer 1
you want to say:
if $_REQUEST['link'] is equal to and the same type, as string 1
this would work
1, you didnt name the variable in the url
you did
?=1
you should have done
?link=1
2,
you are improperly using the === operator.
=== means equal AND of the same data type
== just means equal, and is less specific
data which comes trhough $_REQUEST is generally of data type string
you are saying
if $_REQUEST['link'] is equal to and the same type, as integer 1
you want to say:
if $_REQUEST['link'] is equal to and the same type, as string 1
this would work
Code: Select all
if ($_REQUEST['link']) === '1') { // the quotes mean its a string