Click here to Skip to main content
14,880,313 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<?php
require('top.php');
if(isset($_POST['submit']))
{
    $catogry=mysqli_real_escape_string($conn,$_POST['Catogry']);
  
    $add_catogry="insert into categories (categories, status) VALUES ($catogry,'1')";
    mysqli_query($conn,$add_catogry);
     
    header('location:catogry.php');     
 }
?>


What I have tried:

<?php
require('top.php');


if (isset($_GET['type']) && $_GET['type']!='')
{
    $type=mysqli_real_escape_string($conn,$_GET['type']) ;
    if($type=='status')
    {
        
        $operation=mysqli_real_escape_string($conn,$_GET['operation']);
        if($operation=='active')
        {
           
            $status='1';
        }
        else
        {
          
            $status='0';
        }
        $id=mysqli_real_escape_string($conn,$_GET['id']);
        $update_status="update categories set status='$status' where id=$id";
        mysqli_query($conn,$update_status);
    }   

i am attaching ths because its same table and working fine
Posted
Updated 11-Apr-21 4:01am
Comments
Richard Deeming 12-Apr-21 6:35am
   
REPOST
You have already posted this question:
Same code for another work fine here also when I print the value of $catogry it will print the value which I have entered. But not inserting in database.[^]

If you want to update your question to add missing information, click the green "Improve question" link and update your question. Do not post the update as a "new" question.

1 solution

Start by looking at what PHP mysqli query() Function[^] returns. If it's ture, then it worked. If it's false, then look at the error: PHP MySQL Insert Data[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900