הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   מה הבעיה עם הקוד? (https://hosts.co.il/forums/showthread.php?t=16915)

Cool_DuDu 01-03-06 16:03

מה הבעיה עם הקוד?
 
מה הבעיה בקוד הבא?

ציטוט:

<?php
mysql_connect("localhost","root","") or die("Error!");
mysql_select_db("try") or die("Error");

mysql_query("UPDATE text SET text='$_POST[text]'");
?>

<html dir="rtl">
<head><title>Main Page</title></head>
<body>
<center><b>Main Page</b></center>
<method="post">
<textarea cols=50 rows=10 name="text"></textarea><br />
<input type="submit" name="submit" value="עדכן">
</form>
<META HTTP-EQUIV="Refresh" CONTENT="2; URL=/next/admin/">
</body>
</html>


זה הארור שמוצג לי:
Notice: Undefined index: text in c:\program files\easyphp1-8\www\next\admin\main.php on line 5

Tomer 01-03-06 16:28

PHP קוד:

<?php
error_reporting
(0);
mysql_connect("localhost","root","") or die("Error!"); 
mysql_select_db("try") or die("Error"); 

$text $_POST['text'];
mysql_query("UPDATE text SET text='$text'");
?>

<html dir="rtl"> 
<head><title>Main Page</title></head> 
<body> 
<center><b>Main Page</b></center>
<method="post"> 
<textarea cols=50 rows=10 name="text"></textarea><br />
<input type="submit" name="submit" value="עדכן"> 
</form> 
<META HTTP-EQUIV="Refresh" CONTENT="2; URL=/next/admin/">
</body> 
</html>

והסבר קטן - קבעתי את המשתנה $text שיעקוב אחרי ה POST, ובתחילת העמוד הוספתי error_reporting(0); כדי לבטל Notices / Errors / Warnings.

Cool_DuDu 02-03-06 14:21

תודה תומרר

meshuga 02-03-06 14:23

סודר-ננעל


כל הזמנים הם GMT +2. הזמן כעת הוא 12:49.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ