Tell the syntax to insert a value into the table.
simple table
you need to insert the value of the variable

$sql = " INSERT INTO Pcontent ([Ptittle])VALUES('$Ptittle')" ; echo "<br>"; 

but nothing is entered in the table

here is the listing:

 $sql = " INSERT INTO dbo.Pcontent ([Ptittle])VALUES('$Ptittle')" ; echo "<br>"; $result = sql_query($sql)or die('Error querying MSSQL database'); 

when sql query error appears:

 PHP Fatal error: Uncaught Error: Call to undefined function sql_query() in C:\inetpub\wwwroot\technet\admin\scripts\gen_page.php:51 Stack trace: #0 {main} thrown in C:\inetpub\wwwroot\technet\admin\scripts\gen_page.php on line 51 
  • why do you echo "<br>"; ? - Alex

2 answers 2

 $query = "INSERT INTO TABLENAME (id,name) VALUES ('$id','$name')"; $result = mssql_query($query,$dbc) 

$query - query $dbc - connection to the database

  • crashes with this output PHP Fatal error: Uncaught Error: Call to undefined function mssql_query () in C: \ inetpub \ wwwroot \ technet \ admin \ scripts \ gen_page.php: 51 Stack trace: # 0 {main} thrown in C: \ inetpub \ wwwroot \ technet \ admin \ scripts \ gen_page.php on line 51 - qaz qaz
  • @qazqaz, stackoverflow.com/a/17103976/4827341 - aleksandr barakin

figured out, it was necessary to use instead of mssql ssqlsrv

  • This is not an answer, it is rather a comment. Complete and expand your answer. - AK