legohead6 Posted May 22, 2006 Share Posted May 22, 2006 when you click submit it doesnt post anything to the database[code]<?PHPsession_start();?><html><body bgcolor="#000000" text="#FF0000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF"><form method="POST"> <p>Message:<br> <textarea rows="5" name="Me" cols="26"></textarea></p> <p><input type="submit" value="Submit" name="submit"></p></form><?phpif(isset($_POST['submit'])){$username="***";$password="*****";$database="******";mysql_connect(localhost,$username,$password);@mysql_select_db($database) or die( "Unable to select database");$me=$_POST['Me'];$em=$_SESSION['email'];$cat=$_GET['cid'];$user=$_SESSION['user'];$id=$_GET['id'];$query2 = "SELECT * FROM messages WHERE id=$id";$result2 = mysql_query($query2);$row = mysql_fetch_row($result2);$re="RE:";$subj="$re $row[2]";$mes="<i><font size='2'>Original Message By $row[1]</font><br><br>$row[3]</i><br>-----------------------------<br><br>$me<br>";$me=$_POST['Me'];$query = "INSERT INTO messages VALUES ('','$user','$subj','$mes','$em','$cat')";mysql_query($query);}$cat=$_GET['cid'];echo "<a href='board.php?cid=$cat'>Return to menu</a>";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10199-why-wont-this-code-work/ Share on other sites More sharing options...
cyberRobot Posted May 22, 2006 Share Posted May 22, 2006 In your form tag, don't you need the action attribute:[code]<form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>">...[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10199-why-wont-this-code-work/#findComment-38012 Share on other sites More sharing options...
legohead6 Posted May 22, 2006 Author Share Posted May 22, 2006 no, i dont think so....ive done many forms and left it out.... Quote Link to comment https://forums.phpfreaks.com/topic/10199-why-wont-this-code-work/#findComment-38035 Share on other sites More sharing options...
.josh Posted May 22, 2006 Share Posted May 22, 2006 $query = "INSERT INTO messages VALUES ('','$user','$subj','$mes','$em','$cat')";mysql_query($query) [b]or die(mysql_error();[/b]add that and post what it says. but also, you need to do likeinsert into messages ('column','column','column') values ('blah','blah','blah')the correct column for the variable. the only columns you can omit are the ones that a value is auto inserted upon insertion, like timestamps or auto_incremented primary keys Quote Link to comment https://forums.phpfreaks.com/topic/10199-why-wont-this-code-work/#findComment-38041 Share on other sites More sharing options...
legohead6 Posted May 22, 2006 Author Share Posted May 22, 2006 [!--quoteo(post=376130:date=May 22 2006, 03:18 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 22 2006, 03:18 PM) [snapback]376130[/snapback][/div][div class=\'quotemain\'][!--quotec--]$query = "INSERT INTO messages VALUES ('','$user','$subj','$mes','$em','$cat')";mysql_query($query) [b]or die(mysql_error();[/b]add that and post what it says. but also, you need to do likeinsert into messages ('column','column','column') values ('blah','blah','blah')the correct column for the variable. the only columns you can omit are the ones that a value is auto inserted upon insertion, like timestamps or auto_incremented primary keys[/quote]The field left blank in auto_incrementYou have an error in your SQL syntax near '2'>Original Message By adminKnow you can change your own informat' at line 1[!--quoteo(post=376138:date=May 22 2006, 03:24 PM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 22 2006, 03:24 PM) [snapback]376138[/snapback][/div][div class=\'quotemain\'][!--quotec--]The field left blank in auto_incrementYou have an error in your SQL syntax near '2'>Original Message By adminKnow you can change your own informat' at line 1[/quote]o there we go! i fixed it! thats wierd! I though you could put singal quotes inside doubles...but it works without them! ThanksMAtt Quote Link to comment https://forums.phpfreaks.com/topic/10199-why-wont-this-code-work/#findComment-38049 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.