franknu Posted March 31, 2007 Share Posted March 31, 2007 ok I want to update data from my database any idea here is my updating code $sql = "SELECT * FROM business_info WHERE BusinessName = '$BusinessName' AND User_Name = '$User_Name'"; $result = mysql_query($query) or die ("Problem with the query: <pre>$sql</pre><br>" . mysql_error()); $res2 = mysql_fetch_assoc($result); if(isset($_POST["submit"])) { $query="UPDATE business_info SET BusinessName= '$BusinessName', `Slogan`='$Slogan', Business_Address = '$Business_Address', Tel='$Tel', Website= '$Website', Email = '$Email', Fax= '$Fax', `type`='$type', make = '$make', Categories = '$Categories', Keyword = '$Keyword', Picture1 = '$Picture1', Headline = '$Headline', Slogan2 = '$Slogan2', Description1 = '$Description1', Description2 = '$Description2', Description3 = '$Description3', Picture2 = '$Picture2', Picture3 = '$Picture3', `Password`= '$Password' WHERE User_Name = '$User_Name'"; $result = mysql_query($query) or die ("Problem with the query: <pre>$query</pre><br>" . mysql_error()); } echo"<table bgcolor='ffffff'>"; echo"<tr><td> <table><tr> </tr> </table> </td></tr><tr><td></td> </tr><tr><td> <table> <tr> <td><table bgcolor='ffffff'> <tr> <td> <table> "; //208 echo '<form action="'. $_SERVER['PHP_SELF'].'" method="post">'; echo"<tr>"; echo"<td> Busiess Info </td></tr><tr> <td> <table> <tr> <td> Business Name </td> <td>"; echo"<input type='text' name='BusinessName' Value='$BusinessName'> </td> </tr> <tr> <td> Slogan </td> <td>"; echo"<input type='text' NAME='Slogan' value='$Slogan'>"; echo"</td> <td> Website </td> <td> <input type='text' name='Website' value='$Website'> </td>"; echo"</tr> <tr> <td> Tel </td> <td>"; echo"<input type='text' name='Tel' value='$Tel'>"; echo"</td>"; echo"<td> Key Words </td> <td>"; echo"<input type='text' name='Keyword' value='$Keyword'>"; echo"</td> </tr> <tr> <td> Fax </td> <td>"; echo"<input type='text' name='Fax' value='$fax'>"; echo"</td> <td> Address echo"<input type='submit' value='Update my database' name='submit' />"; echo" <input type='reset' value='Reset fields' />"; echo"<td> </form> i can pull all the data out my problem is that when i hit the submmit bottom it doesnt make the changes maybe i have to do something inside the value="$_POST'[variable'] please help please help Quote Link to comment Share on other sites More sharing options...
Hughesy1986 Posted March 31, 2007 Share Posted March 31, 2007 Are you sending the username value with the posted data? If you are not that is why they query is not working, use a hidden field like <input type="hidden" value="<?php echo $username; ?>" name="username" id="username"> Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 31, 2007 Share Posted March 31, 2007 @ Franknu: PLEASE use the code tags to wrap your php code so it displays properly. Hints: 1. the first three lines of what you posted are pointless 2. nothing will ever get into a database before you make a database connection AND select a database 3. before trying to enter data into the database, you need to abstract the POSTed values from the $_POST array. Perhaps it would help if you read one of the tutorials on the site about databases. Quote Link to comment Share on other sites More sharing options...
franknu Posted April 2, 2007 Author Share Posted April 2, 2007 i only added what i thought was relevant into about the database ok about the $_POST, can i get a sample line because i tried using many times and i was getting a parser error i guess it is maybe because i am echoing every single line 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.