phpSensei Posted July 15, 2007 Share Posted July 15, 2007 Before Anything, I think I should Explain how my Forum works. Everytime a user adds a topic, the Id of the Forum which the topic is being added to, is inserted in a table row called id_forum, in the messages table. (Same table for Adding Topics). Once it has the Forum's id, you can display these topics like this <?php //We Get the ID of the Topic passed from the URL// $id=$_GET['id']; //Here We Select Everything from Messages, then INNER JOIN with the Forums table// $sql="SELECT * FROM messages INNER JOIN forums ON id_message=id_forum WHERE id_forum='$id' "; $result=mysql_query($sql); $row=mysql_fetch_array($result); ?> I am trying to Collect a user's ip when he views a thread in my forum. Now to skip some of the code, I will do a IF statement for: <?php //Here we Collect the IP Adress of this user// $ip=$_SERVER['REMOTE_ADDR']; //Here we check if in OUr SELECT STATEMENT, We can Find a unique ip// If( $ip == $row['unique_ip']){ //If The ip already Exists, We do Not ADD 1 to the Unique Views// die(); } //Else If the ip is unique, We add it to our list of Ip's, so Later this ip will not count as unique// elseif ($ip != $row['uniqure_ip']{ $id=$_GET['id_message']; mysql_query ("INSERT INTO message_msg (uip) WHERE id_msg='$id' VALUES ('$ip')") mysql_query("UPDATE messages SET uniqueviews = uniqueviews + 1 WHERE message_id='$id2'"); } ?> The ip doesnt go to the proper message id. Quote Link to comment Share on other sites More sharing options...
AbydosGater Posted July 15, 2007 Share Posted July 15, 2007 What do you mean its not going into the proper message id? As in its going into the database.. but for a completly different message, not the one they are viewing? Quote Link to comment Share on other sites More sharing options...
Oldiesmann Posted July 15, 2007 Share Posted July 15, 2007 Where is $id2 being set? Also, the first query in the second block of code is invalid - you can't use WHERE in an INSERT query (you're inserting a new row, so there's not going to be anything in that column yet). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.