Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to insert data in database using php
    primarykey
    data
    text
    <p>I have just started to work with php. I write a simple code in php to insert data in a table customer. I am using mssql database. </p> <pre><code>&lt;?php function InsertData() { $link = mssql_connect('db','123','test'); if (!$link || !mssql_select_db('php', $link)) { die('Unable to connect or select database!'); } $sql = " INSERT INTO customer ([Name],[Website])VALUES('$txtName','$txtWebsite')"; $result = mysql_query($sql, $link); if(!$result) { echo mysql_error(); exit; } // close the connection mysql_free_result($result); mysql_close(); echo "Data successfully inserted"; } ?&gt; &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt; &lt;tr&gt; &lt;td colspan="3" height="10" valign="top" width="98%"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="22%"&gt; &amp;nbsp;Name:&lt;/td&gt; &lt;td width="60%"&gt;&lt;INPUT type="text" name="txtName" id="txtName" Width="200px" MaxLength="30" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" height="12" valign="top" width="98%"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="22%"&gt; &amp;nbsp;Company Website:&lt;/td&gt; &lt;td width="60%"&gt;&lt;INPUT type="text" name="txtWebsite" id="txtWebsite" width="200px" MaxLength="200" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td &gt; &lt;/td&gt; &lt;td &gt; &lt;input type="button" value="submit" id="imgBtnSubmit" click="InsertData()"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I have written above code to insert data into the table and I am calling InsertData function on onClick event of submit button but on clicking button data is not getting inserted into the table. Please anyone tell me where is the problem in this code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload