Jump to content

[SOLVED] Insert Help


topflight

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.