Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 10th, 2015, 12:51 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default "Notice: Undefined variable

I keep getting an error messagee: Undefined variable: pos in /Applications/MAMP/htdocs/project1/rate.php on line 8".
I was getting this error on line 5 but i had included the asset function, i am stuck and do not know how to fix this error. I will post the code below, please help.

Thanks in advance.

Rate.php

PHP Code:

$mysqli 
= new mysqli("localhost","root","root""rating") or die  ("Couldnt connect to the database!"); 

 if (isset(
$_POST['pos']))
 
$post_rating $_POST['rating']; 

 
$find_data $mysqli->query("SELECT * FROM rates WHERE pos='$pos'"); 
 while(
$row $mysqli->fetch_assoc($find_data)) 

   { 
  
$id $row['id']; 
  
$current_rating $row['rating']; 
  
$current_hits $row['hits'];  

   } 

   
$new_hits $current_hits 1
   
$update_hits $mysqli->query("UPDATE rates SET hits = '$new_hits'     WHERE id='$id'"); 

   
$pre_rating $current_rating $post_rating
   
$new_rating $pre_rating $new_hits

   
$update_rating $mysqli->query("UPDATE rates SET rating = '$new_rating' WHERE id='$id'"); 

       
?> 
FGLRANK.PHP

PHP Code:

<!DOCTYPE html> 
<html lang="en">

<head> 
    <title>Football's Greatest Legends Ranking</title>
    <meta charset="utf-8" />
    
    <link rel="stylesheet" href="style1.css" type="text/css" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body class="body">

    <header class="mainheader">
      
      <center>
      <img src="ball.jpg" width="400" height="150" alt="Ron"align="">
      </center>
      <center>
     <font color="white" "arial" size= "6"> <b> Greatest Footballing Legends  - You Decide!! </b> </font>
      </center>
      
          <nav><ul>
               <li> <a href="home.html">Home</a></li>
               <li> <a href="fgl.html">Football Legends</a></li>
               <li><a href="fglrank.php">Football Legends Ranking</a></li>
               <li><a href="contact.html">Contact</a></li> 
           
       </ul></nav>    
       
    </header>
    
    <div class="mainContent">
        <div class="content">
            <article class="topcontent">
                <header>
                    <h2> <center> <font color="black" "arial" size= "3"> <b> <i>  Legends Ranking! </i> </b> </font> </center> </h2>
                </header>
            
                <center>
                <content>
                
                <?php
                
                 $mysqli 
= new mysqli("localhost","root","root""rating") or die ("Couldnt connect to the database!"); 
                  
$find_data $mysqli->query("SELECT * FROM rates"); 
 
 
                while(
$row mysqli_fetch_assoc($find_data))    
                {
                    
$id $row['id'];
                    
$nameofplayer $row['nameofplayer'];
                    
$pos $row['pos'];
                    
$current_rating $row['rating'];
                    
$hits $row['hits'];
                    
                    echo 
"
                            
                            <form action='rate.php' method='POST'>
                                $nameofplayer: <select name='rating'>    
                                            <option>1</option>
                                            <option>2</option>
                                            <option>3</option>
                                            <option>4</option>
                                            <option>5</option>
                                            <option>6</option>
                                            <option>7</option>
                                            <option>8</option>
                                            <option>9</option>
                                            <option>10</option>
                                </select>
                                <input type='hidden' value='$nameofplayer' name='nameofplayer'>
                                <input type='submit' value='Rate!'> Current Rating: "
; echo $current_rating; echo 
                                </form>            
                    "
;
                }
                
                
?>
                
                
                
                
    
                    
                </content>
                </center>
                
                <footer>
                <p class="post-info">Greatest Legends of the game</p>                    
                </footer>
                
            </article>    
            
            <article class="bottomcontent">
                <header>
                    <h2><a href="#" title="Second post">Second post</a></h2>
                </header>
                
                
                <footer>
                <p class="post-info">This post is written by Naz</p>                    
                </footer>
                
                <content>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                     Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
                    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
                    Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p>
            </article>    
            
        </div>
    </div>
    
    <aside class="top-sidebar">
        <article> 
            <h2>Top sidebar</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
        </article>
    </aside>
    
    <aside class="middle-sidebar">
        <article> 
            <h2>Middle sidebar</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
        </article>
    </aside>

    <aside class="bottom-sidebar">
        <article> 
            <h2>Bottom sidebar</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
        </article>
    </aside>
    
    <footer class="mainFooter">
        <p>Copyright &copy; 2013<a href="#" title="1stwebdesigner">1stwebdesigner.com</a></p>
    </footer>
</body>

</html>
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
to recover "undefined variable" error raihanveer BOOK: PHP and MySQL 24-Hour Trainer 0 April 4th, 2012 12:31 PM
Notice: Undefined variable error on input form tonyb187 Pro PHP 2 May 11th, 2008 07:58 AM
Notice: Undefined index: username in latinquarter PHP Databases 1 April 18th, 2008 12:37 PM
Notice: Undefined variable: comments/ Form reset dungey Pro PHP 10 December 1st, 2006 04:00 AM
Notice: Undefined offset: ## Herjan BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 November 27th, 2005 12:29 PM



All times are GMT -4. The time now is 02:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.