אוקי חבר'ס, בזמן האחרון אני יותר מידי צריך אתכם אה?
חחח

אבל עזרתם לי מאוד עד עכשיו, כניראה שקצת קשה ללמוד את PHP לבד \-:
אז זה הקוד שלי לעדכן את השדות $title ו $news ב id מסויים..
PHP קוד:
if ($_GET['id']) {
$id = $_GET['id'];
$query = "SELECT * FROM table WHERE id=$id";
$result = mysql_query($query)
or die("Query failed: " . mysql_error());
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$title = $row['title'];
$news = $row['news'];
echo "<form action='?id=update&$id' method='post'>";
echo "<input type='text' name='title' size='70' maxlength='50' value=\"$title\"> <input type='submit' name='button' value='שלח'>
<br /><textarea rows='10' cols='100' name='news' onPaste='return checkArea(this)' onKeyPress='return checkArea(this)' onKeyUp='totalChars.innerText=this.value.length'>$news</textarea>
<br />
<span id=totalChars>0</span> מתוך 500 תווים";
echo "</form>";
}
}
else if ($_GET['id'] == "update&$id") {
$title = $_POST['title'];
$news = $_POST['news'];
$title = htmlspecialchars($title);
$news = htmlspecialchars($news);
$query = "UPDATE table SET title='$title' , news='$news' WHERE id='$id'";
$result = mysql_query($query)
or die("Query failed: ".mysql_error());
echo "<meta http-equiv=\"refresh\" content=\"0;url='$url'\" />";
}
כן, אולי זה לא הקוד הכי מקצועי שראיתם ואולי מעפן, אבל לומדים לאט לאט (:
אוקי בקיצור, כשאני לוחץ על הכפתור 'שלח' לעדכן את הנתונים הוא מחזיר לי שגיאה כזו:
PHP קוד:
Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'update' at line 1
למה זה קורה? מה לא טוב בקוד שלי?