Upload image from local drive and not Web Form using PHP -


i trying upload image mysql database. trying below no avail.

<?php global $mysqli; $mysqli = new mysqli("127.0.0.1", "root", "mypass", "mydb"); if ($mysqli -> connect_errno) {     echo "failed connect mysql: (" . $mysqli -> connect_errno . ") " . $mysqli -> connect_error; }  $image = addslashes(file_get_contents('c:/wamp64/www/images/img1.jpg'));  $image_name = addslashes("imagename"); $query = "insert info ('image', 'image_name') values ('$image', '$image_name')";  if (!mysql_query($query))     {      echo "something went wrong!";      } ?> 

i below error:

deprecated: mysql_query(): mysql extension deprecated , removed in future: use mysqli or pdo instead in c:\wamp64\www\index.php on line 13

warning: mysql_query(): access denied user ''@'localhost' (using password: n o) in c:\wamp64\www\index.php on line 13

warning: mysql_query(): link server not established in c:\wamp 64\www\index.php on line 13 went wrong!

however, if remove code starting $image, not errors, meaning database connection successful. there seems wrong in second part of code, , i'm afraid error might misleading.

  • do not use string concatenation sql queries.
  • look pdo
  • you're connecting using mysqli, query command mysql. error extremely clear.

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -