Re: Textarea update problem

From: Date: Wed, 07 Mar 2007 17:07:21 +0000
Subject: Re: Textarea update problem
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-250013@lists.php.net to get a copy of this message
Delta Storm wrote:
replies-lists-a1z2-php@listmail.innovate.net wrote:
is there a question here, or are you asking us to write the script for you? - Rick ------------ Original Message ------------
Date: Wednesday, March 07, 2007 01:54:04 PM +0100 From: Delta Storm <delta.storm@hi.t-com.hr> To: php-general@lists.php.net Subject: [PHP] Textarea update problem Hi, I'd like to thank everybody who have helped me till now. All your advices were very helpfull... :) But I have a problem again I need to build a script which will have have the following functions: 1.Be able to select 3 columns from a MySQL database(idnetify the columns by ID) and put the column contents into 3 textarea objects. (for example title,Text1,Text2 each into i textarea). 2.Edit and MySQL update the textarea contents And all in one script. The script has a $id = $_GET['id'] variable which holds the information about the certain table id.
    
---------- End Original Message ----------
This is the script, I have dealt with both problems but when I click on the update button (submit button) i get an error msg: Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server. If you think this is a server error, please contact the webmaster <mailto:admin@localhost>. Error 403 localhost </> 03/07/07 16:17:37 Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8d mod_autoindex_color PHP/5.2.0 The user name and pass for the MySQL server are 100% correct. It reads out the data from the database into the textarea object but when I click the update button I get that msg. Thank you! :) <!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" lang="hr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Language" content="hr"> <title>UPDATE news and article items</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php $id = $_GET['id']; include("authenticate.php"); $link = mysql_connect("localhost","$admin","$pass") or die ("Could not connect to database"); mysql_select_db("europe") or die ("Could not select database"); mysql_query("set names utf8"); $selResult = mysql_query("select title,sText,fText from news where id='$id'"); if (mysql_num_rows($selResult) > 0) {
       while ($row = mysql_fetch_array($selResult))
       {
           if (!$_POST["submit"])
           {
           echo '<table border="0" cellspacing="0" cellpadding="0"
align="center">';
               echo "<tr>";
                   echo '<td colspan="2">';
You can't do this.... You are inside a php echo statement already. Then you are trying to break into php from html
                       echo "<form action='<?php echo
$_SERVER[PHP_SELF] ?>' method=post>";
Not sure what error level you are set to but you should have quotes around PHP_SELF I see it everywhere else, maybe you missed this one. ie: $_SERVER['PHP_SELF']; Previous line should read: echo "<form action='{$_SERVER['PHP_SELF']}' method=post>";
                       echo "<input type=text size=180 name=title
value=" . $row['title'] .">";
                   echo "</td>";
               echo "</tr>";
               echo "<tr>";
                   echo "<td>";
                       echo "<h2>sText</h2>";
                       echo '<textarea cols="65" rows="30" name="sText">';
                       echo $row['sText'];
                       echo "</textarea>";
                   echo '</td>
                   <td>
                       <h2>fText</h2>
                       <textarea cols="65" rows="30" name="fText" >';
                       echo $row['fText'];
                       echo '</textarea>
                   </td>
               </tr>
               <tr>
                   <td colspan="2" align="center">
                       <input type="submit" value="UPDATE" name="submit">
                       </form>
                   </td>
               </tr>
       </table>';
           }
           else
           {
               $title = ($_POST['title']);
               $sText = ($_POST['sText']);
               $fText = ($_POST['fText']);
               $query = "update news set title='$title',
sText='$sText', fText='$fText' where id='$id'";
               $result = mysql_query($query) or die ("could not process
query : $query" . mysql_error());
               if ($result)
               {
                   echo "Data updated succesfully";
                   echo '<a href="edititems.php">Povratak na
editiranje</a>';
               }
               else
               {
                   echo "Data update FAILED";
               }
               mysql_close($link);
           }
       }
} ?> </body> </html>
-- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush

« previous php.general (#250013) next »