Hongmu Notes
Home Summary of pitfalls SQLSTATE[HY000]: General error: trying to execute an empty query
Summary of pitfalls

SQLSTATE[HY000]: General error: trying to execute an empty query

SQLSTATE[HY000]: General error: trying to execute an empty query

This error is typically caused by using an empty query string or statement when executing a PDO query or prepared statement. This can occur in any of the following scenarios within PHP code:

  1. The query string or statement is empty.

Please ensure that your query string or SQL statement contains a valid SQL query. If the string or statement is empty, this error will be thrown. You can use `var_dump()` or an `echo` statement to print the query string or statement before executing the query, to verify that they are correctly set.

  1. Query parameter is empty

This error can also occur when using a PDO statement with bound parameters but without providing any parameters. Please ensure that the bound parameters are assigned values before executing the statement.

Here is an example of a PDO query that uses bound parameters:

$stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username");
$username = "JohnDoe";
$stmt->bindParam(":username", $username);
$stmt->execute();

Please note that the $username variable contains the value of the bound parameter, even if it is merely a single string value.

If you still encounter this error, it is recommended that you check whether your SQL query and parameters are correctly configured, as well as whether there are any other syntax errors.

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Browser caching increases the speed of secondary visits to your website

Browser caching increases the speed of secondary visits to your website Summary of pitfalls

Use browser caching of official words: If users will visit your website multiple times, browser caching of static resources can save users time. Cache headers should be applied to all cacheable static resources, not just to a small subset of static resources (for example, images). Cacheable resources include JS and CSS files, image files, and other binary object files (media files, PDF files, etc.). Normally, HTML doesn’t…
👁 202

Recommended reading

Responsive outdoor wedding photography website template – 0956

Responsive outdoor wedding photography website template – 0956 Practical Collection Yiyou template

An EyouCMS responsive website template designed specifically for the outdoor wedding photography industry. Its romantic and elegant design is perfect for showcasing outdoor wedding portfolios, photography services, travel destinations, and client testimonials – helping wedding photography studios attract prospective couples online. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 56
How does ae export mp4 format? Plugin (AfterCodecs v1.11.0)

How does ae export mp4 format? Plugin (AfterCodecs v1.11.0) Hobbies video clip

My AE version is 2021, and I can successfully export mp4 videos with this plug-in. Before using the plug-in, I exported a video and it was 48G in 4 minutes. Now after using the plug-in, it is 144M in 4 minutes. It is still high-definition and very easy to use! Download address: 🔒 Hidden content: View https://pan.baidu.com/s/1JF5mqkJ36n2i9LEFsxC_Cg?pwd=sujp…
👁 195
Computer operating system software download website template 0147

Computer operating system software download website template 0147 Practical Collection Yiyou template

This set of eyoucms templates is suitable for computer operating systems and software download websites. The design style is simple and practical, and can display operating systems, software applications, download resources and technical tutorials. Helps software download sites attract user traffic online. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Summary of common problems in Eyou CMS installation Eyou CMS (Eyou…
👁 53
(PC+WAP) Black Custom Door and Window Website – pbootCMS Template; Download Source Code for Hardware and Building Materials Industry Websites – 0535

(PC+WAP) Black Custom Door and Window Website – pbootCMS Template; Download Source Code for Hardware and Building Materials Industry Websites – 0535 Practical Collection pbootcms Template

A black custom door and window website template designed for the hardware and building materials industry, compatible with both PC and mobile devices. Its modern and sophisticated design effectively showcases your door and window product lines as well as your strong presence in the building materials trade. This template helps door and window brands or building materials companies establish an online brand presence and enhance their marketing effectiveness. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: ww...
👁 41
Responsive Home Cleaning Service Company Website Template 0957

Responsive Home Cleaning Service Company Website Template 0957 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for cleaning and household services companies. Its fresh and professional design effectively showcases cleaning services, household service offerings, service personnel, and customer reviews. It helps household service providers build a strong online brand image and attract domestic clients. Template Demo | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 61
Environmental Fiberglass Precision Manufacturing Equipment Website Template 0148

Environmental Fiberglass Precision Manufacturing Equipment Website Template 0148 Practical Collection Yiyou template

An eYouCMS website template designed for companies specializing in eco-friendly fiberglass and precision engineering equipment. Its modern, eco-conscious design is ideal for showcasing fiberglass products, precision machinery, and technological applications. This template helps composite materials enterprises present their products online and attract industrial customers. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for eYouCMS | eYouCMS...
👁 55