Page 1 of 1
Ip-grabbing in php
Posted: Tue Mar 16, 2004 8:30 am
by potato
Need help to grab someone's ip and make it a php var.
I know that the ip-grabbing should be done with javascript, but
that's all i knows.
And the only scripts that i can find are with javascript and asp.
Any idea would be welcome.
tom.
Re: Ip-grabbing in php
Posted: Tue Mar 16, 2004 8:35 am
by tim
Bevibed.be wrote:
I know that the ip-grabbing should be done with javascript, but
that's all i knows.
Nonsense. and if u was to search for this, you would find a answer 10x quicker then it did for u to type this thread.
Code: Select all
<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo $ip;
?>
Posted: Tue Mar 16, 2004 8:44 am
by potato
That simple?
1000 x thanx.

Posted: Tue Mar 16, 2004 8:45 am
by m3mn0n
If you think that is complex, wait until you learn OOP..

Posted: Tue Mar 16, 2004 9:06 am
by potato
step by step, no?
Posted: Tue Mar 16, 2004 9:07 am
by tim
Posted: Tue Mar 16, 2004 9:30 am
by potato
Another thing, is it possible to make a mysql query like:
select * from agenda where band_id ='$id' & user_id='$userid'
So with more than one filter or how you call this.
Posted: Tue Mar 16, 2004 9:31 am
by Goowe
Yeah it definitely is...
I think you might have to use AND instead of & but I've never tried the second option

Posted: Tue Mar 16, 2004 9:34 am
by tim
insead of &, the syntax would be AND
$sql = "SELECT * FROM table_name WHERE id1='$id' AND id2='$id2'";
Posted: Tue Mar 16, 2004 9:49 am
by potato
Does someone see the fault in it?
i get following error message: parse error, expecting `','' or `';'' in /
if ($totalRows_Recordset2 = "0"){
mysql_select_db($database_memberships, $memberships);
$query = mysql_query("UPDATE bands SET band_rating='$newrating' WHERE band_id='$bandid'")or exit('Not updated!');
echo "Rating Updated"
}else{ //here is the parse error
echo "You already had voted for this artist(s)"
};
Posted: Tue Mar 16, 2004 9:50 am
by tim
if ($totalRows_Recordset2 = "0"){ \
change
if ($totalRows_Recordset2 == "0"){
echo "You already had voted for this artist(s)"
};
change
echo "You already had voted for this artist(s)";
}
Posted: Tue Mar 16, 2004 9:51 am
by penguinboy
Or:
Code: Select all
$sql = "SELECT * FROM table_name WHERE id1='$id' && id2='$id2'";
Posted: Tue Mar 16, 2004 9:53 am
by tim
wait theres alot of syntax errors:
Code: Select all
<?php
if ($totalRows_Recordset2 = "0"){
mysql_select_db($database_memberships, $memberships);
$query = mysql_query("UPDATE bands SET band_rating='$newrating' WHERE band_id='$bandid'")or exit('Not updated!');
echo "Rating Updated"
}else{ //here is the parse error
echo "You already had voted for this artist(s)"
};
?>
Code: Select all
<?php
if ($totalRows_Recordset2 == "0"){
mysql_select_db($database_memberships, $memberships);
$query = mysql_query("UPDATE bands SET band_rating='$newrating' WHERE band_id='$bandid'")or exit('Not updated!');
echo "Rating Updated"; // forget the ; here
} else {
echo "You already had voted for this artist(s)";
}
?>
that should work
Posted: Tue Mar 16, 2004 9:55 am
by potato
thanx tim, you have made my day a litlle shorter, if you get what i mean.
Sorry for my english.

Posted: Tue Mar 16, 2004 10:03 am
by m3mn0n