helpmeplease2 Posted April 10, 2007 Share Posted April 10, 2007 Why doesn't this work? Is it because the $php_self doesn't work with pages like www.example.com?p=vgrgr&gerr=S&video=name if($_POST['submityes']=="yes"){ $name=$_POST['name']; $comment=$_POST['comment']; $query="INSERT INTO comments (Name,Comment) VALUES ('$name','$comment')"; mysql_query($query) or die('Could not query: ' . mysql_error()); }else{ echo "<form name=\"commentsform\" action=\"$PHP_SELF\" method=\"post\"> <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr><td>Name: </td><td><input type=\"text\" name=\"name\" size=\"30\"><br></td></tr> <tr><td>Comments: </td><td><textarea name=\"comment\" rows=\"6\" cols=\"40\" wrap=\"virtual\"></textarea></td></tr></table> <input type=\"hidden\" name=\"submityes\" value=\"yes\"> <input type=\"submit\" value=\"Add Comments\"></form>"; } Quote Link to comment Share on other sites More sharing options...
helpmeplease2 Posted April 11, 2007 Author Share Posted April 11, 2007 Anyone? Quote Link to comment Share on other sites More sharing options...
tippy_102 Posted April 11, 2007 Share Posted April 11, 2007 I tested it and it worked for me.....didn't test the INSERT though. What error are you getting? Also, you should clean the data before adding it to the database: $name= mysql_real_escape_string( $name ); Quote Link to comment Share on other sites More sharing options...
helpmeplease2 Posted April 11, 2007 Author Share Posted April 11, 2007 No error, it just doesn't work. Quote Link to comment Share on other sites More sharing options...
tippy_102 Posted April 11, 2007 Share Posted April 11, 2007 What part doesn't work? Quote Link to comment Share on other sites More sharing options...
fenway Posted April 11, 2007 Share Posted April 11, 2007 Also, why not have the HTML as HTML, and the php variables as PHP? The way you have it set up defeats the purpose... Quote Link to comment Share on other sites More sharing options...
helpmeplease2 Posted April 11, 2007 Author Share Posted April 11, 2007 It doesn't add it to the database. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 11, 2007 Share Posted April 11, 2007 Without an error? Quote Link to comment Share on other sites More sharing options...
helpmeplease2 Posted April 12, 2007 Author Share Posted April 12, 2007 Yup, no error. Quote Link to comment Share on other sites More sharing options...
rpadilla Posted April 12, 2007 Share Posted April 12, 2007 try inserting a marker in your insert statment, to make sure its really executed like mysql_query($query) or die('Could not query: ' . mysql_error()); echo 'my query was executed'; also try making some error codes, maybe error reporting is off. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 12, 2007 Share Posted April 12, 2007 Then post the query string sent to mysql. Quote Link to comment Share on other sites More sharing options...
helpmeplease2 Posted April 12, 2007 Author Share Posted April 12, 2007 It turns out it was inserting it, but not everything I wanted. I modified the code, but its still not inserting the Game and Video. The $gtitle and $vtitle are from the url. if($_POST['submityes']=="yes"){ $gtitle=$_GET['game']; $vtitle=$_GET['video']; $result = mysql_query("SELECT * FROM videos WHERE GTitle='$gtitle' AND VTitle='$vtitle'") or die(mysql_error()); while($row = mysql_fetch_row( $result )) { $name=$_POST['name']; $game=$row['GTitle']; $video=$row['VTitle']; $comment=$_POST['comment']; $query="INSERT INTO comments (Name,Game,Video,Comment) VALUES ('$name','$game','$video','$comment')"; mysql_query($query) or die('Could not query: ' . mysql_error()); } }else{ echo "<form name=\"commentsform\" action=\"$PHP_SELF\" method=\"post\"> <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr><td>Name: </td><td><input type=\"text\" name=\"name\" size=\"30\"><br></td></tr> <tr><td>Comments: </td><td><textarea name=\"comment\" rows=\"6\" cols=\"40\" wrap=\"virtual\"></textarea></td></tr></table> <input type=\"hidden\" name=\"submityes\" value=\"yes\"> <input type=\"submit\" value=\"Add Comments\"></form>"; } Quote Link to comment Share on other sites More sharing options...
fenway Posted April 12, 2007 Share Posted April 12, 2007 Sigh.... could you just post the echo of $query? I'm sure they're blank. Quote Link to comment Share on other sites More sharing options...
helpmeplease2 Posted April 12, 2007 Author Share Posted April 12, 2007 They are blank thats why I need your help. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 12, 2007 Share Posted April 12, 2007 Well, print out the $row hash. Quote Link to comment Share on other sites More sharing options...
helpmeplease2 Posted April 12, 2007 Author Share Posted April 12, 2007 Arghhh I was trying to do it the hard way! I could've just put $name=$_POST['name']; $game=$_GET['game']; $video=$_GET['video']; $comment=$_POST['comment']; $query="INSERT INTO comments (Name,Game,Video,Comment) VALUES ('$name','$game','$video','$comment')"; mysql_query($query) or die('Could not query: ' . mysql_error()); That is working, thanks for the help! 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.