Search code examples
phphtmlmysqlvarchar

VARCHAR does not allow any letters (mySQL)


I'm creating a mysql database table and want to insert some values to my table from a page by using PHP. I've succeeded in everything however, I can only insert integer values to my table. I've used VARCHAR for the input type for the fields. I've also tried TEXT input type but that did not work as well. What can be the problem?

One of my fields' code is:

<p>
<label>Event Name: 
<input name = "ename" type = "text" size = "30" 
maxlength = "300" /> 

My insert code is:

$sql = "INSERT INTO sca (ename, eplace, society, edate, ehour) VALUES ($_POST[ename], $_POST[eplace], $_POST[society], $_POST[edate], $_POST[ehour])";

Thank you.


Solution

  • You should use quotes in your insert statement like:

    VALUES ('{$_POST['ename']}', '{$_POST['eplace']}') // and so on