Php命令行脚本无法使用MYSQLI连接到服务器
我尝试使用这个命令行脚本。它将图像添加到已存在的数据库和表中。服务器上安装了Wamp服务器,我可以从其他计算机访问它。但每次我运行脚本时,脚本在连接时都会挂起Php命令行脚本无法使用MYSQLI连接到服务器,php,mysql,mysqli,Php,Mysql,Mysqli,我尝试使用这个命令行脚本。它将图像添加到已存在的数据库和表中。服务器上安装了Wamp服务器,我可以从其他计算机访问它。但每次我运行脚本时,脚本在连接时都会挂起 <?php error_reporting(E_ALL); ini_set('display_errors', 1); $filename = $argv[1]; //$filename="images/image10.jpg"; $imgData = file_get_contents($filena
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$filename = $argv[1];
//$filename="images/image10.jpg";
$imgData = file_get_contents($filename);
$size = getimagesize($filename);
$servername="192.168.0.34";
$username="root";
$password="password";
$dbname = "test";
$conn = new mysqli($servername, $username, $password, $dbname);
// check connection
if($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connection successful";
// insert into table
$sql = sprintf("insert into images(image_type, image, image_size, image_name) values('%s', '%s', '%d', '%s')",
mysql_real_escape_string($size['mime']),
mysql_real_escape_string($imgData),
$size[3],
mysql_real_escape_string($_FILES['userfile']['name']));
if($conn->query($sql) === TRUE) {
echo "Inserted new image successfully";
} else {
echo "Error inserting image: " . $conn->error;
}
echo "Closing the connection";
$conn = null;
?>
我只在客户端安装了php和php mysql。客户端运行debian,服务器运行windows 7。我是否缺少需要安装的其他内容
谢谢您需要在系统上安装mysqli。请参阅:我已将其安装在我的系统上。使用php-mysql。还有吗?你使用的是什么版本的PHP?