![]() Then, the mysqlquery() function executes the INSERT INTO statement, and a new record will be added to the 'Persons. ![]() The 'insert.php' file connects to a database, and retrieves the values from the form with the PHP POST variables. I tried this and run successfully: set variable1 100 set variable2 100 SET variable variable1 + variable2 INSERT INTO etl1 (name) VALUES (variable) Here etl1 is my Table name, replace it with yours. When a user clicks the submit button in the HTML form in the example above, the form data is sent to 'insert.php'. And the best practice to achieve that is to use an ORM or a PHP framework with a database abstraction layer which does this for you. Please check and ensure both variables shouldn't be NULL in this case. Asking for help, clarification, or responding to other answers. Given that the parameter for mysqliquery() is just a string, we can use variables as we would in any other string - if the string is double-quoted, it is. ![]() So in your example you will try to insert '', which in SQL again is an empty string. Thanks for contributing an answer to Stack Overflow Please be sure to answer the question.Provide details and share your research But avoid. I am trying to insert a string variable from a form into mysql but it keeps giving me an error, and within the error it cuts off part of the statement, so I assume its an issue with the fact that there are commas in the string. PHP doesn't print NULL - it is just an empty string.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |