今天第三个问题抱歉。
我想出了如何将IP地址插入到sql(woohoo)中,它已经有效了。
if (empty($userid)) {
$names= array('Goat', 'Goat Toucher', 'Goat Fondler', 'Goat Farmer', 'Goat Keeper', 'Goat Herder', 'Goat Stalker', 'Goat Lover', 'Ettamogah', 'Bungle Bungle', 'Teapot', 'Fuzzyface', 'Walker', 'Stroker', 'Eggtrump', 'Ghoul', 'Who', 'of Doom', 'of Mercy', 'of JFC', 'From Above', 'Strangler', 'Pooper', 'Servant', 'Bunny', 'Layer', 'Slayer', 'Hu Wong', 'Phu King Phat', 'Entombed', 'Orama', 'Wobbly Finger', 'Crooked Toe', 'Up the Duff', 'Lover', 'Geek', 'Freak', 'Jelly Bottom', 'Invader', 'Impaler', 'Arouser', 'Handler', 'Googly Eyes', 'Buddha Belly', 'Big Nose', 'No Nose', 'Ogre', 'Pink', 'Princess', 'Angel', 'Devil', 'Demon', 'Thunder Thighs', 'Sugar Lips', 'Cupcake', 'Sweetiechops', 'Midget', 'Loony', 'Anonymous');
$random = rand(0,count($names)-1);
$name= $names[$random];
$ip=$_SERVER["REMOTE_ADDR"];
$ip = ip2long($ip);
$sql = ("insert into cometchat_guests (name,lastactivity,ip) values ('Guest ".mysql_real_escape_string($name)."','".getTimeStamp()."','".$ip."')");
$query = mysql_query($sql);
$userid = mysql_insert_id();
setcookie($cookiePrefix.'guest', base64_encode($userid), time()+3600*24*365, "/");
}
return $userid;
现在..我需要打印它。
SELECT INET_NTOA(ip) FROM 'user' WHERE 1
我在那之后放了什么?
SELECT INET_NTOA(ip) FROM 'user' WHERE 1 = $uid or
SELECT INET_NTOA(ip) FROM 'user' WHERE 1 echo $ip
什么? PHP让我很头疼哈哈,但我很开心学习!
我需要在哪里打印它:
if($owner == 1 || in_array($userid,$moderatorUserIDs))
SELECT INET_NTOA(ip) FROM 'cometchat_guests' WHERE 1 {
$options="<input type=button value='".$chatrooms_language[40]."' onClick=javascript:".$caller."kickUser($uid,0);$close class='invitebutton'>
<input type=button value='".$chatrooms_language[41]."' onClick=javascript:".$caller."banUser($uid,0);$close class='invitebutton'>".$options;
}
好的,所以我想我明白了
__
if($owner == 1 || in_array($userid,$moderatorUserIDs)) {
$options="<input type=button value='".$chatrooms_language[40]."' onClick=javascript:".$caller."kickUser($uid,0);$close class='invitebutton'>
<input type=button value='".$chatrooms_language[41]."' onClick=javascript:".$caller."banUser($uid,0);$close class='invitebutton'>".$options;
$sql = getGuestDetails($uid);
$sql = "SELECT INET_NTOA(ip) FROM 'cometchat_guests' WHERE 'userid' = 1";
$result = mysql_query($sql);
while($rows = mysql_fetch_assoc($result))
尝试过它......它不起作用。它什么都没有,它只是空白。我要尖叫!我很快开始讨厌PHP。为什么赢得它只是打印OMG
答案 0 :(得分:0)
$sql = "SELECT INET_NTOA(ip) FROM 'cometchat_guests' WHERE 'UserId'=1 ";
$result = mysql_query($sql);
while($rows = mysql_fetch_assoc($result))
{
//assign your data from mysql to php variables
//Each iteration is single row in MySql
$whatever = $rows['someColumn'];
}
修改强>
将WHERE 'userid' = 1
更改为实际ID,如:
... WHERE 'userid' = $userid ...
你的意思是什么不起作用?有什么错误吗?你期望实现什么目标?