שאלה, מה הבעיה בקוד?

Godamit

New member
שאלה, מה הבעיה בקוד?

בדף הזה אני רוצה לקלוט מידע כמו שם ולינקים, ולהוסיף אותם לטבלה קיימת במסד נתונים ששמה works. <html> <body link="yellow" vlink="yellow" bgcolor=32CD32> <center> <form name="form1"> <table border="1"> <tr> <td><input type="text" name="text1" size="25" value="<?=$_POST["text1"]; ?>"></td> <td>הכנס מספר תמונה</td> </tr> <tr> <td><input type="text" name="text2" size="25" value="<?=$_POST["text2"]; ?>"></td> <td>הכנס שם תמונה</td> </tr> <tr> <td><input type="text" name="text3" size="25" value="<?=$_POST["text3"]; ?>"></td> <td>הכנס קישור לתמונה</td> </tr> <tr> <td><input type="text" name="text4" size="25" value="<?=$_POST["text4"]; ?>"></td> <td>הכנס תמונה מוגדלת</td> </tr> <tr> <td><input type="text" name="text5" size="25" value="<?=$_POST["text5"]; ?>"></td> <td>הכנס מחיר</td> </tr> <TD align="right"><INPUT type="SUBMIT" name="insert_button" value=" הכנס נתונים "></TD> <TD align="left"><INPUT type="RESET" value="נקה טופס"></TD> </table></center> <?php if (isset($_POST["insert_button"])) { $id_work=$_POST["text1"]; $name=$_POST["text2"]; $picture=$_POST["text3"]; $big_picture=$_POST["text4"]; $price=$_POST["text5"]; $host="localhost"; $user="******"; $password="******"; $db="******"; $con=@mysql_connect($host,$user,$password); @mysql_select_db($db); $sqlquery="INSERT INTO works (id_work,name,picture,big_picture,price) VALUES ( '$id_work','$name','$picture','$big_picture','$price')"; $theresult=@mysql_query($sqlquery,$con); } ?> בבקשה עזרה?
 

itaym02

New member
שרות לתפוזן המתחיל

<html> <body link="yellow" vlink="yellow" bgcolor=32CD32> <center> <form name="form1"> <table border="1"> <tr> <td><input type="text" name="text1" size="25" value="<?=$_POST["text1"]; ?>"></td> <td>הכנס מספר תמונה</td> </tr> <tr> <td><input type="text" name="text2" size="25" value="<?=$_POST["text2"]; ?>"></td> <td>הכנס שם תמונה</td> </tr> <tr> <td><input type="text" name="text3" size="25" value="<?=$_POST["text3"]; ?>"></td> <td>הכנס קישור לתמונה</td> </tr> <tr> <td><input type="text" name="text4" size="25" value="<?=$_POST["text4"]; ?>"></td> <td>הכנס תמונה מוגדלת</td> </tr> <tr> <td><input type="text" name="text5" size="25" value="<?=$_POST["text5"]; ?>"></td> <td>הכנס מחיר</td> </tr> <TD align="right"><INPUT type="SUBMIT" name="insert_button" value=" הכנס נתונים "></TD> <TD align="left"><INPUT type="RESET" value="נקה טופס"></TD> </table></center> <?php if (isset($_POST["insert_button"])) { $id_work=$_POST["text1"]; $name=$_POST["text2"]; $picture=$_POST["text3"]; $big_picture=$_POST["text4"]; $price=$_POST["text5"]; $host="localhost"; $user="******"; $password="******"; $db="******"; $con=@mysql_connect($host,$user,$password); @mysql_select_db($db); $sqlquery="INSERT INTO works (id_work,name,picture,big_picture,price) VALUES ( '$id_work','$name','$picture','$big_picture','$price')"; $theresult=@mysql_query($sqlquery,$con); } ?>​
 

itaym02

New member
The code looks fine

למרות שהוא מיושן משהו. אתה תסלח לי, אך בניתוח המוח האחרון שעברתי פגעו לי ביכולות הESP שלי. הודעת שגיאה, או הסבר למה אתה חושב שהקוד לא תקין, מאוד יעזרו לנו לעזור לך.
 

Godamit

New member
הסיבה למה אני חושב שזה לא תקין מאוד פשוטה

המידע לא מתווסף לMySql אני מזין את הנתונים בטופס ולוחץ על כפתור הסומביט..אבל שום דבר לא קורה.. לא רשום שגיאה או משהו. וזה מיושן משהו כי אני פרמיטיבי פה
 

maornet

New member
תנסה ככה:

$sqlquery="INSERT INTO `works` (`id_work`,`name`,`picture`,`big_picture`,`price`) VALUES ( '$id_work','$name','$picture','$big_picture','$price')"; $theresult=mysql_query($sqlquery,$con) or die(mysql_error()); אם זה מביא לך שגיאה תכתוב אותה פה
 
תדפיס את השאילתא עם echo

ותריץ אותה ישירות ב-mysql ואז תגלה את השגיאה האפשרית.
 
אגב, אתה עובד בשיטת GET ולא בPOST

אתה צריך להגדיר זאת בטופס שלך או לשנות את הגישה לנתונים ככה שיהיו דרך GET...
 
למעלה