surochek Posted July 20, 2007 Share Posted July 20, 2007 The form works. Almost. The first field (Character="name") is the only one that won't accept the value and won't insert the data into the db. What is it that I'm missing? The main page: <?php session_start(); include("connect.php"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Twenty Questions</title> <link rel="stylesheet" type="text/css" href="builder2.css" media="screen" /> <link rel="stylesheet" type="text/css" href="printbuilder.css" media="print" /> </head> <body> <div id="wrapper"> <div class="header"> <span class="title">The Ultimate Character Builder</span><br /> <h3>Part 2<br /> Twenty Questions</h3> </div> <br /> <br /> <div class="left"> <?php include_once("left.inc"); ?> </div> <div class="content"> <?php $user=$_SESSION['username']; if (isset($_POST['submit'])) { $sql = "SELECT * FROM twentyquestions WHERE username = '$user'"; $query = mysql_query($sql) or die (mysql_error(). " with query : ". $sql."<br>"); $num=mysql_num_rows($query); if ($num<1){ $user = $_SESSION['username']; $name = $_POST['character_name']; $q1a = $_POST['1a']; $q1b = $_POST['1b']; $q2a = $_POST['2a']; $q2b = $_POST['2b']; $query = "INSERT INTO twentyquestions (username, character_name, 1a, 1b, 2a, 2b, ) VALUES ('$user','$name', '$q1a', '$q1b', '$q2a', '$q2b')"; $update=mysql_query($query) or die("<br>Error: ". mysql_error(). " with query : ". $query); echo "<span style='color:#330099;'><h3 align='center'>Information saved!</h3></span>"; } else{ $user = $_SESSION['username']; $name = $_POST['character_name']; $q1a = $_POST['1a']; $q1b = $_POST['1b']; $q2a = $_POST['2a']; $q2b = $_POST['2b']; $query = "UPDATE twentyquestions SET character_name='$name', 1a='$q1a', 1b='$q1b', 2a='$q2a', 2b='$q2b' WHERE username = '$user'"; $update=mysql_query($query) or die("<br>Error: ". mysql_error(). " with query : ". $query); echo "<span style='color:#330099;'><h3 align='center'>Form updaded successfully.</h3></span>"; $query = "SELECT * FROM twentyquestions WHERE username='$user'"; $result= mysql_query($query); $info=mysql_fetch_array($result) or die (mysql_error()); $name = $info['character_name']; $q1a = $info['1a']; $q1b = $info['1b']; $q2a = $info['2a']; $q2b = $info['2b']; } } $sql = "SELECT * FROM twentyquestions WHERE username = '$user'"; $query = mysql_query($sql) or die (mysql_error(). " with query : ". $sql."<br>"); $num=mysql_num_rows($query); if ($num!==0){ $query = "SELECT * FROM twentyquestions WHERE username='$user'"; $result= mysql_query($query); $info=mysql_fetch_array($result) or die (mysql_error()); $name = $info['character_name']; $q1a = $info['1a']; $q1b = $info['1b']; $q2a = $info['2a']; $q2b = $info['2b']; echo "<form action=".$_SERVER['SCRIPT_NAME']." method='post'>"; include("basicquestions.php"); } else { echo "<form action=".$_SERVER['SCRIPT_NAME']." method='post'>"; include("basicquestions.php"); } ?> </table> </form> </div> <br /> <br /> <br /> </div> </body> </html> The form itself: <table border="0" cellpadding="3" cellspacing="3" summary="Twenty Questions" align="center"> <tr class="hide"><td colspan="4"><br /> <br /> <br /> <br /> </td></tr> <tr><td colspan="4" align="center"><h3>List of Conflicts</h3></td></tr> <tr><td> </td><td align="right"><b>Character:</b></td><td> <textarea rows="1" cols="25" name="character_name"><?php echo $name?></textarea></td><td> </td></tr> <tr><td></td><td><b>External</b></td><td><b>Internal</b></td><td></td></tr> <tr><td>1</td><td> <textarea rows="2" cols="25" name="1a"><?php echo $q1a?></textarea></td><td> <textarea rows="2" cols="25" name="1b"><?php echo $q1b?></textarea></td><td></td></tr> <tr><td>2</td><td> <textarea rows="2" cols="25" name="2a"><?php echo $q2a?></textarea></td><td> <textarea rows="2" cols="25" name="2b"><?php echo $q2b?></textarea></td><td></td></tr> <tr><td> </td><td colspan="3"><center> <?php echo "<input type='submit' name='submit'>"; ?> </center></td></tr> ...Ready to feel duh... Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 20, 2007 Share Posted July 20, 2007 try echoing the $sql 's personally i don't see the problem unless your getting errors.. or posting something weird Quote Link to comment Share on other sites More sharing options...
surochek Posted July 20, 2007 Author Share Posted July 20, 2007 That's the thing. I'm not getting errors. I can post from all the other fields and the data gets into the db, except for the first field ($name='character_name'). I can't see what's wrong, either. I'm not getting any mysql errors. Quote Link to comment Share on other sites More sharing options...
play_ Posted July 20, 2007 Share Posted July 20, 2007 $query = "INSERT INTO twentyquestions (username, character_name, 1a, 1b, 2a, 2b, ) VALUES ('$user','$name', '$q1a', '$q1b', '$q2a', '$q2b')"; you have an extra comma (,) after 2b. try taking it otu Quote Link to comment Share on other sites More sharing options...
surochek Posted July 20, 2007 Author Share Posted July 20, 2007 Thanks, but that' s not it. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 20, 2007 Share Posted July 20, 2007 can you post the SQL statements then!! Quote Link to comment Share on other sites More sharing options...
surochek Posted July 20, 2007 Author Share Posted July 20, 2007 Well, whatever it was, in the process of checking and double-checking, I made it go away. Maybe I didn't upload the code properly. It works now. I did predict a duh. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.