我想用php7连接旧的mysql服务器(Server是4.0.20-standard)。升级mysql服务器或降级php不是一种选择。
我这样做:$conn = mysqli_connect($local,$user,$pwd,$db,$port);
但我收到此错误:Warning: mysqli_connect(): Connecting to 3.22, 3.23 & 4.0 is not supported. Server is 4.0.20-standard
。
有可能吗?
答案 0 :(得分:-1)
解决方案(教学解决方案,不要在生产环境中使用此方法):
步骤1:在php7机器上安装putty.exe + plink.exe。第2步:我创建these methods为你/我完成所有工作。例1:
$query = "SELECT * FROM user";
$rs = select($query);
if($rs)
for($index = 0; $index < count($rs);$index++){
//ALWAYS use this. Now u can use that array like a normal resultset $rs["lalala"]
$row1 = $rs[$index];
//use this like usual
echo $rs["username"];
}
例2:
$query = "SELECT * FROM user";
$rs = select($query);
if($rs)
for($index = 0; $index < count($rs);$index++){
//ALWAYS use this. Now u can use that array like a normal resultset $rs["lalala"]
//$row1 = $rs[$index];
//now you didn't the line above...
echo $rs[$index]["username"];//you'll need something like $rs[0]["username"]
}
对于更新/删除/插入,您可以使用类似于insert
方法的内容。例3:
if(m_insert("insert into user (name,pwd,email) values ('kkk', 'hahaha', 'email@lala.com');")){
echo "</br>true</br>";
} else {
echo "</br>false</br>";
}
Remember1:您需要更改方法变量(主机,数据库,用户名,密码等)......
记住2:在此行$commands[0] = 'mysql -u username -pPASSWORD...'