RE: What wrong with my Query??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Either syntax is correct. From section 6.4.3 of the MySQL Manual:

INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
        [INTO] tbl_name [(col_name,...)]
        VALUES ((expression | DEFAULT),...),(...),...
        [ ON DUPLICATE KEY UPDATE col_name=expression, ... ]
or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
        [INTO] tbl_name [(col_name,...)]
        SELECT ...
or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
        [INTO] tbl_name
        SET col_name=(expression | DEFAULT), ...
        [ ON DUPLICATE KEY UPDATE col_name=expression, ... ]

David

*************************************************************************************************************
Actually, your sql syntax is wrong. The SET keyword if for UPDATE not
INSERT 

Use 
$sql = "INSERT INTO mfadmin
(id,account,planlimit,name,email,password,lastlogin,datecreated,expiry,l
astip) VALUES
('','$accname_lc','$plans','$yourname','$email','$password','$datetoday'
,'$datetoday','$expirydate','123.123.123.123')";


Gary Every
Sr. UNIX Administrator
Ingram Entertainment Inc.
2 Ingram Blvd, La Vergne, TN 37089
"Pay It Forward!"


-----Original Message-----
From: HarryG [mailto:harry1980@xxxxxxxxx] 
Sent: Thursday, March 24, 2005 11:27 PM
To: php-db@xxxxxxxxxxxxx
Subject:  What wrong with my Query??


What the hell is wrong with this MYSQL query?? PHP keeps giving me the
error message:

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
'limit=20000, name='test1', email='atest@xxxxxxxx', password='t 

$query = "INSERT INTO mfadmin SET id='', account='$accname_lc',
limit=$plans, name='$yourname', email='$email', password='$password',
lastlogin='$datetoday', datecreated='$datetoday', expiry='$expirydate',
lastip=123.123.123.123";
 
This is my table structure
CREATE TABLE `admin` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `account` varchar(50) NOT NULL default '',
  `limit` int(10) unsigned NOT NULL default '0',
  `name` varchar(50) NOT NULL default '',
  `email` varchar(50) NOT NULL default '',
  `password` varchar(50) NOT NULL default '',
  `lastlogin` varchar(50) NOT NULL default '',
  `datecreated` varchar(50) NOT NULL default '',
  `expiry` varchar(50) NOT NULL default '',
  `lastip` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux