הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

השב
 
כלים לאשכול תצורת הצגה
ישן 12-01-06, 18:27   # 1
SilverDragon
משתמש חדש
 
מיני פרופיל
תאריך הצטרפות: Jan 2006
הודעות: 3

SilverDragon לא מחובר  

תגידו, מה הבעיה עם הקוד הזה?

יש מסד נתונים, בתוכו יש טבלה vegetables עם העמודות NAME + NUMBER
אני רוצה שמשתמש יוכל להוסיף נתונים לטבלה.
1. יצרתי קובץ HTML כזה:
HTML קוד:
<form name="vege" action="db3-1.php" method="post">
<font face=arial> שם הירק <br>
<input name="name" type="text"> 
<br> <font face=arial> מספר המוצר <br>
<input name="number" type="text">
<input type="submit">
</form>
2. יצרתי קובץ PHP כזה:
PHP קוד:
<?PHP

$name 
$_POST['name'];

$number $_POST['number'];

mysql_connect("localhost","root") or die("cant connect: ".mysql_error());

mysql_select_db("aviv") or die("cant open DB: ".mysql_error());

$SQL "INSERT INTO `vegetables`('name','number') VALUES('$name','$number');";

mysql_query("$SQL")or die("cant query: ".mysql_error());

$SQLL "SELECT name FROM vegetables";
$res mysql_query($SQLL) or die("cant query:".mysql_error());
$rows mysql_num_rows($res);
echo 
"We got $rows rows back<BR>";
while(
$row mysql_fetch_assoc($res)) {
echo 
$row['name']."<BR>";
};
?>

וזה לא פועל כמובן.. :S

Last edited by SilverDragon; 12-01-06 at 18:30..
  Reply With Quote
ישן 12-01-06, 19:29   # 2
meshuga
הנהלת הפורום לשעבר
 
meshuga's Avatar
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
גיל: 35
הודעות: 7,601

meshuga לא מחובר  

אולי תשתף אותנו בשגיאה וגם נוכל לעזור.....
  Reply With Quote
ישן 12-01-06, 19:33   # 3
CSite.co.il
משתמש - היכל התהילה
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
הודעות: 1,816

CSite.co.il לא מחובר  

תנסה את זה:

PHP קוד:
<?PHP 

$name 
$_POST['name']; 

$number $_POST['number']; 

mysql_connect("localhost","root") or die("cant connect: ".mysql_error()); 

mysql_select_db("aviv") or die("cant open DB: ".mysql_error()); 

$SQL "INSERT INTO `vegetables`('name','number') VALUES('$name','$number');"

mysql_query("$SQL")or die("cant query: ".mysql_error()); 

$SQLL "SELECT name FROM vegetables"
$res mysql_query($SQL) or die("cant query:".mysql_error()); 
$rows mysql_num_rows($res); 
echo 
"We got $rows rows back<BR>"
while(
$row mysql_fetch_assoc($res)) { 
echo 
$row['name']."<BR>"
}; 
?>
  Reply With Quote
ישן 12-01-06, 19:41   # 4
DaNieLLL
חבר מתקדם
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
גיל: 31
הודעות: 614

DaNieLLL לא מחובר  

נסה את זה:

PHP קוד:
<?PHP 

$name 
$_POST['name']; 

$number $_POST['number']; 

mysql_connect("localhost","root") or die("cant connect: ".mysql_error()); 

mysql_select_db("aviv") or die("cant open DB: ".mysql_error()); 

$SQL "INSERT INTO `vegetables`(`name`,`number`) VALUES('$name','$number');"

mysql_query("$SQL")or die("cant query: ".mysql_error()); 

$SQLL "SELECT name FROM vegetables"
$res mysql_query($SQLL) or die("cant query:".mysql_error()); 
$rows mysql_num_rows($res); 
echo 
"We got $rows rows back<BR>"
while(
$row mysql_fetch_assoc($res)) { 
echo 
$row['name']."<BR>"
}; 
?>
עריכה: אתה לא משתמש בסיסמא להתחברות למסד? זה אפשרי?
תנסה עם סיסמא גם:

PHP קוד:
<?PHP 
$name 
$_POST['name']; 

$number $_POST['number']; 

mysql_connect("localhost","root","pass") or die("cant connect: ".mysql_error()); 

mysql_select_db("aviv") or die("cant open DB: ".mysql_error()); 

$SQL "INSERT INTO `vegetables`(`name`,`number`) VALUES('$name','$number');"

mysql_query("$SQL")or die("cant query: ".mysql_error()); 

$SQLL "SELECT name FROM vegetables"
$res mysql_query($SQLL) or die("cant query:".mysql_error()); 
$rows mysql_num_rows($res); 
echo 
"We got $rows rows back<BR>"
while(
$row mysql_fetch_assoc($res)) { 
echo 
$row['name']."<BR>"
}; 
?>
__________________

Last edited by DaNieLLL; 12-01-06 at 19:43..
  Reply With Quote
השב

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


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

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