S
Saka
Guest
i have table named page now my task is to insert, update,delete from page. every thing is okay but i need to write the following function more securely or strongly . i knew about mysql_error(), mysql_affected_rows, mysql_affected_rows.
please modify following functions so it will give best performance
inserting row
function AddPage($parent_id)
{
$query="INSERT INTO page (parent_id) VALUES ('$parent_id')";
if(mysql_query($query))
return 1;
else
return 0;
}
deleting row
function RemovePage($page_id)
{
$query="DELETE FROM page WHERE page_id='$page_id'";
if(mysql_query($query))
return 1;
else
return 0;
}
updating row
function ChangeParent($page_id,$parent_id)
{
$query= "UPDATE page SET parent_id='$parent_id' WHERE page_id='$page_id'";
if(mysql_query($query))
return 1;
else
return 0;
}
please modify following functions so it will give best performance
inserting row
function AddPage($parent_id)
{
$query="INSERT INTO page (parent_id) VALUES ('$parent_id')";
if(mysql_query($query))
return 1;
else
return 0;
}
deleting row
function RemovePage($page_id)
{
$query="DELETE FROM page WHERE page_id='$page_id'";
if(mysql_query($query))
return 1;
else
return 0;
}
updating row
function ChangeParent($page_id,$parent_id)
{
$query= "UPDATE page SET parent_id='$parent_id' WHERE page_id='$page_id'";
if(mysql_query($query))
return 1;
else
return 0;
}