graham23s Posted May 16, 2007 Share Posted May 16, 2007 Hi Guys, i have written this script: <?php ## Begin isset ################################################################### if(isset($_POST['submit'])) { // POST variables...////////////////////////////////////////////////////////////// $add_comment = stripslashes($_POST['add_comment']); // Grab the POST variables...///////////////////////////////////////////////////// $query3 = "INSERT INTO `comments` (`user_id`,`profile_id`,`date_added`,``) VALUES ('$log_in_users_id','$profile_id',now(),'$add_comment')"; // get the logged in users id...//////////////////////////////////////////////////// $query1 = "SELECT * FROM `membership` WHERE `username`='$member'"; $result1 = mysql_query($query1) or die (mysql_error()); $row = mysql_fetch_array($result1) or die (mysql_error()); // get the logged in users id...////////////////////////////////////////////////// $log_in_users_id = $row['id']; ## Top ########################################################################### } else { ## Bottom ######################################################################## // get the nzb id...////////////////////////////////////////////////////////////// $special_id = $_GET['id']; // get the nzb name...//////////////////////////////////////////////////////////// $query2 = "SELECT * FROM `profiles` WHERE `id`='$profile_id'"; $result2 = mysql_query($query2) or die (mysql_error()); $rows = mysql_fetch_array($result2) or die (mysql_error()); // get the profile name...//////////////////////////////////////////////////////// $profile = $rows['profile']; echo "<br /><p>Add A Comment For</p><center><h3>($profile)</h3></center><br />"; // make a table...////////////////////////////////////////////////////////////////// echo '<table width="500" border="1" bordercolor="#000000" cellspaing="0" cellpadding="2" /> <form action="nzb_comment.php" method="POST" /> <tr> <td align="center" /><textarea name="add_comment" rows="10" cols="30"></textarea></td> </tr> <tr> <td align="center" /><input type="submit" name="submit" value="Add Comment!" /> </td> </tr> </table></form><br />'; ## end isset ##################################################################### } ?> it works great apart from the fact i can't get the "special_id" to post into mysql, i'm grabbing it from the previous page so i can't use POST is there anyway i can add the "special_id" into mysql at all? thanks as usual guys Graham Link to comment https://forums.phpfreaks.com/topic/51648-solved-problem-getting-id/ Share on other sites More sharing options...
SoulAssassin Posted May 16, 2007 Share Posted May 16, 2007 Your code is not even trying to INSERT the special_id. Trys this: <?php ## Begin isset ################################################################### if(isset($_POST['submit'])) { // POST variables...////////////////////////////////////////////////////////////// $add_comment = stripslashes($_POST['add_comment']); $special_id = $_POST['special_id']; echo "$special_id"; // Grab the POST variables...///////////////////////////////////////////////////// $query3 = "INSERT INTO `comments` (`user_id`,`profile_id`,`special_id`,`date_added`,``) VALUES ('$log_in_users_id','$profile_id', '$special_id', now(),'$add_comment')"; // get the logged in users id...//////////////////////////////////////////////////// $query1 = "SELECT * FROM `membership` WHERE `username`='$member'"; $result1 = mysql_query($query1) or die (mysql_error()); $row = mysql_fetch_array($result1) or die (mysql_error()); // get the logged in users id...////////////////////////////////////////////////// $log_in_users_id = $row['id']; ## Top ########################################################################### } else { ## Bottom ######################################################################## // get the nzb id...////////////////////////////////////////////////////////////// $special_id = $_GET['id']; echo "$special_id"; // get the nzb name...//////////////////////////////////////////////////////////// $query2 = "SELECT * FROM `profiles` WHERE `id`='$profile_id'"; $result2 = mysql_query($query2) or die (mysql_error()); $rows = mysql_fetch_array($result2) or die (mysql_error()); // get the profile name...//////////////////////////////////////////////////////// $profile = $rows['profile']; echo "<br /><p>Add A Comment For</p><center><h3>($profile)</h3></center><br />"; // make a table...////////////////////////////////////////////////////////////////// echo '<table width="500" border="1" bordercolor="#000000" cellspaing="0" cellpadding="2" /> <form action="nzb_comment.php" method="POST" /> <tr> <td align="center" /><textarea name="add_comment" rows="10" cols="30"></textarea></td> </tr> <tr> <input type="hidden" name="special_id" value="$special_id"> <td align="center" /><input type="submit" name="submit" value="Add Comment!" /> </td> </tr> </table></form><br />'; ## end isset ##################################################################### } ?> Link to comment https://forums.phpfreaks.com/topic/51648-solved-problem-getting-id/#findComment-254426 Share on other sites More sharing options...
graham23s Posted May 16, 2007 Author Share Posted May 16, 2007 thanks mate i stuck it in a hidden field. cheers Graham Link to comment https://forums.phpfreaks.com/topic/51648-solved-problem-getting-id/#findComment-254449 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.