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:
if Clicked Edit link in table will go to Edit Page & this is the code :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>";
?>
Now when Press Edit Button showing MessageCode:<?
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>
<?
}
?>
" Updated Done "
and it's not updated !!
what is the problem ??
please help me today !!!!!
You don't assign $_POST['cat_IDno']; to a new variable name.
sorry can you ReType a new code whit out error ??!!
plz !!!!
As John said, you need to replace
WithCode:$_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.Code:$cat_IDno = $_POST['cat_IDno'];
i've do it but it's not work
it's print : Update Done !
but it's not updated !!!
why ????
this modifyed code :
Look for This Error MSG :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>
<?
}
?>
Code:You have an error in your SQL syntax; check 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.
this my email :
to help me online :
nader808@hotmail.com
Where is $Cname defined? I see
but I never see $Cname assigned a value.Code:$ccname=$SQL_Arr1[1];
Catagory Name: <input type="text" name="Cname" id="Cname" value="<? echo $ccname; ?>">
This parameter for print orginal value before update in text box !!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks