Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
| FAQ | Members List | 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 10th, 2015, 11:51 AM
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.


PHP Code:

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

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

$find_data $mysqli->query("SELECT * FROM rates WHERE pos='$pos'"); 
$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'"); 


PHP Code:

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

    <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">

<body class="body">

    <header class="mainheader">
      <img src="ball.jpg" width="400" height="150" alt="Ron"align="">
     <font color="white" "arial" size= "6"> <b> Greatest Footballing Legends  - You Decide!! </b> </font>
               <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> 
    <div class="mainContent">
        <div class="content">
            <article class="topcontent">
                    <h2> <center> <font color="black" "arial" size= "3"> <b> <i>  Legends Ranking! </i> </b> </font> </center> </h2>
= new mysqli("localhost","root","root""rating") or die ("Couldnt connect to the database!"); 
$find_data $mysqli->query("SELECT * FROM rates"); 
$row mysqli_fetch_assoc($find_data))    
$id $row['id'];
$nameofplayer $row['nameofplayer'];
$pos $row['pos'];
$current_rating $row['rating'];
$hits $row['hits'];
                            <form action='rate.php' method='POST'>
$nameofplayer: <select name='rating'>    
                                <input type='hidden' value='
$nameofplayer' name='nameofplayer'>
                                <input type='submit' value='Rate!'> Current Rating: "
; echo $current_rating; echo 
                <p class="post-info">Greatest Legends of the game</p>                    
            <article class="bottomcontent">
                    <h2><a href="#" title="Second post">Second post</a></h2>
                <p class="post-info">This post is written by Naz</p>                    
                    <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>
    <aside class="top-sidebar">
            <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>
    <aside class="middle-sidebar">
            <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>

    <aside class="bottom-sidebar">
            <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>
    <footer class="mainFooter">
        <p>Copyright &copy; 2013<a href="#" title="1stwebdesigner">1stwebdesigner.com</a></p>

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 11:31 AM
Notice: Undefined variable error on input form tonyb187 Pro PHP 2 May 11th, 2008 06:58 AM
Notice: Undefined index: username in latinquarter PHP Databases 1 April 18th, 2008 11:37 AM
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 04:28 PM.

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