Jump to content

Recommended Posts

Hi please will you help me? Why will this code not work! I got it from a book, ive checked n double checkd it and i am lost I just dont know what else to try

display form

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Update</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p> </p><form name="memberediting" method="post"
action "update.php">
  <table width="250" border="0" align="center" cellpadding="3">
    <tr>
      <td colspan="2" bgcolor="#dddddd">
        <div align="center"><b>Update Personal Information</b></div>
      </td>
     </tr>
<?php
connect database
$connection= mysql_connect($host,$uname,$pass)
or die("Database connection failed! <br>");
$result=mysql_select_db($database)
or die("Database could not be selected");
$query = "SELECT * from week9 where username='" .$username ."'";
$result = mysql_query($query);
if($row=mysql_fetch_array($result))
{
echo "<tr bgcolor=\"#eeeeee\"> ";
echo " <td width=\"100\" bgcolor=\"#eeeeee\"> ";
echo " <div align=\"right\">password </div>";
echo " </td>";
echo " <td width=\"150\"> ";
echo " <input type=\"text\" name=\"password\" value=\"",$row["password"]."\" >";
echo " </td>";
echo " </tr>";
echo " <tr bgcolor=\"#eeeeee\"> ";
echo " <td width=\"100\" bgcolor=\"#eeeeee\"> ";
echo " <div align=\"right\">E-mail</div>";
echo " </td>";
echo " <td width=\"150\"> ";
echo " <input type=\"text\" name=\"email\" value=\"",$row["email"]."\" >";
echo " </td>";
echo " </tr>";
echo " <tr bgcolor=\"#eeeeee\"> ";
echo " <td width=\"100\" bgcolor=\"#eeeeee\"> ";
echo " <div align=\"right\">Username</div>";
echo " </td>";
echo " <td width=\"150\"> ";
echo "<input type=\"text\" name=\"username\" value=\"".$row["username"]."\" >";
echo "     </td>";
echo "   </tr>";
echo "   <tr>";
echo " 		<td colspan=\"2\" bgcolor=\"#dddddd\"> ";
echo "			<div align=\"center\"> ";
echo " 				<input type=\"submit\" name=\"Submit\" value=\"Submit\">";
echo " 			</div>";
echo "		</td>";
echo " </tr>";
}
?>
	</table>
</form>          
</body>
</html>

 

Update


$connection= mysql_connect ($host,$uname,$pass)
or die("Database connection failed! <br>");
$result=mysql_select_db ($database)
or die ("Database could not be selected");
$query = "UPDATE week9 SET password=\"". $password . "\" , email=\"". $email . "\" where username=\"".$username."\"";
$result = mysql_query($query);
if (!$result)
{
die(" Query could not be executed.<br>");
}
else
{
echo "<table border=\"0\" align\"center\" cellspacing=\"1\" cellpadding=\"5\" width=\"300\">";
echo "  <tr> ";
echo "    <td colspan=\"2\" bgcolor=\"#dddddd\"> ";
echo "		<center><b> ".mysql_affected_rows()." record updated successfully</b></center>";
echo "	  </td>";
echo "  </tr>";
echo "  <tr bgcolor=\"#eeeeee\"> ";
echo "	 <td width=\"100\" bgcolor=\"#eeeeee\"> ";
echo "		<div align=\"right\">Name<\div>";
echo "	 </td> ";
echo "	 <td width=\"200\">".$username. "<\td>";
echo " </tr>";
echo " <tr bgcolor=\"#eeeeee\"> ";
echo "	 <td width=\"100\" bgcolor=\"#eeeeee\"> ";
echo "		<div align=\"right\">E-mail</div>";
echo "	 </td> ";
echo "	 <td width=\"200\">".$Email. "</td>";
echo "  </tr>";
echo "  <tr bgcolor=\"#eeeeee\"> ";
echo "	  <td width=\"100\" bgcolor=\"#eeeeee\"> ";
echo "		<div align=\"right\">password</div>";
echo " 	  </td>";
echo "	  <td width=\"200\">".$password. "</td>";
echo "  </tr>";
echo "  <tr> ";
echo "	  <td colspan=\"2\" bgcolor=\"#dddddd\"> </td>";
echo "  </tr>";
echo "</table>";
}
?>

 

Edit

<title>Edit Membership</title>
</head>

<body>

<form name="updateform" method="post" action="displayform.php">
<table width="250" border="0" align="center" cellpadding="3">
	<tr>
        	<td colspan="2" bgcolor="#dddddd" height="23">
            	<center><b>Enter your username</b></center>
            </td>
        </tr>
        <tr bgcolor="#eeeeee">
        	<td width="100" bgcolor="#eeeeee">
            	<center>username</center>
            </td>
            <td width="150">
            	<input type="text" name="username">
            </td>
        </tr>
        <tr>
        	<td colspan="2" bgcolor="#dddddd">
            	<center>
                	<input type="submit" name="Submit" value="Submit">
                </center>
            </td>
        </tr>
     </table>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/84354-help-damm-code/
Share on other sites

look at the database connection ( ,$agin)or die(mysql_error());

 

 

connect database
$connection= mysql_connect($host,$uname,$pass)
or die("Database connection failed! <br>");
$result=mysql_select_db($database)
or die("Database could not be selected");

 

corrected

<?php
connect database
$connection= mysql_connect($host,$uname,$pass)
or die("Database connection failed! <br>");
$result=mysql_select_db($database,$connection)
or die("Database could not be selected");
?>

Link to comment
https://forums.phpfreaks.com/topic/84354-help-damm-code/#findComment-429645
Share on other sites

If the first piece of code is the exact contents of the file, it contains a fatal parse error and won't execute.

 

Parse error: syntax error, unexpected T_STRING in ...\yourfile.php on line 17

 

When learning php, developing php code, or debugging php code, check your web server log file for errors or turn on full php error reporting in php.ini or a .htaccess file to get php to help you out (turning on full php error reporting in your script won't help you find fatal parse errors.)

Link to comment
https://forums.phpfreaks.com/topic/84354-help-damm-code/#findComment-429669
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.