I got following 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 '' at line 1
$latestid = "SELECT id,fr_id,max(frd_date) FROM emp WHERE user_id ='$uid' and status='0' GROUP BY id DESC Limit 1";
$latestresult = mysql_query($latestid) or die(mysql_error());
$num1 = mysql_fetch_array($latestresult);
Mysql + php error
Moderator: General Moderators
- Jaxolotl
- Forum Contributor
- Posts: 137
- Joined: Mon Nov 13, 2006 4:19 am
- Location: Argentina and Italy
Re: Mysql + php error
Query seems to be ok, I create the DB structure and make the query with no error messages.
SELECT id,fr_id,max(frd_date) FROM emp WHERE user_id =''1'' and status=''0'' GROUP BY id DESC Limit 1
Wich MySQL version are you using? Limit max() or Group may not be available for that version
Code: Select all
CREATE TABLE `emp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fr_id` int(11) NOT NULL DEFAULT '0',
`frd_date` date NOT NULL DEFAULT '0000-00-00',
`user_id` int(11) NOT NULL DEFAULT '0',
`status` enum('0','1') NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `fr_id` (`fr_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Wich MySQL version are you using? Limit max() or Group may not be available for that version
Re: Mysql + php error
It seems that MySQL isn't reading even the first word of your query string, since the error says: near ": -- meaning that it hasn't even read "SELECT". Try echoing the contents of your $latestid variable, right before you try to query the database.
Re: Mysql + php error
I just realized that you have posted the same question twice in a few hours. Please don't do that!