updating records

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

updating records

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

$_GET is a querystring array (link.php?qs=val1&qss=val2). $_POST is the array made by form data.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

thanks. but whats your point?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Post Reply