mysqli_stmt_bind_param不能处理时间类型吗?
报错的这条语句
mysqli_stmt_bind_param($stmt, 'idii', $c, $a, $t, $w);
完整代码
<?phprequire ('inc/config.php');$page_title = '住宅数据添加-feige数据中心';include ('inc/header.php');require (MYSQL);if ($_SERVER['REQUEST_METHOD'] == 'POST') { $trimmed = array_map('trim', $_POST); $errors = array(); if(empty($trimmed['wdate'])) { $errors[] = '日期不能为空'; } else { $w = mysqli_real_escape_string ($conn, $trimmed['wdate']); } if ( isset($trimmed['city']) && filter_var($trimmed['city'], FILTER_VALIDATE_INT, array('city' => 1)) ) { $c = mysqli_real_escape_string ($conn, $trimmed['city']);; } else { $errors[] = '请选择区域'; } if (is_numeric($trimmed['taoshu']) && ($trimmed['taoshu'] > 0)) { $t = mysqli_real_escape_string ($conn, (int) $trimmed['taoshu']); } else { $errors[] = '请输入一个正确的套数'; } if (is_numeric($trimmed['area']) && ($trimmed['area'] > 0)) { $a = mysqli_real_escape_string ($conn, (float) $trimmed['area']); } else { $errors[] = '请输入一个正确的面积'; } if (empty($errors)) { $q = 'INSERT INTO f_chengjiao (city_id, area, taoshu, fang_time, os_time) VALUES (?, ?, ?, ?, ?, NOW())'; $stmt = mysqli_prepare($conn, $q); mysqli_stmt_bind_param($stmt, 'idii', $c, $a, $t, $w); mysqli_stmt_execute($stmt); if (mysqli_stmt_affected_rows($stmt) == 1) { echo '<p>这条数据已经被添加</p>'; $_POST = array(); } else { echo '<p style="font-weight: bold; color: #C00">程序发生错误,请重新添加</p>'; } mysqli_stmt_close($stmt); } } if ( !empty($errors) && is_array($errors) ) { echo '<p style="font-weight: bold; color: #C00">发生下列错误:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo '请在试一遍</p>';}?><div class="portlet wrap mT50"> <div class="portlet-title">住宅数据添加</div> <div class="portlet-body"> <form action="zhuzhai_add.php" method="post"> <div class="control-group"> <label class="control-label">时间</label> <div class="controls"> <input type="text" name="wdate" class="add-in" onClick="WdatePicker()" value="" />时间格式例如:2014-12-12 </div> </div> <div class="control-group"> <label class="control-label">区域</label> <div class="controls"> <select name="city" class="select-city"> <?php $q = "SELECT city_id, city_name FROM f_city ORDER BY city_id ASC"; $r = mysqli_query ($conn, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($conn)); if (@mysqli_num_rows($r) > 0) { while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) { echo "<option value=\"$row[0]\""; if (isset($trimmed['city']) && ($trimmed['city'] == $row[0]) ) echo ' selected="selected"'; echo ">$row[1]</option>\n"; } mysqli_free_result ($r); } else { echo '<option>暂无区域,请添加一个新地区</option>'; } mysqli_close($conn); ?> </select> </div> </div> <div class="control-group"> <label class="control-label">套数</label> <div class="controls"> <input type="text" name="taoshu" class="add-in" value="" />套 </div> </div> <div class="control-group"> <label class="control-label">面积</label> <div class="controls"> <input type="text" name="area" class="add-in" value="" />平方 </div> </div> <div class="form-actions"> <button class="btn" name="submit" type="submit">提交</button> </div> </form> </div></div><?phpinclude ('inc/footer.php');?>
报错提示
出错文件是 'D:\wamp\www\zhuzhai_add.php' 出错行号是 36: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean givenDate/Time: 9-11-2014 03:52:53Array( [_GET] => Array ( ) [_POST] => Array ( [wdate] => 2014-09-11 [city] => 1 [taoshu] => 50 [area] => 10000 [submit] => ) [_COOKIE] => Array ( ) [_FILES] => Array ( ) [_ENV] => Array ( ) [_REQUEST] => Array ( [wdate] => 2014-09-11 [city] => 1 [taoshu] => 50 [area] => 10000 [submit] => )
回复讨论(解决方案)
你的$conn 在哪初始化的? 且inser 语句的字段与值个数没匹配上吧。
mysqli_stmt_bind_param($stmt, 'idi s', $c, $a, $t, $w);
你的$conn 在哪初始化的? 且inser 语句的字段与值个数没匹配上吧。
$conn是数据库连接
insert的确多了一个?,但是还是会报错
mysqli_stmt_bind_param($stmt, 'idi s', $c, $a, $t, $w);
修改成s也报错
你的$conn 在哪初始化的? 且inser 语句的字段与值个数没匹配上吧。
<?php//数据库连接信息DEFINE ('DB_HOST', 'localhost'); // 服务器地址 DEFINE ('DB_USER', 'root'); // 数据库用户名DEFINE ('DB_PASSWORD', ''); // 数据库密码DEFINE ('DB_NAME', 'fang01'); // 数据库名$conn = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // 连接MYSQL数据库,选择指定的数据库if (!$conn) { trigger_error ('Could not connect to MySQL: ' . mysqli_connect_error() );} else { mysqli_set_charset($conn, 'utf8'); // 设置字符集}?>
贴出修改后的sql串和错误信息

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



On the Douyin platform, many users are eager to obtain level certification, and the level 10 light sign shows the user's influence and recognition on Douyin. This article will delve into the price of Douyin’s level 10 light boards and the time it takes to reach this level to help users better understand the process. 1. How much does a level 10 Douyin light sign cost? The price of Douyin's 10-level light signs will vary depending on market fluctuations and supply and demand. The general price ranges from a few thousand yuan to ten thousand yuan. This price mainly includes the cost of the light sign itself and possible service fees. Users can purchase level 10 light signs through Douyin’s official channels or third-party service agencies, but they should pay attention to legal channels when purchasing to avoid false or fraudulent transactions. 2. How many days does it take to create a level 10 fan sign? Reach level 10 light sign

Players can experience the main plot of the game and collect game achievements when playing in Elden's Circle. Many players don't know how long it takes to clear Elden's Circle. The player's clearance process is 30 hours. How long does it take to clear the Elden Ring? Answer: 30 hours. 1. Although this 30-hour clearance time does not refer to a master-like speed pass, it also omits a lot of processes. 2. If you want to get a better game experience or experience the complete plot, then you will definitely need to spend more time on the duration. 3. If players collect them all, it will take about 100-120 hours. 4. If you only take the main line to brush BOSS, it will take about 50-60 hours. 5. If you want to experience it all: 150 hours of base time.

Xiaohongshu, a platform full of life and knowledge sharing, allows more and more creators to express their opinions freely. In order to get more attention and likes on Xiaohongshu, in addition to the quality of content, the time of publishing works is also crucial. So, how to set the time for Xiaohongshu to publish works? 1. How to set the time for publishing works on Xiaohongshu? 1. Understand the active time of users. First, it is necessary to clarify the active time of Xiaohongshu users. Generally speaking, 8 pm to 10 pm and weekend afternoons are the times when user activity is high. However, this time period will also vary depending on factors such as audience group and geography. Therefore, in order to better grasp the active period of users, it is recommended to conduct a more detailed analysis of the behavioral habits of different groups. By understanding users’ lives

Setting up a wireless network is common, but choosing or changing the network type can be confusing, especially if you don't know the consequences. If you're looking for advice on how to change the network type from public to private or vice versa in Windows 11, read on for some helpful information. What are the different network profiles in Windows 11? Windows 11 comes with a number of network profiles, which are essentially sets of settings that can be used to configure various network connections. This is useful if you have multiple connections at home or office so you don't have to set it all up every time you connect to a new network. Private and public network profiles are two common types in Windows 11, but generally

Detailed explanation of Linux file time viewing techniques In Linux systems, file time information is very important for file management and tracking changes. The Linux system records file change information through three main time attributes, namely access time (atime), modification time (mtime) and change time (ctime). This article details how to view and manage this file time information, and provides specific code examples. 1. Check the file time information by using the ls command with the parameter -l to list the files.

How to use the time and date modules in Python Introduction: In programming, dealing with time and dates are very common tasks. Python provides powerful time and date modules, making time and date operations easier and more convenient. This article will introduce the time and date modules in Python and provide specific code examples to help readers better understand and apply them. 1. Introducing the time and date module Python’s built-in time and date module is the datetime module. We need to introduce this module first.

Many users are not sure how to adjust the time of the gshock watch. The overall method is relatively simple. Here is a detailed introduction to the adjustment method of the gshock watch. Users who do not know how to operate can refer to it. How to adjust the time on a gshock watch 1. First label these buttons according to ABCD. A key: It can be understood as the exit key, usually used together with the C key. The B key and the D key can be understood as: plus and minus keys, which are the adjustment keys. For example, if it is 13 o'clock now, press the D key when it reaches 14 o'clock. The C key is the mode key. You can switch modes by pressing it. Generally, the mode key of a watch is in the lower left corner and has the word "mode" in English. Operation method 1. First we need to adjust the watch to the

With the popularity of short video platforms, video matrix account marketing has become an emerging marketing method. By creating and managing multiple accounts on different platforms, businesses and individuals can achieve goals such as brand promotion, fan growth, and product sales. This article will discuss how to effectively use video matrix accounts and introduce different types of video matrix accounts. 1. How to create a video matrix account? To make a good video matrix account, you need to follow the following steps: First, you must clarify what the goal of your video matrix account is, whether it is for brand communication, fan growth or product sales. Having clear goals helps develop strategies accordingly. 2. Choose a platform: Choose an appropriate short video platform based on your target audience. The current mainstream short video platforms include Douyin, Kuaishou, Huoshan Video, etc.
