+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 15

Thread: Error in Edit plz help !!!!!!

  1. #1
    Newbie Magic_PHP is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    8

    Exclamation Error in Edit plz help !!!!!!

    hi
    i've programming library file system

    there error in Control Panel

    there are catagory table

    this code fetch items from catagory table in DB & show it as table:

    Code:
    <?
    include("../config.php");
    $SQL_Select_catag=mysql_query("select * from catagory");
    echo 
    '<center><a href="add_catagory.php">Add Catagory</a></center><br>';
    echo 
    '<table width="300" border="1" align="center" style="border: 1px dotted #000000" cellspacing="0" cellpadding="0" >';
        while (list(
    $Id,$cat_name)=mysql_fetch_array($SQL_Select_catag))
        {
            
        
    $iid=$Id;
        echo 
    "<tr><td>";
        echo 
    $iid;
        echo 
    "</td><td>";
        echo 
    $cat_name;
        echo 
    "</td><td>";
        echo 
    '<a href= "edit_cat.php?cat_IDno=';
         echo 
    $iid;
        echo 
    '">Edit</a>';
        echo 
    "</td><td>";
        echo 
    '<a href= "delete_cat.php?cat_IDno=';
         echo 
    $iid;
        echo 
    '">Delete</a>';
        echo 
    "</td></tr>";
        }
        echo 
    "</table>";
    echo 
    '<center><a href="add_catagory.php">Add Catagory</a></center>';    
    echo 
    "<center><br>";
    ?>
    if Clicked Edit link in table will go to Edit Page & this is the code :

    Code:
    <?
    include("../config.php");

    $_POST['cat_IDno'];
    if (
    $Cname != null )
    {
        
    $sql_update_catag="update catagory set cat_name='$Cname' where Id='$cat_IDno'";
        
    $qr=mysql_query($sql_update_catag);
        
        if (
    $qr == true)
        {
            echo 
    "Updated Done";
        }
        
        else 
        {
            echo 
    "Not Done";
        }
        
    }
    else 
    {
        
    $SQL_Statment_catag=mysql_query("select *  from catagory where Id=$cat_IDno");
    $SQL_Arr_catag=mysql_fetch_array($SQL_Statment_catag);
    $ccname=$SQL_Arr_catag[1];
    ?>    

    <form action="edit_cat.php" method="POST">
    <center>
    Catagory Name: <input type="text" name="Cname" id="Cname" value="<? echo $ccname?>">
    <br>
    <input type="submit" value="Edit">
    </center></form>

    <?
    }
    ?>
    Now when Press Edit Button showing Message
    " Updated Done "

    and it's not updated !!

    what is the problem ??

    please help me today !!!!!

  2. #2
    Co-Administrator John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John's Avatar
    Join Date
    Jul 2006
    Age
    21
    Posts
    5,885
    Blog Entries
    25
    You don't assign $_POST['cat_IDno']; to a new variable name.

  3. #3
    Newbie Magic_PHP is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    8

    Post

    sorry can you ReType a new code whit out error ??!!

    plz !!!!

  4. #4
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97
    As John said, you need to replace

    Code:
    $_POST['cat_IDno']; 
    With

    Code:
    $cat_IDno $_POST['cat_IDno']; 
    I doubt John will rewrite your code without the error and I know I'm not. But we have told you how to fix the problem.

  5. #5
    Newbie Magic_PHP is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    8
    i've do it but it's not work
    it's print : Update Done !

    but it's not updated !!!

    why ????

  6. #6
    Newbie Magic_PHP is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    8
    this modifyed code :
    Code:

    <?
    $cat_IDno
    =$_GET['cat_IDno'];

    include(
    "../config.php");
    $SQL_Statment_catag=mysql_query("select *  from catagory where Id=$cat_IDno");
    $SQL_Arr1=mysql_fetch_array($SQL_Statment_catag);
    $iiid=$SQL_Arr1[0];
    $ccname=$SQL_Arr1[1];





    if (
    $Cname != null )
    {
        
    $sql_update_catag=mysql_query("update catagory set cat_name='$Cname' where Id=$cat_IDno") or die(mysql_error());
        
        if (
    $sql_update_catag == true)
        {
            echo 
    "Updated Done";
        }
        
        else 
        {
            echo 
    "Not Done";
        }
        
    }
    else 
    {

    ?>    

    <form action="edit_cat.php" method="POST">
    <center>
    <input type="hidden" name="yid" value="<? echo $iiid;?> ">
    Catagory Name: <input type="text" name="Cname" id="Cname" value="<? echo $ccname?>">
    <br>
    <input type="submit" value="Edit">
    </center></form>

    <?
    }
    ?>
    Look for This Error MSG :

    Code:
    You have an error in your SQL syntaxcheck the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 
    Last edited by Magic_PHP; 02-21-2008 at 02:25 PM.

  7. #7
    Newbie Magic_PHP is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    8
    this my email :

    to help me online :

    nader808@hotmail.com

  8. #8
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97
    Where is $Cname defined? I see

    Code:
    $ccname=$SQL_Arr1[1];
    but I never see $Cname assigned a value.

  9. #9
    Newbie Magic_PHP is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    8
    Catagory Name: <input type="text" name="Cname" id="Cname" value="<? echo $ccname; ?>">

  10. #10
    Newbie Magic_PHP is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    8
    This parameter for print orginal value before update in text box !!

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Hex Edit To Change Dialog Button Call....
    By Catacomb187 in forum General Programming
    Replies: 1
    Last Post: 02-25-2008, 09:44 PM
  2. help me solve a file edit problem
    By 111222 in forum PHP Forum
    Replies: 11
    Last Post: 12-12-2007, 05:38 PM
  3. Edit a Microsoft Agent
    By r1card0 in forum General Programming
    Replies: 0
    Last Post: 03-11-2007, 02:15 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts