Jump to content

Recommended Posts

I am trying to insert something to the database and I getting the falling error.

 

Stored in: screenshots/fs2004-2009-jun-17-019.jpgYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'show) VALUES ('2001', 'fs2004-2009-jun-17-019.jpg', '67.169.186.234', '06' at line 2

 

This is the insert code

<?php
include'db.php';
  $name = $_POST['name'];
  $login = $_POST['login'];
  $ip = $_POST['ip'];
  $dscp = $_POST['descp'];
  $info = $_FILES["file"]["name"];
  $link = "$info";
  $fdate = $_POST['udate'];
  $show = $_POST['public'];
  
 $insert = mysql_query ("INSERT INTO `screenshots`(login,link,ip,date,name,decp,show) VALUES     ('$login','$link','$ip','$fdate','$name','$dscp','$show') ") or die(mysql_error());

?>

Thanks in advanced.

Link to comment
https://forums.phpfreaks.com/topic/162684-solved-insert-help/
Share on other sites

You have a field in the screenshots table called show, correct ?

Well Show is a MySQL reserved word (meaning it has a special meaning)

So you can't use it the way you are trying to use it. so to tell MySQL its a field you add the back ticks `

 

think if it this way, just say i have a field called SELECT

and i ENTER

SELECT SELECT from table

MySQL would be quite confused so i would need to do this

SELECT `SELECT` from table

 

So either rename the field you have called "show" to "ShowIT" (for example) or change the query to the one in my last post

Link to comment
https://forums.phpfreaks.com/topic/162684-solved-insert-help/#findComment-858550
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.