Page 1 of 1

problem updating <TEXTAREA>

Posted: Mon Apr 02, 2007 1:39 pm
by franknu
ok i have a problem with <textarea> because it is not holding the values

once i submit the info it just clear the value box which delete everything in that field in the database

here is my code

Code: Select all

$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= ('$_POST[BusinessName]'), `Slogan`=('$_POST[$Slogan]'),
               Business_Address = ('$_POST[Business_Address]'), Tel=('$_POST[Tel]'), Website= ('$_POST[Website]'),
               Email = ('$_POST[Email]'), Fax= ('$_POST[Fax]'), `type`='$type',
               make = '$make', Categories = ('$_POST[Categories]'), Keyword = ('$_POST[Keyword]'),  Picture1 = ('$_POST[Picture1]'),
               Headline = ('$_POST[Headline]'), Slogan2 = ('$_POST[Slogan2]'), Description1 = ('$_POST[Description1]'),
               Description2 = ('$POST[Description2]'), Description3 =  ('$_POST[Description3]'),
               Picture2 = ('$_POST[Picture2]'), Picture3 = ('$_POST[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"enctype="multipart/form-data">';

 



 echo"<tr>";

echo"<td> Busiess Info </td></tr><tr>
    <td>
    <table>
        <tr>
          <td>
          Business Name
          </td>
          <td>";

echo"<input type='text' name='BusinessName'  Value=('$_POST[BusinessName]'> </td>
</tr> <tr> <td> Slogan </td>        <td>";

echo"<input type='text' NAME='Slogan' value=('$_POST[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
          </td>
          <td>";
echo" <input type='text' name='Business_Address' value='$Business_Address'>";

           echo"</td>
       </tr>
      </table>
      </td>
  </tr>
  <tr>
    <td>
	<table>
        <tr>  <td>  </td>  <td>
          </td>  <td></td><td> </td><td>
         Category
          </td>

          <td>";



echo '<textarea ROWS=5 COLS=65  NAME="Categories">' . $_POST['Catagories'] . '</textarea>';



        echo" </td>

       </tr>
      </table>
	  <table>
        <tr>
          <td>
         Business  Webpage
          </td>
        </tr>
        <tr>
          <td>
          Headline
         </td>
        </tr>
        <tr>
          <td>";
echo" <input type='text' name='Headline' value=('$_POST[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=('$_POST[Slogan2]')>"
;
        echo"  </td>
      </tr>
        <tr>
                      <td>   Description </td>
        </tr>
        <tr>
          <td>";
         echo" <TEXTAREA ROWS=5 COLS=65 NAME='Description1' value=('$_POST[Description1]')>$Description1 </TEXTAREA> ";
          echo"</td>
       </tr>
        <tr>
         <td>
          Description2
          </td>
       </tr>
        <tr>
          <td>";
          echo"<TEXTAREA ROWS=5 COLS=65 NAME='Description2' value='$Description2'>$Description2</TEXTAREA>";
          echo"</td>
        </tr>
        <tr>
          <td>
          Description3
         </td>
        </tr>
        <tr>
         <td>";
echo"<TEXTAREA ROWS=5 COLS=65 NAME='Description3' value='$Description3'>$Description3</TEXTAREA>";
         echo"</td>
        </tr>

       <tr>
          <td>

        <table>";

echo"<table>";
echo"<tr>
<td>";   

   echo" Picture1";
		  echo" <input name='Picture1' type='file' value=''></td>
<td> <img src='dfdfd.jpg'></td>";
echo"</tr>";

echo"<tr>
<td>";   

   echo" Picture2";
		  echo" <input name='Picture2' type='file' value=''></td>
<td> <img src='dfdfd.jpg'></td>";
echo"</tr>";


echo"<tr>
<td>";   

   echo" Picture3";
		  echo" <input name='Picture3' type='file' value=''></td>
<td> <img src='dfdfd.jpg'></td>";
echo"</tr>";
echo"<tr>
<td>";   

   echo" Picture4";
		  echo" <input name='Picture4' type='file' value=''></td>
<td> <img src='dfdfd.jpg'></td>";
echo"</tr>";
echo"<tr>
<td>";   

   echo" Picture5";
		  echo" <input name='Picture5' type='file' value=''></td>
<td> <img src='dfdfd.jpg'></td>";
echo"</tr>";
echo"<tr>
<td>";   

   echo" Picture6";
		  echo" <input name='Picture6' type='file' value=''></td>
<td> <img src='dfdfd.jpg'></td>";
echo"</tr>";
echo"<tr>
<td>";   

   echo" Video";
		  echo" <input name='video' type='file' value=''></td>
<td> <img src='dfdfd.jpg'></td>";
echo"</tr>";
echo"<tr>
<td>";   

   echo"Sound";
		  echo" <input name='sound' type='file' value=''></td>
<td> <img src='dfdfd.jpg'></td>";

Posted: Mon Apr 02, 2007 2:19 pm
by andym01480
Couple of problems I can see...

1) Are the initial values in the form meant to be the result of your select query?
If so they should be

Code: Select all

$res['value']
...
2) There is an error in the database update query

Code: Select all

Description2 = ('$POST[Description2]'),
should be $_POST.
Other folk will point out that it should be

Code: Select all

$_POST['description']
- single quotes around the associative array keys.
{} around the

Code: Select all

$_POST['description']
will help too.
3)

Code: Select all

$_POST['categories']
would be better than

Code: Select all

$_POST[catagories]
for the text area!

edited

4)

Code: Select all

echo" <TEXTAREA ROWS=5 COLS=65 NAME='Description1' value=('$_POST[Description1]')>$Description1 </TEXTAREA> ";
Textarea doesn't have a VALUE attribute

Posted: Mon Apr 02, 2007 6:45 pm
by RobertGonzalez
You spelled categories wrong in your code. You have $_POST['catagories'].

EDIT | Now that I look at it, your query is not all that clean. I think you need to ditch the parens. Also, is there a reason you are echoing so much? Why not use actual markup and intersperse PHP into it as needed?

Posted: Mon Apr 02, 2007 9:26 pm
by feyd
$_POST[$Slogan] may be a problem too.