Ip-grabbing in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

Ip-grabbing in php

Post 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.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Re: Ip-grabbing in php

Post 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;
?>
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

Post by potato »

That simple? 8O


1000 x thanx. :D
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

If you think that is complex, wait until you learn OOP.. :wink:
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

Post by potato »

step by step, no?
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

oh dont pay attention to Sami, just trying to scare ya.

:twisted: :twisted: :twisted:
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

Post 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.
Goowe
Forum Commoner
Posts: 94
Joined: Mon Mar 15, 2004 9:51 am
Location: Southeast Alaska

Post by Goowe »

Yeah it definitely is...

I think you might have to use AND instead of & but I've never tried the second option :roll:
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

insead of &, the syntax would be AND

$sql = "SELECT * FROM table_name WHERE id1='$id' AND id2='$id2'";
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

Post 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)"
};
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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)";
}
Last edited by tim on Tue Mar 16, 2004 9:52 am, edited 1 time in total.
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

Or:

Code: Select all

$sql = "SELECT * FROM table_name WHERE id1='$id' && id2='$id2'";
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

Post by potato »

thanx tim, you have made my day a litlle shorter, if you get what i mean.
Sorry for my english. :oops:
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

tim wrote:oh dont pay attention to Sami, just trying to scare ya.

:twisted: :twisted: :twisted:
:twisted: :P

More info @ http://www.mysql.com/doc/en/INSERT.html
Post Reply