wooowooo Posted January 3, 2008 Share Posted January 3, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/84354-help-damm-code/ Share on other sites More sharing options...
cooldude832 Posted January 3, 2008 Share Posted January 3, 2008 well maybe you can start by saying how it doesn't work does it not work like a farm animal refusing to plow a field? Quote Link to comment https://forums.phpfreaks.com/topic/84354-help-damm-code/#findComment-429640 Share on other sites More sharing options...
redarrow Posted January 3, 2008 Share Posted January 3, 2008 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"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/84354-help-damm-code/#findComment-429645 Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2008 Share Posted January 3, 2008 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.) Quote Link to comment https://forums.phpfreaks.com/topic/84354-help-damm-code/#findComment-429669 Share on other sites More sharing options...
wooowooo Posted January 3, 2008 Author Share Posted January 3, 2008 I have tried the change suggested, with $connection Basically the page displays to enter the user n then goes 2 the edit page but its doesnt check the user or pull up there information and display it. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/84354-help-damm-code/#findComment-429671 Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2008 Share Posted January 3, 2008 The second parameter in the mysql_select_db() function call is optional and has nothing to do with your code not working. Quote Link to comment https://forums.phpfreaks.com/topic/84354-help-damm-code/#findComment-429675 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.