• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

看看这个存储过程哪里错了

mysql 搞代码 7年前 (2018-05-31) 132次浏览 已收录 0个评论

看看这个存储过程错哪了?
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;


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:看看这个存储过程哪里错了
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址