源代码如下:

解决方案 »

  1.   

    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>注册窗口二</title>
    </head><body bgcolor="#ccccff">
    <div align="center">
     <P>
      <h1>注册窗口</h1>
     </p>
    <hr>
    </div>
    <%-- 变量定义--%>
    <%
      String userid=new String();
      String userid2=new String();
      String userpsw=new String();
      String userpsw2=new String();
      String usermail=new String();
      String username=new String();
      String usersex=new String();
      String userwork=new String();
      String temp=new String();
      int n;
    %>
    <%--! 从上一张页面上获得变量值 --%>
    <%
      userid=request.getParameter("txtuserid");
      userid2=request.getParameter("txtuserid2");
      userpsw=request.getParameter("txtpassword");
      userpsw2=request.getParameter("txtpassword2");
      usermail=request.getParameter("txtmail");
      username=request.getParameter("txtname");
      usersex=request.getParameter("radsex");
      userwork=request.getParameter("selwork");
      n=userid.length()*userid2.length()*userpsw.length()*userpsw2.length()*usermail.length()*username.length()*usersex.length()*userwork.length();
    %>
    <%-- 判断zc1.jsp这张页面有没有输入正确的变量 --%>
    <%
      if(n!=0&userpsw.equals(userpsw2)){
        String url=new String();

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:usergl","dpf110120","88643226");
    Statement stmt=con.createStatement();
    String SQL=new String();
    %>
    <%-- 判断这个用户名有没有存在--%>
    <%
      SQL="select * from user1 where user1='"+userid+"'";
      ResultSet rs=stmt.executeQuery(SQL);
      int flag=1;
      if(rs.next()){
        flag=0;
      }
      rs.close();
      if(flag==1){
    %>
    <%--! 向数据库中写入数据 --%>
    <%
      SQL="insert into user1(id1,user1,passwords,email,names,sex,works) values('"+userid+"','"+userid2+"','"+userpsw+"','"+usermail+"','"+username+"','"+usersex+"','"+userwork+"')";
      stmt.executeUpdate(SQL);
    %>
    <%
      String SQL2=new String();
      SQL2="create table"+userid+"(title text,article text)";
      stmt.executeUpdate(SQL2);
      stmt.close();
      con.close();
    %>
      <p align="center">注册成功!</p>
    <table width="200" border="0" cellspacing="0" cellpadding="0">
       <tr>
        <td height="35" width="100">用户账号: </td>
    <td height="35" width="100"><%=userid%> </td>
       </tr>
       <tr>
        <td height="35" width="100">用户昵称: </td>
    <td height="35" width="100"><%=userid2%> </td>
       </tr>
       <tr>
         <td height="35" width="100">E-mail: </td>
     <td height="35" width="100"><%=usermail%> </td>
       </tr>
       <tr>
         <td height="35" width="100">姓名: </td>
     <td height="35" width="100"><%=username%> </td>
       </tr> 
       <tr>
         <td height="35" width="100">性别: </td>
     <td height="35" width="100"><%=usersex%> </td>
       </tr> 
       <tr>
         <td height="35" width="100">职业: </td>
     <td height="35" width="100"><%=userwork%> </td>
       </tr> 
    </table>
    <%
      }
      }
      else{
    %>
    <%
      if(!(userpsw.equals(userpsw2))){
    %>
        <p>
    密码不符!
    </p>
    <%
      }
      if(n==0){
    %>
        <p>
        有未添加的注册信息!
        </p>
    <%
      }
    %>
      <p>
      注册不成功!
      </p>
    <%
    }
    %>
    </div>
    </body>
    </html>
      

  2.   

    出错的提示如下:
    org.apache.jasper.JasperException: [Microsoft][ODBC SQL Server Driver][SQL Server]第 1 行: 'table1' 附近有语法错误。
      

  3.   

    那么这个table这个是在数据库中还是在那里呢?>
      

  4.   

    SQL2="create table"+userid+"(title text,article text)";
     add blankspace
    SQL2="create table "+userid+" (title text,article text)";
      

  5.   

    "create table  "+userid+"(title text,article text)";
    table后要有空格,你的好像是没这个
      

  6.   

    tomuno(tomuno)和wsk_228(qing_feng)说的很明白了!如果没有空格,你的语句就是这样:假如说,你的userid的值为:aaacreate tableaaa(title text,article text)你自己觉得,数据库,能识别吗?