Home  >  Article  >  Backend Development  >  How to Resolve an Error in Line 13 Using w3schools Tutorial?

How to Resolve an Error in Line 13 Using w3schools Tutorial?

Susan Sarandon
Susan SarandonOriginal
2024-10-21 07:49:02629browse

How to Resolve an Error in Line 13 Using w3schools Tutorial?

Error Encountered while Utilizing w3schools Tutorial

A user has encountered an error when attempting to implement code from the w3schools tutorial. The specific error occurs in line 13, which is:

<code class="php">mysqli_query('INSERT INTO web_formitem (ID, formID, caption, key, sortorder, type, enabled, mandatory, data) VALUES (105, 7, Tip izdelka (6), producttype_6, 42, 5, 1, 0, 0)');</code>

Inaccurate Information from w3schools

The user has consulted w3schools for assistance but has not found it to be particularly useful. According to the documentation, it is flagged for containing numerous errors.

Correcting the Error

The error stems from a misunderstanding of the first parameter required by the mysqli_query function. It expects a connection string instead of a SQL query. The corrected code should be:

<code class="php">$link = mysqli_connect("localhost", "root", "", "web_table");

mysqli_query($link, "INSERT INTO web_formitem (`ID`, `formID`, `caption`, `key`, `sortorder`, `type`, `enabled`, `mandatory`, `data`)
VALUES (105, 7, 'Tip izdelka (6)', 'producttype_6', 42, 5, 1, 0, 0)");</code>

Note: Backticks (`) should be added for column names in the INSERT query, as some of the names are reserved words.

The above is the detailed content of How to Resolve an Error in Line 13 Using w3schools Tutorial?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn