Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
| Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 31st, 2007, 08:56 AM
Registered User
 
Join Date: Oct 2007
Location: , , Philippines.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to p3allen2000
Default undefined index and variable

Hey guys...am having problems with updating with php5. Now am having undefined index and varibles on most of the pages of the website that i am working on. How can i do away with them? this is my code:



<?php

        require_once("connection.php");



        $recno=$_POST['recno'];




         echo "recno=$recno";


        $cdest="";
        $id="";
    for($saverec=1; $saverec<$recno; $saverec++)
    {


        $ccont="reccont".$saverec;
        $ccont = $_POST["$ccont"];

        $ccode="reccode".$saverec;
        $ccode=$_POST["$ccode"];

    $ccat="reccat".$saverec;
        $ccat=$_POST["$ccat"];

    $cprice="recprice".$saverec;
        $cprice=$_POST["$cprice"];

    $cRFC="recRFC".$saverec;
        $cRFC=$_POST["$cRFC"];

    $cdim="recdim".$saverec;
        $cdim=$_POST["$cdim"];

    $cclass="recclass".$saverec;
        $cclass=$_POST["$cclass"];

    $ccman="reccman".$saverec;
        $ccman=$_POST["$ccman"];

        $recfile="recfile".$saverec;
        $recfile=$_POST["$recfile"];

        $chidid="rechidid".$saverec;
        $chidid=$_POST["$chidid"];

        $crec="recfile".$saverec;
        $crec=$_POST["$crec"];



echo "<br>id=$chidid, reccont=$ccont, ccode=$ccode, category=$ccat, RFC=$cRFC, dimension=$cdim, class=$cclass, cman=$ccman, price=$cprice<br><br>";


        $dest = basename($_FILES["$crec"]['name']);



$qupdate = "UPDATE tblfurniture_back
            SET contno='$ccont', prodcode='$ccode', category='$ccat', RFC='$cRFC',dimension='$cdim', class='$cclass', cman='$ccman',price='$cprice', dest='$cdest' where id='$id'";



       if(mysql_query($qupdate))
        {
         echo "<br><center>Record Update Successful!</center><br>";

        }

        else
        die (" Data Update Failed!".mysql_error());


        move_uploaded_file($_FILES["$crec"]['tmp_name'], $dest);



}

    mysql_close();

echo "<center><a href=apanelnext_back.php>back</a></center>";


?>


  #2 (permalink)  
Old November 1st, 2007, 04:49 PM
Authorized User
 
Join Date: Sep 2007
Location: , , .
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

Which variable is giving you that error ($recno)?

You need to make sure that there is a value in the $_POST array like so:

Code:
if(isset($_POST["recno"])){ $recno = $_POST["recno"]; } else { $recno = ""; }
And a shortcut of writing the above would be like
Code:
$recno = (isset($_POST["recno"])) ? $_POST["recno"] : "";
And there is another option...for the server configuration(php.ini) you could lower the error reporting

http://mynameissteve.com


Similar Threads
Thread Thread Starter Forum Replies Last Post
Notice: Undefined index: username in latinquarter PHP Databases 1 April 18th, 2008 11:37 AM
Undefined index junemo Pro PHP 8 October 31st, 2007 05:45 PM
upload files - Undefined index: DOCUMENT_ROOT lanita PHP How-To 4 July 14th, 2006 09:07 AM
Undefined Index Error rit01 Beginning PHP 0 March 1st, 2006 10:03 AM
Undefined index ashinotani Beginning PHP 2 August 17th, 2004 03:31 PM





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