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

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

dudu 23-02-06 11:17

בעיה בהוספת נתונים למסד.
 
זאת השגיאה שהוא מראה לי:
HTML קוד:

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 'reporter`='' `maf`='' `about`='4'' at line 1
זה הקוד:
HTML קוד:

$sql = "INSERT INTO books SET `bookname`='$bookname' `reporter`='$reporter' `maf`='$maf' `about`='$about'";
mysql_query($sql) or die(mysql_error());

אני לא מבין מה הבעיה .. תודה למי שיעזור.

OldMega 23-02-06 11:39

אתה מריץ את זה על המחשב?

dudu 23-02-06 12:58

על שרת רגיל...

DaNieLLL 23-02-06 14:03

מה אתה מנסה לעשות פה? לשנות נתונים או להכניס נתונים חדשים?
אם נתונים חדשים:

PHP קוד:

$sql "INSERT INTO `books`  (`bookname`, `reporter`, `maf`, `about`) VALUES ('$bookname' , '$reporter' , '$maf', '$about')";
mysql_query($sql) or die(mysql_error()); 

ואם עדכון נתונים:


PHP קוד:

$sql "UPDATE  books SET  `bookname`='$bookname'  and `reporter`='$reporter'  and `maf`='$maf' and `about`='$about'";
mysql_query($sql) or die(mysql_error()) 

רק לגבי זה אני לא בטוח אם צריך את הand או לא.

שקד 23-02-06 14:14

ציטוט:

נכתב במקור על ידי Pip
מה אתה מנסה לעשות פה? לשנות נתונים או להכניס נתונים חדשים?
אם נתונים חדשים:

PHP קוד:

$sql "INSERT INTO `books`  (`bookname`, `reporter`, `maf`, `about`) VALUES ('$bookname' , '$reporter' , '$maf', '$about')";
mysql_query($sql) or die(mysql_error()); 

ואם עדכון נתונים:


PHP קוד:

$sql "UPDATE  books SET  `bookname`='$bookname'  and `reporter`='$reporter'  and `maf`='$maf' and `about`='$about'";
mysql_query($sql) or die(mysql_error()) 

רק לגבי זה אני לא בטוח אם צריך את הand או לא.

או הכי טוב לעשות ככה
PHP קוד:

$sql mysql_query("INSERT INTO `books` (bookname,reporter,maf,about) VALUES
('$bookname','$reporter','$maf','$about')"
) or die (mysql_error()); 



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

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