Jump to content

Recommended Posts

When inserting into a database, do you have to specify all the column names? Because I get the error:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order)

 

mysql_query("INSERT INTO UserCP(name, link_name, content, order)
VALUES('".$_POST['name']."','".$_POST['lname']."','".$_POST['content']."','".($order[0] -1).")")
	or array_push($error_array, "ERROR08 - ".mysql_error());

 

Table:

 

CREATE TABLE IF NOT EXISTS `UserCP` (

  `id` int(11) NOT NULL auto_increment,

  `name` varchar(30) NOT NULL default '',

  `link_name` varchar(30) NOT NULL default '',

  `content` text NOT NULL COMMENT 'If first line isn''t php add ?> to the start.',

  `enabled` int(11) NOT NULL default '1',

  `order` int(11) NOT NULL default '0',

  PRIMARY KEY  (`id`)

)

 

Is i because I haven't specified the column enabled??

Link to comment
https://forums.phpfreaks.com/topic/164792-solved-inserting-into-a-database/
Share on other sites

try this

mysql_query("INSERT INTO UserCP(name, link_name, content, `order`)
VALUES('".$_POST['name']."','".$_POST['lname']."','".$_POST['content']."','".($order[0] -1)."')") or array_push($error_array, "ERROR08 - ".mysql_error());

 

Added last ' and used back ticks on order field

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.