Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Akinwaps's avatar

i want to add Json output data to my SQL database Users option but not adding

i want to add the json output data to the data of customer account creation, i use this code but it only account creation apply to my SQL database but the Json output from my endpoint url does not added to the database

please any solution?

i use this code below

     //execute the started curl session
     $output = curl_exec($ch);
     //var_dumb($output);
     $err = curl_error($ch);
     if ($err){
          exist("Error Encountered ".$err);
     }

     $jsonoutput = json_decode($output);
     //close the session and delete the variable made by curl_init
     curl_close($ch);
     
     if($jsonoutput->status = 1){
        $customer_code = $jsonoutput->data->customer_code;
        
        
        $sql = "insert into #__n(customer_code)values('$customer_code')";
    if($data->var_dump($sql)){
    
        echo "Account successfully Created". $customer_code;
        }else{
           echo $data->dberror();
     }
0 likes
9 replies
sr57's avatar

st like this?

$sql = "insert into #__n(customer_code,my_json_field) values('$customer_code','$output')";
Akinwaps's avatar

I mean like the output data on my endpoint call api which returns "customer_code" as a form of successful creation on the called api so I want to input this return data automatically into my SQL database value on successful creation of a customer account.

sr57's avatar

@akinwaps

Did you try my previous answer?

and/or give sample data (reception from api and how you want it in the db)

sr57's avatar

so i'm only intrested in adding " "customer_code": "CUS_yaj72sb3383rucw" to my users value.

Not your original question ! :-)

You just have to adapt a little my fist answer ...

Akinwaps's avatar

@sr57 what I need is a code to a the jsonoutput data into my SQL users database value that's all and the above code is not working out.

sr57's avatar

@akinwaps

Sorry but it's not clear.

the jsonoutput data ? which data and type exactly?

my SQL users database value ? which field and type exactly?

the above code is not working out.

it works for your original question.

Akinwaps's avatar

@sr57 can you drop your telegram or whatsapp link maybe I should add you up so we can have a better conversation.

sr57's avatar

@akinwaps

Maybe but not for sure, written forces us to be clear; it is always possible to rephrase what you don't understand ... moreover it can be useful for others.

Akinwaps's avatar

@sr57 @sr57 maybe because I have many database that's why the code is not working out.

Let assume I have databases: Nord_vee Nord_mee Nord_cee And I want to input the data to Nord_mee on the table "users" with value "customer_code" so how will the code looks like

Please or to participate in this conversation.