franknu Posted March 23, 2007 Share Posted March 23, 2007 i need to know why this database is not updating, i am getting the text from the database but it is not updating here is my code <?php $db = mysql_connect($host, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); $Picture2 = (isset($_POST['Picture2']) ? $_POST['Picture2']:''); $Picture3 = (isset($_POST['Picture3']) ? $_POST['Picture3']:''); $Picture4 = (isset($_POST['Picture4']) ? $_POST['Picture4']:''); $User_Name = (isset($_POST['User_Name']) ? $_POST['User_Name']:''); $Password = (isset($_POST['Password']) ? $_POST['Password']: ''); $User_Name=strtolower($_POST['User_Name']); $Password=strtolower($_POST['Password']); $usercheck = mysql_query("SELECT * FROM business_info where User_Name='$User_Name' AND Password='$Password'",$db); $userrow = mysql_fetch_array($usercheck); $num_rows = mysql_num_rows($usercheck); $query = "SELECT * FROM business_info where User_Name='$User_Name' AND Password='$Password'"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $BusinessName= $row['BusinessName']; $Keyword = $row['Keyword']; $Picture1 = $row['Picture1']; $Headline = $row['Headline']; $Slogan =$row['Slogan']; $Slogan2 = $row['Slogan2']; $Description1 =$row['Description1']; $Description2 = $row['Description2']; $Description3= $row['Description3']; $Contact2 = $row['Contact2']; $Picture2 = $row['Picture2']; $Picture3 = $row['Picture3']; $Categories=$row['Categories']; $Business_Address= $row['Business_Address']; $make=$row['make']; $type=$row['type']; $Tel= $row['Tel']; $Website=$row['Website']; } if ($num_rows!=1) { print "<p><b>username and/or password not found. Try again?</b></p>"; } else { echo"<table border='0'>"; echo" <tr>"; echo "Welcome to the The member session<br> here you can update your webpage<br>"; //start here $query = "SELECT * FROM business_info WHERE `BusinessName`= '$BusinessName' AND `User_Name`='$User_Name'"; $result = mysql_query($query) or die (mysql_error()); $res2 = mysql_fetch_assoc($result); echo "$BusinessName"; if(isset($_GET['update'])) { $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 (mysql_error()); } echo"<table bgcolor='ffffff'>"; echo"<tr>"; echo"<td>"; echo"<table>"; echo"<tr>"; echo"</tr>"; echo"</table>"; echo"</td>"; echo"</tr>"; echo"<tr>"; echo"<td></td>"; echo"</tr>"; echo"<tr>"; echo"<td>"; echo"<table> "; echo" <tr>"; echo"<td>"; echo"<table bgcolor='ffffff '>"; echo" <tr>"; echo"<td>"; echo"<table>"; echo"<form action=\"{$_SERVER['PHP_SELF']}\" method='Post'>"; echo"<tr>"; echo"<td>"; echo"Address" ; echo"</td>"; echo"<td> <input type='text' name='Business_Address' value='$Business_Address'>"; echo" </td>"; echo" </tr>"; echo"</td>"; echo"<td>"; echo"Category"; echo"</td>"; echo"<td>"; echo" <TEXTAREA ROWS=5 COLS=65 NAME='Categories' value='$Categories'> $Categories </TEXTAREA>"; echo"</td>"; echo"</tr>"; echo"</table>"; echo"<table>"; echo"<tr>"; echo"<td>"; echo"Business Webpage"; echo"</td>"; echo"</tr>"; echo"<tr>"; echo"<td>"; echo"Headline"; echo"</td>"; echo"</tr>"; echo"<tr>"; echo" <td> <input type='text' name='Headline' value='$Headline'>"; echo" </td>"; echo"</tr>"; echo"<tr>"; echo"<td>"; echo"Slogan"; echo"</td>"; echo"</tr>"; echo"<tr>"; echo"<td> <input type='text' name='Slogan2' value='$Slogan2'>"; echo"</td>"; echo" </tr>"; echo"<tr>"; echo" <td>"; echo"Description1"; echo" </td>"; echo"</tr>"; echo"<tr>"; echo"<td>"; echo"<TEXTAREA ROWS=5 COLS=65 NAME='Description1' value='$Description1'>$Description1 </TEXTAREA> "; echo"</td>"; echo"</tr>"; echo"<tr>"; echo"<td>"; echo"User Name"; echo"</td>"; echo"<td> <input type='text' name='User_Name' value='$User_Name'>"; echo"</td>"; echo"<td>"; echo"Password"; echo"</td>"; echo"<td> <input type='text' name='Password' value='$Password'>"; echo"</td>"; echo"</tr>"; echo"</table>"; echo"</td>"; echo"</tr>"; echo"</table>"; echo" </td>"; echo"</tr>"; echo"<tr>"; echo"<td> <input type='submit' value='Update my database' name='update' /> <input type='reset' value='Reset fields' />"; echo"<td> "; echo"</form>"; echo"</table>"; echo"</td>"; echo"<td>"; echo"</td>"; echo" </tr>"; echo"</table>"; echo"</tr>"; echo"</table>"; } ?> thank u Quote Link to comment https://forums.phpfreaks.com/topic/44055-updating-database/ Share on other sites More sharing options...
DeathStar Posted March 23, 2007 Share Posted March 23, 2007 HI I cant read anything! Please put in [ code ] [ /code ] and why are you echo'ing each and every single line? Quote Link to comment https://forums.phpfreaks.com/topic/44055-updating-database/#findComment-213923 Share on other sites More sharing options...
franknu Posted March 23, 2007 Author Share Posted March 23, 2007 i echo every line because i was getting a parser error with out it so i decided to keep i tlike that i think that problem is here if(isset($_GET['update'])) { $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 (mysql_error()); } maybe i should change to submit any idea Quote Link to comment https://forums.phpfreaks.com/topic/44055-updating-database/#findComment-213929 Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 That or you know make it just one echo, not 50. Quote Link to comment https://forums.phpfreaks.com/topic/44055-updating-database/#findComment-213933 Share on other sites More sharing options...
DeathStar Posted March 23, 2007 Share Posted March 23, 2007 Please put in [ code ] [ /code ] Quote Link to comment https://forums.phpfreaks.com/topic/44055-updating-database/#findComment-213938 Share on other sites More sharing options...
cmgmyr Posted March 24, 2007 Share Posted March 24, 2007 simplify your query to only update 1 column...if that works move on to the next until you find the one that is giving you problems. Quote Link to comment https://forums.phpfreaks.com/topic/44055-updating-database/#findComment-213967 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.