dropfaith Posted October 24, 2008 Share Posted October 24, 2008 okay so this connects elsewhere on my page and is pulling the data just fine the error im getting is Notice: Undefined variable: mode in /home/www/lawrenceguide.org/www/recipes/profile.php on line 184 also its not updating if a person votes but i assume the Notice has something to do with that <?php //Puts SQL Data into an array $data = mysql_query("SELECT * FROM RecipeVote WHERE Name = '$Name'") or die(mysql_error()); //Now we loop through all the data while($ratings = mysql_fetch_array( $data )) { //This outputs the sites name Echo "Name: " .$ratings['Name']."<br>"; //This calculates the sites ranking and then outputs it - rounded to 1 decimal $current = $ratings['Total'] / $ratings['Votes']; Echo "Current Rating: " . round($current, 1) . "<br>"; //This creates 5 links to vote a 1, 2, 3, 4, or 5 rating for each particular item Echo "Rank Me: "; Echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=1&Id=".$ratings['Id'].">Vote 1</a> | "; Echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=2&Id=".$ratings['Id'].">Vote 2</a> | "; Echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=3&Id=".$ratings['Id'].">Vote 3</a> | "; Echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=4&Id=".$ratings['Id'].">Vote 4</a> | "; Echo "<a href=".$_SERVER['PHP_SELF']."?mode=vote&voted=5&Id=".$ratings['Id'].">Vote 5</a><p>"; } //We only run this code if the user has just clicked a voting link if ( $mode=="vote") { //If the user has already voted on the particular thing, we do not allow them to vote again $cookie = "Mysite$Id"; if(isset($_COOKIE[$cookie])) { Echo "Sorry You have already ranked that site <p>"; } //Otherwise, we set a cooking telling us they have now voted else { $month = 2592000 + time(); setcookie(Mysite.$Id, Voted, $month); //Then we update the voting information by adding 1 to the total votes and adding their vote (1,2,3,etc) to the total rating mysql_query ("UPDATE RecipeVote SET Total = Total+$voted, Votes = Votes+1 WHERE Name = $Name"); Echo "Your vote has been cast <p>"; } } mysql_close(); ?> im following this http://php.about.com/od/finishedphp1/ss/rating_script.htm Link to comment https://forums.phpfreaks.com/topic/129921-solved-rating-script/ Share on other sites More sharing options...
dropfaith Posted October 24, 2008 Author Share Posted October 24, 2008 http://lawrenceguide.org/recipes/profile.php?Name=Allisons%20Supreme%20Chocolate%20Chip%20Cookies is a test site and i think the issue is mode isnt getting set into the link wonders Link to comment https://forums.phpfreaks.com/topic/129921-solved-rating-script/#findComment-673521 Share on other sites More sharing options...
GKWelding Posted October 24, 2008 Share Posted October 24, 2008 Your code provided above only has 46 lines in it. Can you provide the code for the script that's failing? Link to comment https://forums.phpfreaks.com/topic/129921-solved-rating-script/#findComment-673525 Share on other sites More sharing options...
dropfaith Posted October 24, 2008 Author Share Posted October 24, 2008 thats it the lines before it are a completly different peice i just added the opening for the php so it would color the script properly line 160 is if ( $mode=="vote") // line 160 { //If the user has already voted on the particular thing, we do not allow them to vote again $cookie = "Mysite$Id"; if(isset($_COOKIE[$cookie])) { Echo "Sorry You have already ranked that site <p>"; } //Otherwise, we set a cooking telling us they have now voted else { $month = 2592000 + time(); setcookie(Mysite.$Id, Voted, $month); //Then we update the voting information by adding 1 to the total votes and adding their vote (1,2,3,etc) to the total rating mysql_query ("UPDATE RecipeVote SET Total = Total+$voted, Votes = Votes+1 WHERE Name = $Name"); Echo "Your vote has been cast <p>"; } } mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/129921-solved-rating-script/#findComment-673527 Share on other sites More sharing options...
GKWelding Posted October 24, 2008 Share Posted October 24, 2008 ok, just had a look at the code again. you have the following line: if ($mode=="vote") on line 25. However, nowhere in the script do you have... $mode=$_GET['MODE']; or the POST equivalent which is where this notification is coming from... Link to comment https://forums.phpfreaks.com/topic/129921-solved-rating-script/#findComment-673529 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.