Fails to insert fields in mysql with PHP with a post method

-1

I am learning to program in PHP but when I insert the data with the post method it marks the error "Call to a member function query () on null".

$ key = $ _POST ['key']; $ Description = $ _POST ['des']; $ code = $ _POST ['cb']; $ pc = $ _POST ['pc']; $ Wholesale = $ _POST ['pma']; $ Retail = $ _POST ['pmu']; $ suggested = $ _POST ['suggested'];

$ insert="INSERT INTO product (key, description, code, pc, wholesale, retail, suggested) values ('$ password', '$ description', '$ code', '$ pc', '$ wholesale ',' $ Retail ',' $ suggested ') ";

$ execute = $ link-> query ($ insert); if (! execute) {     printf ("Error", $ link -> error); } else {     echo "added correct"; }

mysqli_close ($ link); echo "Correct data";

Someone to help me since I can not find an error in my code?

    
asked by jaime gallardo 27.05.2018 в 06:31
source

1 answer

0

This error message means that in the instruction $ejecutar = $enlace->query($insert); $ link is null, so you should check the code $enlace = conectar(); and see that the connect function is returning a valid object

    
answered by 27.05.2018 в 15:34