2007. 03. 7, szerda keltezéssel 16.28-kor Delta Storm ezt írta:
> [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]>
> >> To: [email protected]
> >> 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:[EMAIL PROTECTED]>.
>
>
> 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))
> {
you don't need that if above, as the while loop will not start at all if
there is no rows in the result
> if (!$_POST["submit"])
> {
> echo '<table border="0" cellspacing="0" cellpadding="0"
> align="center">';
> echo "<tr>";
> echo '<td colspan="2">';
> echo "<form action='<?php echo
> $_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']);
why are you putting those $_POST values in brackets?
it should be
$title = $_POST['title'];
btw, you should check those values before passing them to the database
because of security reasons
>
> $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());
here you don't need $result I think, you could just use
mysql_query($query) or die ("could not process query : $query" .
mysql_error());
>
> if ($result)
> {
and you don't have to check for $result, as the die statement would
cause your script to stop executing if there was an error, so if it gets
here you might just print out "everything is ok"
> echo "Data updated succesfully";
> echo '<a href="edititems.php">Povratak na
> editiranje</a>';
> }
> else
> {
> echo "Data update FAILED";
> }
and this "else" part is also totally useless, as it never gets here. it
there is an error it dies right at the query, otherwise it is successful
> mysql_close($link);
> }
> }
> }
>
> ?>
> </body>
> </html>
>
hope I could help
Zoltán Németh
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php