I want to connect to old mysql server (Server is 4.0.20-standard) with php7. Upgrade mysql server or downgrade php is not an option.
I'm doing this: $conn = mysqli_connect($local,$user,$pwd,$db,$port);
But i'm getting this error: Warning: mysqli_connect(): Connecting to 3.22, 3.23 & 4.0 is not supported. Server is 4.0.20-standard
. Is possible do that?
Solution (didactic solution, do not use this on production environment):
Step 1: Install putty.exe + plink.exe in php7 machine. Step 2: I created these methods to do all the job for you/me. Example1:
$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"];
}
Example2:
$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"]
}
For update/delete/insert you can use something similar to the insert
method. Example 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: You need to change the method variables (host, database, username, password, etc)... Remember2: Change the mysql credentials at this line $commands[0] = 'mysql -u username -pPASSWORD...'