看看这个存储过程错哪了?
CREATE PROCEDURE AddTopic($fid smallint, $author char(15), $subject char(80), $message mediumtext)
BEGIN
DECLARE $authorid mediumint;
SELECT MAX(uid) INTO $authorid FROM bbs_members WHERE username = &author; -- 这句注释掉, 就不会出错, 不明白这句怎么错了?
DECLARE $postime int;
SELECT MAX(dateline) INTO $postime FROM bbs_posts;
IF $postime IS NULL THEN
SET $postime = 0;
END IF;
INSERT INTO bbs_threads (fid, subject, author, authorid, dateline, lastpost) VALUES ($fid, $subject, $author, $authorid, $postime, $postime);
UPDATE bbs_forums SET threads = threads + 1 WHERE fid = $fid;
INSERT INTO bbs_posts (fid, tid, subject, author, authorid, message, dateline) VALUES ($fid, last_insert_id(), $subject, $author, $authorid, $message, $postime);
UPDATE bbs_forums SET posts = posts + 1 WHERE fid = $fid;
END;
------解决方案--------------------SELECT MAX(uid) INTO $authorid FROM bbs_members WHERE username = $author;
对了,你的变量尽量不要前面加¥符号。
------解决方案--------------------出错信息是什么?
------解决方案--------------------因为你select语句下面还有定义变量呀:
DECLARE $postime int;