contra10 Posted December 26, 2008 Share Posted December 26, 2008 i'm having trouble entering 2 values that are get values from another page heres my code <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['id'])){ $id = $_GET['id']; $insert1= "SELECT * FROM groups WHERE id = '$id'"; $topic1 = mysql_query($insert1) or die(mysql_error()); while ($topica = mysql_fetch_assoc($topic1)) { $grpname= "{$topica['name']}"; } } //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['name'] | !$_POST['note']) { die('You did not complete all of the required fields'); } // checks if the name is in use if (!get_magic_quotes_gpc()) { $_POST['name'] = ($_POST['name']); } $topiccheck = $_POST['name']; $check = mysql_query("SELECT notename FROM notes_groups WHERE notename = '$topiccheck'") or die(mysql_error()); $check2 = mysql_num_rows($check); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the topic '.$_POST['name'].' is already in use.'); } // this makes sure both name and group entered match if ($_POST['name'] == $_POST['note']) { die('Input a different name please. '); } $query2= "SELECT id FROM users WHERE username = '$username'"; $result2 = mysql_query($query2) or die(mysql_error());; $usera = mysql_fetch_assoc($result2); $userid = "{$usera['id']}"; $name = mysql_real_escape_string($_POST['name']); $note = mysql_real_escape_string($_POST['note']); $link = mysql_real_escape_string($_POST['link']); //This gets today's date $date = time () ; //This puts the day, month, and year in seperate variables $day = date('d', $date) ; $month = date('F', $date) ; $year = date('Y', $date) ; // now we insert it into the database $insert = "INSERT INTO notes_groups (gid, gname, uid, uname, notename, note, link, month, day, year) VALUES ('$id', '$grpname', '$userid', '$username', '$name', '$note', '$link', '$month', '$day', '$year')"; $add_group = mysql_query($insert) or die(mysql_error()); ?> the values $id and $grpname do not enter, but they are on the page as before i echoed thevalues on that same page. So i know that they are on the page Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 26, 2008 Share Posted December 26, 2008 How do you get to this script? Ken Quote Link to comment Share on other sites More sharing options...
gevans Posted December 26, 2008 Share Posted December 26, 2008 Where is the problem? where does it show and where doesn't it? do you get any errors? Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 26, 2008 Author Share Posted December 26, 2008 the script works fine its just that the values $id and $grpname don't enter into the database it shows 0 for the id and nothing for the grpname Quote Link to comment Share on other sites More sharing options...
gevans Posted December 26, 2008 Share Posted December 26, 2008 change this line $insert = "INSERT INTO notes_groups (gid, gname, uid, uname, notename, note, link, month, day, year) VALUES ('$id', '$grpname', '$userid', '$username', '$name', '$note', '$link', '$month', '$day', '$year')"; $add_group = mysql_query($insert) or die(mysql_error());] to $insert = "INSERT INTO notes_groups (gid, gname, uid, uname, notename, note, link, month, day, year) VALUES ('$id', '$grpname', '$userid', '$username', '$name', '$note', '$link', '$month', '$day', '$year')"; die($insert); $add_group = mysql_query($insert) or die(mysql_error()); and see what you get back Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 27, 2008 Author Share Posted December 27, 2008 I get INSERT INTO notes_groups (gid, gname, uid, uname, notename, note, link, month, day, year) VALUES ('', '', '2', 'asd', 'asdasd', 'asdsadas', '', 'December', '26', '2008') first 2 variables arn't entering Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 27, 2008 Author Share Posted December 27, 2008 my variables can be seen if i echo them Quote Link to comment Share on other sites More sharing options...
revraz Posted December 27, 2008 Share Posted December 27, 2008 Your post above is a echo, so they are not being set. my variables can be seen if i echo them Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 27, 2008 Author Share Posted December 27, 2008 i thought i set it when i said $grpname= "{$topica['name']}"; how should i change that Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 27, 2008 Author Share Posted December 27, 2008 also did i set it when i said $id = $_GET['id']; Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted December 27, 2008 Share Posted December 27, 2008 looks like these values are not even being passed - with all the $_POST in there it would seem you have neglected to correctly insert the values into the action attribute of the submittng form... - May I suggest you stick to one form of datatransfer and simply put these values in hidden fields within that form???? post back your form html as well as the code if you have investigated this aspect and are still having problems... PS http://www.pastebin.com can be really helpful in these situations.... 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.