【php – 如何在另一个页面上的另一个类中访问mysqli连接?】教程文章相关的互联网学习教程文章

php – mysqli_query()预计至少有2个参数,1给出?【代码】

参见英文答案 > mysqli_query expects at least 2 parameters 5个每次运行这个php时,我都会得到相同的3个错误.我不知道我做错了什么,有人可以帮忙吗? 以下是错误:[05-May-2014 19:20:50 America/Chicago] PHP Warning: mysqli_query()expects at least 2 parameters, 1 given in/home/sagginev/public_html/Nutrifitness/search.php on line 10 [05-May-2014 19:20:50 America/Chicago] PHP...

php – 在mysqli中插入许多值的最佳方法?【代码】

我正在寻找一种SQL注入安全技术,用PHP和MySQLi一次插入大量行(约2000).我有一个包含所有必须包含的值的数组.目前我正在这样做:<?php $array = array("array", "with", "about", "2000", "values");foreach ($array as $one) {$query = "INSERT INTO table (link) VALUES ( ?)";$stmt = $mysqli->prepare($query);$stmt ->bind_param("s", $one);$stmt->execute();$stmt->close(); } ?>我尝试了call_user_func_array(),但它导致了...

php – mysqli_select_db()期望参数1为mysqli,给定字符串【代码】

我是Mysqli_ *的新手,我收到了这些错误:Warning: mysqli_select_db() expects parameter 1 to be mysqli, stringgiven in D:\Hosting\9864230\html\includes\connection.php on line 11 Warning: mysqli_error() expects exactly 1 parameter, 0 given inD:\Hosting\9864230\html\includes\connection.php on line 13数据库选择失败:<?php require("constants.php");// 1. Create a database connection $connection = mysqli_co...

php – mysqli :: query():无法获取mysqli【代码】

Warning: mysqli::query(): Couldn’t fetch mysqli in C:\Program Files (x86)\EasyPHP-DevServer-13.1VC9\data\localweb\my portable files\class_EventCalendar.php on line 43以下是我的连接文件:<?php if(!isset($_SESSION)) { session_start(); } // Create array to hold error messages (if any) $ErrorMsgs = array();// Create new mysql connection object $DBConnect = @new mysqli("localhost","root@localhost",...

php – 为什么mysqli给出“命令不同步”错误?【代码】

我正在尝试运行以下内容.<?php$db = mysqli_connect("localhost","user","pw") or die("Database error"); mysqli_select_db($db, "database");$agtid = $_POST['level'];$sql = sprintf("call agent_hier(%d)", $agtid);$result = mysqli_query($db, $sql) or exit(mysqli_error($db));if ($result) {echo "<table border='1'><tr><th>id</th><th>name</th><th>parent_id</th><th>parent_name</th><th>level</th><th>email</th></...

php – MySQLi编写语句错误报告【代码】

参见英文答案 > How to get MySQLi error information in different environments? / mysqli_fetch_assoc() expects parameter 1 to be mysqli_result 1个我正试图绕过MySQli,我对错误报告感到困惑.我使用MySQLi’prepare’语句的返回值来检测执行SQL时的错误,如下所示:$stmt_test = $mysqliDatabaseConnection->stmt_init(); if($stmt_test->prepare("INSERT INTO testtable VALUES (23,44,...

php – 类mysqli_result的对象无法转换为字符串【代码】

我收到错误: mysqli_result类的对象无法转换为字符串 这是我的代码:$username2 = htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8');$con = mysqli_connect('localhost','root','','test');$result = mysqli_query($con, "SELECT classtype FROM learn_usersWHERE username='$username2';");echo "my result <a href='data/$result.php'>My account</a>";解决方法:mysqli_query()将对象资源返回到$result变量,而...

PHPmysqli扩展整理,包括面向过程和面向对象的比较\事务控制\批量执行\预处理【代码】【图】

相关文章:PHP的mysql扩展整理,操作数据库的实现过程分析 介绍 mysqli是PHP程序与mysql数据库进行数据交互的桥梁,它支持面向过程和面向对象两种方式 面向过程方式 现在面向对象编程已经成为了主流,mysqli面向过程化的编程方式可能已经没有太多实用价值,但是通过面向对象的和面向过程两种方式实现同一段代码,对体会对象和过程两种编程思想还是很有意义,个人觉得这个比较十分有趣! 流程图: 实例:<?php header("content-type:t...

php – 警告:mysqli_connect():( HY000 / 1045):用户’用户名’@’localhost’拒绝访问(使用密码:YES)【代码】

Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘username’@’localhost’ (using password: YES) in C:\Users\xampp\htdocs\PHP_Login_Script\config.php on line 6 Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given in C:\Users\xampp\htdocs\PHP_Login_Script\login.php on line 10 Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, boole...

php mysqli_connect:客户端未知的身份验证方法[caching_sha2_password]【代码】

我使用php mysqli_connect登录MySQL数据库(全部在localhost上)<?php //DEFINE ('DB_USER', 'user2'); //DEFINE ('DB_PASSWORD', 'pass2'); DEFINE ('DB_USER', 'user1'); DEFINE ('DB_PASSWORD', 'pass1'); DEFINE ('DB_HOST', '127.0.0.1'); DEFINE ('DB_NAME', 'dbname');$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);if(!$dbc){die('error connecting to database'); } ?>这是mysql.user表: MySQL Serv...

php – 警告:mysqli_query()需要至少2个参数,给定1个.什么?【代码】

我创建了一个PHP页面,它应该从数据库中选择两个名称并显示它们. 它只是说:Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/tdoylex1/public_html/dorkhub/index.php on line 4Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/tdoylex1/public_html/dorkhub/index.php on line 8我的代码是:<?php mysqli_connect(localhost,tdoylex1_dork,dorkk,tdoylex1_dork); $name1 = my...

php – 如何将mysql更改为mysqli?【代码】

根据下面的代码,我用于常规的mysql,我怎么能将它转换为使用mysqli? 是否像更改** mysql _query($sql)一样简单;到mysqli _query($sql); ?**<?PHP//in my header file that is included on every page I have this $DB["dbName"] = "emails"; $DB["host"] = "localhost"; $DB["user"] = "root"; $DB["pass"] = ""; $link = mysql_connect($DB['host'], $DB['user'], $DB['pass']) or die("<center>An Internal Error has Occured. ...

php – 如何显示MySQLi查询的错误?【代码】

参见英文答案 > How to get MySQLi error information in different environments? / mysqli_fetch_assoc() expects parameter 1 to be mysqli_result 1个> mysqli or die, does it have to die? 4个我使用以下脚本来处理表单以向我的网站添加信息.我遇到的问题是,当我提交表单时,没有任何内容被提交到数据库,并且没有错误.如何向查询添加错误报...

php – 从mysql转换为mysqli(mysql_fetch_array)【代码】

我有一些像这样的PHP代码:$row = mysql_fetch_array ( mysql_query("SELECT * FROM `tblFacilityHrs` WHERE `uid` = '$uid'")); 我现在正尝试将其转换为mysqli_fetch_array,如此处所示http://php.net/manual/en/mysqli-result.fetch-array.php(示例#1面向对象的样式) 我不确定“$result”的例子意味着什么. 这就是我到目前为止转换代码的原因:<?php include('../config.php'); if (isset($_GET['uid']) ) { $uid = $_GET['uid...

php – mysqli bind_param和受影响的行错误【代码】

我是mysqli的新手,我查过过PHP手册等等,没什么用.我不太确定出了什么问题.我一直收到这个错误:Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters in prepared statement in C:\xampp\htdocs\new1\template.php on line 165还有这个Warning: mysqli_stmt_affected_rows() [function.mysqli-stmt-affected-rows]: Couldn't fetch mysqli_stmt in C:\xampp\htd...