Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

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

  1. #1
    Magic_PHP is offline Newbie
    Join Date
    Feb 2008
    Posts
    8
    Rep Power
    0

    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. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20
    You don't assign $_POST['cat_IDno']; to a new variable name.

  4. #3
    Magic_PHP is offline Newbie
    Join Date
    Feb 2008
    Posts
    8
    Rep Power
    0

    Post

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

    plz !!!!

  5. #4
    Jordan Guest
    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.

  6. #5
    Magic_PHP is offline Newbie
    Join Date
    Feb 2008
    Posts
    8
    Rep Power
    0
    i've do it but it's not work
    it's print : Update Done !

    but it's not updated !!!

    why ????

  7. #6
    Magic_PHP is offline Newbie
    Join Date
    Feb 2008
    Posts
    8
    Rep Power
    0
    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 12:25 PM.

  8. #7
    Magic_PHP is offline Newbie
    Join Date
    Feb 2008
    Posts
    8
    Rep Power
    0
    this my email :

    to help me online :

    nader808@hotmail.com

  9. #8
    Jordan Guest
    Where is $Cname defined? I see

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

  10. #9
    Magic_PHP is offline Newbie
    Join Date
    Feb 2008
    Posts
    8
    Rep Power
    0
    Catagory Name: <input type="text" name="Cname" id="Cname" value="<? echo $ccname; ?>">

  11. #10
    Magic_PHP is offline Newbie
    Join Date
    Feb 2008
    Posts
    8
    Rep Power
    0
    This parameter for print orginal value before update in text box !!

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [Help] hex edit
    By pradevil in forum General Programming
    Replies: 0
    Last Post: 01-28-2010, 12:10 PM
  2. Edit Image
    By nidhikapoor in forum Visual Basic Programming
    Replies: 2
    Last Post: 10-18-2009, 03:13 AM

Tags for this Thread

Bookmarks

Posting Permissions

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