3raser Posted November 22, 2009 Share Posted November 22, 2009 <?php mysql_connect("", "", "") or die("Error connecting to the MySQL database!"); mysql_select_db("") or die("Error connecting to the selected database!"); $ip = $_SERVER[REMOTE_ADDR]; $action = $_GET['a']; //prosses of getting the numbers for users $construct = "SELECT * FROM agreedusers WHERE ip='$ip'"; $run = mysql_query($construct); $foundnum = (mysql_num_rows($run)); if ($foundnum ==1) die("You have not yet agreed to the TOS! TOS content goes here. <a href='?a=yes'>I agree</a>- If you don't agree, leave this page now."); if ($action =="yes") { echo "You've agreed to the TOS.<br><a href='index.php'>Back</a>"; mysql_query("INSERT INTO agreedusers ('$ip')") or die(mysql_error()); } else { echo "You've agreed to the TOS."; } ?> http://sawthememusic.comli.com/ It says you've agreed when you really haven't, and it says I have an error in my SQL syntax at http://sawthememusic.comli.com/?a=yes Quote Link to comment Share on other sites More sharing options...
emopoops Posted November 22, 2009 Share Posted November 22, 2009 lol insert into what? insert into users (column) values('$ip') Quote Link to comment Share on other sites More sharing options...
emopoops Posted November 22, 2009 Share Posted November 22, 2009 and also if their ip is int he agreed user than it would mean they have agreed? Quote Link to comment Share on other sites More sharing options...
3raser Posted November 22, 2009 Author Share Posted November 22, 2009 Alright, I updated my code and fixed a few things you mentioned. <?php $ip = $_SERVER[REMOTE_ADDR]; $action = $_GET['a']; //prosses of getting the numbers for users $construct = "SELECT * FROM agreedusers WHERE ip='$ip'"; $run = mysql_query($construct); $foundnum = (mysql_num_rows($run)); if ($foundnum ==0) die("You have not yet agreed to the TOS! TOS content goes here. <a href='index.php?a=yes'>I agree</a>- If you don't agree, leave this page now."); if ($action =="yes") { echo "You've agreed to the TOS.<br><a href='index.php'>Back</a>"; mysql_query("INSERT INTO agreedusers VALUES ('$ip')") or die(mysql_error()); } else { echo "You've agreed to the TOS."; } ?> Now, when I click the agree link it doesn't do anything. Quote Link to comment Share on other sites More sharing options...
Jarod Posted November 22, 2009 Share Posted November 22, 2009 try if ( isset($action) =="yes") { see if that works =/ also it's probably because you have $ip = $ip = $_SERVER['REMOTE_ADDR']; instead of $ip = $_SERVER[REMOTE_ADDR]; (punctuations) try this too: $foundnum = mysql_num_rows($run); instead of $foundnum = (mysql_num_rows($run)); Quote Link to comment Share on other sites More sharing options...
Jarod Posted November 22, 2009 Share Posted November 22, 2009 try if ( isset($action) =="yes") { see if that works =/ also it's probably because you have $ip = $_SERVER[REMOTE_ADDR]; instead of $ip = $_SERVER['REMOTE_ADDR']; (punctuations) try this too: $foundnum = mysql_num_rows($run); instead of $foundnum = (mysql_num_rows($run)); 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.