Please help.. I have no idea whats wrong.

<?
include("accesscontrol.php");
include('../config.php');
include('header.php');
if($createpermission !="true") { echo "You do not have permission to create users.</div></div></body></html>"; }else{
if(!isset($ends_design_add_go)) {
?>
<div align="right">
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="85%">
    <tr>
      <td width="100%">
      <form method="post" action="adduser.php" name="addForm">
  <input type="hidden" name="id"  size="45" value="id" />
  <input type="text" name="userid"  size="45" value="" />
  Username<br />
  <br />
  <input type="password" name="password"  size="45" value="" />
  Password<br />
  <br />
  <input type="text" name="fullname"  size="45" value="" />
  Full Name<br />
  <br />
  <input type="text" name="emailaddress"  size="45" value="" />
  Email Address<br>
  <br>
  <input type="text" name="URL"  size="45" value="" /> Website<br>
  <br>
  <input type="text" name="pic"  size="45" value="" /> Picture<br>
  <br>
  <input type="text" name="dlevel"  size="45" value="" /> Display level<br>
  <br>
  <? $divisiondrop = "SELECT Gname FROM $divisionprefix ORDER BY id desc";

 ?>
 <select name=division>
 <? 

$resultdivision=mysql_query($divisiondrop) or die(mysql_error()); 
while($row=mysql_fetch_array($resultdivision)) { 

?>
<option value="<?=$row['Gname']?>"><?=$row['Gname']?></option>
<? 
}
?> 
</select> Division<br>
  <br>
<? $rankdrop = "SELECT rank FROM $rankprefix ORDER BY rnum desc";

 ?>
 <select name=rank>
 <? 

$resultrank=mysql_query($rankdrop) or die(mysql_error()); 
while($row=mysql_fetch_array($resultrank)) { 

?>
<option value="<?=$row['rnum']?>"><?=$row['rank']?></option>
<? 
}
?> 
</select> Rank<br>
  <br>
      	<? $titledrop = "SELECT Tname FROM $titleprefix ORDER BY id desc";

 ?>
 <select name=titles>
 <? 

$resulttitle=mysql_query($titledrop) or die(mysql_error()); 
while($row=mysql_fetch_array($resulttitle)) { 

?>
<option value="<?=$row['Tname']?>"><?=$row['Tname']?></option>
<? 
}
?> 
</select> Title<br>
  <br>
      	<? $honordrop = "SELECT honor FROM $honorprefix ORDER BY id desc";

 ?>
 <select name=division>
 <? 

$resulthonor=mysql_query($honordrop) or die(mysql_error()); 
while($row=mysql_fetch_array($resulthonor)) { 

?>
<option value="<?=$row['honor']?>"><?=$row['honor']?></option>
<? 
}
?> 
</select> Honor<br />
  <br>
  <textarea rows="7" name="bio" cols="38"></textarea><br>
  <br />
  <input name="activate" type="checkbox" value="1" />
  Activate<br />
  <br />
  <input name="add2" type="checkbox" value="true" />
  Post Entry Permission<br />
  <br />
  <input name="edit2" type="checkbox" value="true" />
  Edit Entry Permission<br />
  <br />
  <input name="delete2" type="checkbox" value="true" />
  Delete Entry Permission<br />
  <br />
  <input name="create2" type="checkbox" value="true" />
  Create User Permission<br />
  <br />
  <input name="ulevel" type="checkbox" value="true" />
  Administrator Permission<br />
  <br />
  <input name="vamp" type="checkbox" value="true" />
  Vamp Member<br />
  <br />
  <input type="hidden" name="ends_design_add_go" value="TRUE" />
  <input name="submit" type="submit" value="Create User" />
</form></div>
</div>
      </td>
    </tr>
  </table>
</div>
<br><br>
</body>
</html>
<?
} else {
$MYSQLCONN = mysql_connect("$host","$username","$userpass") or die("Error connecting to database.");
mysql_select_db("$userdatabase",$MYSQLCONN) or die("The database could not be found.");
$query = "INSERT INTO $userprefix ('id','userid','password','fullname','emailaddress','add2','edit2','delete2','create2','activated','last_login','rank','pic','title','honor','division','bio','ip','ulevel','URL','vamp','dlevel') VALUES ('','$userid','$password','$fullname','$emailaddress','$add2','$edit2','$delete2','$create2','$activated','','$rank','$pic','$title','$honor','$division','$bio','','$ulevel','$URL','$vamp','$dlevel')";
if(!mysql_query($query)) { echo "Error: must be a unique admin user name and id"; } else { echo "User Created </div></div></body></html>"; }
} }
?>

    Don't try to insert '' into id (assuming its auto_inc. Either insert NULL or omit the id and the '' altogether.

    There may be other errors - a few clues would help, like error messages etc

    hth

      it was null before and still did'nt work.

      I dont get errors. I just cant do the query. So it displays my error message.

        echo the query to check variables and syntax and, if you ask mysql nicely it'll give you the error message 🙂

        $query = "INSERT INTO $userprefix  ('id','userid','password','fullname','emailaddress
        ','add2','edit2','delete2','create2','activated','
         last_login','rank','pic','title','honor','division
        ','bio','ip','ulevel','URL','vamp','dlevel') VALUES  ('','$userid','$password','$fullname','$emailaddre
         ss','$add2','$edit2','$delete2','$create2','$activ
         ated','','$rank','$pic','$title','$honor','$divisi
        on','$bio','','$ulevel','$URL','$vamp','$dlevel')"; 
        if(!mysql_query($query)) { 
        echo mysql_error(); 
        echo "<br>$query";
        } else { echo "User Created </div></div></body></html>"; } 
        }
          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 ''id','userid','password','fullname','emailaddress ','add2','ed
          INSERT INTO vampusers ('id','userid','password','fullname','emailaddress ','add2','edit2','delete2','create2','activated',' last_login','rank','pic','title','honor','division ','bio','ip','ulevel','URL','vamp','dlevel') VALUES ('','test','','',' ss','','','','',' ated','','','','Vamp','',' on','','','','','','')
          

            Don't quote field names, only values

            INSERT INTO vampusers (id,userid,password,fullname,emailaddress
            ,add2,edit2,delete2,create2,activated,
            last_login,rank,pic,title,honor,division
            ,bio,ip,ulevel,URL,vamp,dlevel) VALUES (NULL, ...... )

            If you have any reserved words as field names, use backticks

              Still not working. What am I doing wrong? Thanks for your time me It really helps.

              $MYSQLCONN = mysql_connect("$host","$username","$userpass") or die("Error connecting to database.");
              mysql_select_db("$userdatabase",$MYSQLCONN) or die("The database could not be found.");
              $query = "INSERT INTO $userprefix (id, userid, password, fullname, emailaddress, add2, edit2, delete2, create2, activated, rank, pic, title, honor, division, bio, ulevel, URL, vamp, dlevel) VALUES (NULL, $userid, $password, $fullname, $emailaddress, $add2, $edit2, $delete2, $create2, $activated, $rank, $pic, $title, $honor, $division, $bio, $ulevel, $URL, $vamp, $dlevel)";
              

                could I just do somthing like this?

                $query = "INSERT INTO $userprefix
                id='$id',userid='$userid',password='$password',fullname='$fullname',emailaddress='$emailaddress',add2='$add2',edit2='$edit2',delete2='$delete2',create2='$create2',activated='$activate',rank='$rank',pic='$pic',title='$title2',honor='$honor',division='$division',bio='$bio',ulevel='$ulevel',URL='$URL',vamp='$vamp',dlevel='$dlevel'";
                

                  Originally posted by Paragon

                  does that means its working? if so mark resolved... otherwise if you want to use field=value you can do an UPDATE just be sure to LIMIT it to 1 row, and to use a WHERE clause

                    1) Have you tried echoing the SQL to the screen to see if anything is missing and the syntax is correct?

                    2) Have you ran the query manually against mysql?

                      Originally posted by Paragon
                      could I just do somthing like this?

                      $query = "INSERT INTO $userprefix
                      id='$id',userid='$userid',password='$password',fullname='$fullname',emailaddress='$emailaddress',add2='$add2',edit2='$edit2',delete2='$delete2',create2='$create2',activated='$activate',rank='$rank',pic='$pic',title='$title2',honor='$honor',division='$division',bio='$bio',ulevel='$ulevel',URL='$URL',vamp='$vamp',dlevel='$dlevel'";
                      

                      [/B]

                      And no, this won't work

                        yes I have I cant figure it out.

                          Originally posted by Paragon
                          yes I have I cant figure it out.

                          Not the most informative of responses, but the telepathy repairman should be around this afternoon and I might be able to help when he's done.

                            Originally posted by barand
                            Don't quote field names, only values

                            INSERT INTO vampusers (id,userid,password,fullname,emailaddress
                            ,add2,edit2,delete2,create2,activated,
                            last_login,rank,pic,title,honor,division
                            ,bio,ip,ulevel,URL,vamp,dlevel) VALUES (NULL, ...... )


                            If you have any reserved words as field names, use backticks

                            hve you actually tried this yet?

                            NOT quoting the columns
                            QUOTING the values....

                              Originally posted by Weedpacket
                              Not the most informative of responses, but the telepathy repairman should be around this afternoon and I might be able to help when he's done.

                              I thought the telepathy guy was coming yesterday!?!? No wonder my day was off...

                                Originally posted by LordShryku
                                I thought the telepathy guy was coming yesterday!?!? No wonder my day was off...

                                woops I should have told you guys....

                                I'm standing in for him today 😃

                                my bad! :o

                                  Originally posted by barand
                                  Don't quote field names, only values

                                  If you have any reserved words as field names, use backticks

                                  You removed the quotes from the values too.

                                    Originally posted by barand
                                    You removed the quotes from the values too.

                                    third time he's been told this... I dont think he's listening :eek:

                                      Write a Reply...