
April 24th, 2004, 03:57 AM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 9
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
php/mysql (update table)
Problem is, if you try to update, only numbers are applyed. If I want to save words or single letters or numbers/letters mixed, it doesn't work.
I don't know what the problem is. Any of you maybe?
full code:
Code:
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
// - connecting and getting information -
$link = mysql_connect("server", "user", "password") or die("Could not connect: " . mysql_error());
mysql_select_db('radar', $link) or die ('Can\'t connect to database: ' . mysql_error());
$query = mysql_query("SELECT * FROM `test`") or die ('<h3>Some error');
while ($data = mysql_fetch_array($query)){
$header = $data['header'];
}
?>
<!-- start of the HTML FORM part -->
<form ENCTYPE="multipart/form-data" action='<? echo"$php_self"; ?>' method="post">
<input type="text" name="name" size="50" <?echo "value='$header'";?>><br>
<button type="submit">save</button>
</form>
<?
// - PHP updating part -
$header = $_REQUEST['name'];
$sql = "UPDATE `test` SET `header` = $header ";
$result = mysql_query($sql);
if ($result){echo "updated <br>";}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo "<meta http-equiv='refresh' content='1;URL=$PHP_SELF'>";
}
?>
</body></html>
here is the url it is running atm: http://www.folklore.ee/radar/test/xxx.php
Database is MySQL. The row "test" has type "text".
Any suggestions/help is welcome. Thanks.

|