代码给出以下错误:
Warning: mysql_select_db() expects parameter 1 to be string, object given in \imgtest.php on line 35
Warning: mysql_query() expects parameter 1 to be string, object given in
\imgtest.php on line 37
下面是代码:
<!DOCTYPE html>
<html>
<body background="bla.jpg" >
<h3>Register with us</h3>
<form enctype="multipart/form-data" method="POST">
<input type="file" name="image" />
<input type="submit" name="sumit" value="upload te image" />
</form>
<?php
if(isset($_POST["sumit"]))
{
if(getimagesize($_FILES['image']['tmp_name'])== FALSE)
{
echo "blablabla";
}else{
$image= addslashes($_FILES['image']['tmp_name']);
$name= addslashes($_FILES['image']['name']);
$image= file_get_contents($image);
$image= base64_encode($image);
saveimage($name,$image);
}
}
function saveimage($name,$image)
{
$con=mysqli_connect("localhost","root","","mydb");
mysql_select_db($con,"photos");
$qry="insert into images101 (name,image) values ('$name','$image')";
$result=mysql_query($con,$qry);
if($result)
{
echo "imahe uploaded";
}
else
{
echo "image not uploaded";
}
}
?>
</body>
</html>