Jump to content

Uncaught mysqli_sql_exception


ivanAdolfo

Recommended Posts

insertImg: $sql="`user`, `id`, `imageName`, `imageType`,  `imageSize`, `imgeContent`)  VALUES ($wuser,$id, $imgName, $imgType, $imgSize,$imgContent)";

Values:   XY(user varchar)=1(id int)=noticiacallampa.jpg(imageName varchar)=image/jpeg(imageType varchar)=31 kB(imageSize varchar)=imgContent (longlob it comes from file_get_contents($image)
Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'kB,????' at line 5 in C:\xampp\htdocs\_website\liceoUtil\php\liceoFuncs.php:79 Stack trace: #0 C:\xampp\htdocs\_website\liceoUtil\php\liceoFuncs.php(79): mysqli_query(Object(mysqli), 'INSERT INTO `li...') #1 C:\xampp\htdocs\_website\liceoIUpload.php(32): insertImg(Object(mysqli)) #2 {main} thrown in C:\xampp\htdocs\_website\liceoUtil\php\liceoFuncs.php on line 79

line 79: $result = mysqli_query($conn, $sql);

thanks

Link to comment
Share on other sites

An insert query works better if your sql informs the server

  1. it's an INSERT query
  2. which table to insert into

so needs to begin with "INSERT INTO tablename..."

Also, string literals like $imageName need to be inside single quotes. However you should be using a prepared statement.

I would also advise storing your image files in the filesystem and putting the metadata (such as filename) in the table.

Link to comment
Share on other sites

21 hours ago, Barand said:

An insert query works better if your sql informs the server

  1. it's an INSERT query
  2. which table to insert into

so needs to begin with "INSERT INTO tablename..."

Also, string literals like $imageName need to be inside single quotes. However you should be using a prepared statement.

I would also advise storing your image files in the filesystem and putting the metadata (such as filename) in the table.

I try it using quotes as well and the INTO 'tablename' and the error still the same.

I will do what you suggest... storing your image files in the filesystem and putting the metadata (such as filename) in the table.

Thanks.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.