Jump to content

Error in Edit plz help !!!!!!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
14 replies to this topic

#1
Magic_PHP

Magic_PHP

    Newbie

  • Members
  • Pip
  • 8 posts
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:


<?

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 :


<?

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
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
You don't assign $_POST['cat_IDno']; to a new variable name.

#3
Magic_PHP

Magic_PHP

    Newbie

  • Members
  • Pip
  • 8 posts
sorry can you ReType a new code whit out error ??!!

plz !!!!

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
As John said, you need to replace

$_POST['cat_IDno'];

With

$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
Magic_PHP

Magic_PHP

    Newbie

  • Members
  • Pip
  • 8 posts
i've do it but it's not work
it's print : Update Done !

but it's not updated !!!

why ????

#6
Magic_PHP

Magic_PHP

    Newbie

  • Members
  • Pip
  • 8 posts
this modifyed 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 :


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



#7
Magic_PHP

Magic_PHP

    Newbie

  • Members
  • Pip
  • 8 posts
this my email :

to help me online :

nader808@hotmail.com

#8
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Where is $Cname defined? I see

[COLOR=#000000][COLOR=#0000BB]$ccname[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]$SQL_Arr1[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]];[/COLOR][/COLOR]

but I never see $Cname assigned a value.

#9
Magic_PHP

Magic_PHP

    Newbie

  • Members
  • Pip
  • 8 posts
Catagory Name: <input type="text" name="Cname" id="Cname" value="<? echo $ccname; ?>">

#10
Magic_PHP

Magic_PHP

    Newbie

  • Members
  • Pip
  • 8 posts
This parameter for print orginal value before update in text box !!

#11
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I see. Add

$Cname = $_POST['Cname'];

Under the $GET_ function.

#12
Magic_PHP

Magic_PHP

    Newbie

  • Members
  • Pip
  • 8 posts
i not under stand you !!