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 Link to comment https://forums.phpfreaks.com/topic/182474-why-isnt-it-working-using-the-get-fuction/ 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') Link to comment https://forums.phpfreaks.com/topic/182474-why-isnt-it-working-using-the-get-fuction/#findComment-963014 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? Link to comment https://forums.phpfreaks.com/topic/182474-why-isnt-it-working-using-the-get-fuction/#findComment-963015 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. Link to comment https://forums.phpfreaks.com/topic/182474-why-isnt-it-working-using-the-get-fuction/#findComment-963018 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)); Link to comment https://forums.phpfreaks.com/topic/182474-why-isnt-it-working-using-the-get-fuction/#findComment-963024 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)); Link to comment https://forums.phpfreaks.com/topic/182474-why-isnt-it-working-using-the-get-fuction/#findComment-963026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.