Page 1 of 1

updating records

Posted: Thu Jun 14, 2007 10:25 am
by pleigh
hi, im having a problem and need some help from you guys, i have this code.

Code: Select all

<?php
		  			$ed = $_GET['eid'];
		  		
		  			if (isset($_POST['submit'])) {
		  				$error = null;
		  				
		  				if (empty($_POST['text_edit'])) {
		  					$e = false;
		  					$error = "cannot be blank";
		  				} else {
		  					$e = $_POST['text_edit'];
		  				}
		  				
		  				
		  				
		  				if (!$e) {
		  					
		  					$squery = "SELECT RightsDesc FROM hh_Rights WHERE RightsKey='" . $ed . "'";
		  					$sresult = mysql_query($squery) or die(mysql_error());
		  					
		  					if ($sresult) {
		  						
		  						
		  						$query = "UPDATE hh_Rights SET RightsDesc='" . $e . "' WHERE RightsKey='" . $ed . "'";
								$result = @mysql_query($query) or die(mysql_error());
								if (mysql_affected_rows() == 1) {
									echo "nagedit";
								} else {
									echo "nde nagedit";
								}
		  					}
		  					
		  					
		  				} else {
		  					echo "system error.<br>";
		  				}
		  			}
?>
the $ed is getting its value from another page which has this code

Code: Select all

$query = "SELECT RightsKey, RightsDesc FROM hh_Rights";
				$result = mysql_query($query) or die(mysql_error());
				if (mysql_num_rows($result) > 0) {
					while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
						echo "
							<tr>
								<td width='85%'>". $row[1] . "</td>
								<td width='15%' align='center'><a href='edit-rights.php?eid=" . $row[0] ."'>Edit</a></td>
							</tr>
						";
					}
				}
now, when i try to move my mouse pointer over the link, it will reflect the eid value...the problem is that, the getting page do not get its value. and also, i was thinking why is it that the if (isset($_POST['submit'])) part of my page is not setting and finishes the code block without doing anything.

thank you.

Posted: Thu Jun 14, 2007 3:53 pm
by RobertGonzalez
$_GET is a querystring array (link.php?qs=val1&qss=val2). $_POST is the array made by form data.

Posted: Thu Jun 14, 2007 9:23 pm
by pleigh
thanks. but whats your point?

Posted: Thu Jun 14, 2007 10:45 pm
by feyd
Look at your original post again... You're clicking a text link. $_POST has no values when you simply go to a link.

Posted: Fri Jun 15, 2007 10:58 am
by RobertGonzalez
pleigh wrote:thanks. but whats your point?
My point is look at your code. See all the references to $_POST. How can there be one when there is no form?

But if your only question in all that code is why:

Code: Select all

<?php
$ed = $_GET['eid'];
?>
Is not working, the answer is... I don't know. We would need to see more code since there is nothing in your code that would suggest it is not setting.