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

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

adiga000 09-10-05 21:32

בעיה בפקודה
 
אני לומד PHP ואני מנסה כבר כמה ימים להצליח להכניס למס נתונים
ולהוציא
אני קצת נתקעתי שמה

ויש לי בעיה בפקודה

<?php
$host="localhost";
$user="ali_user";
$password="password";
$db="ali_base";
$table="ali_base"; //your default table/course name
mysql_connect($host,$user,$password)
or die("<BR><BR><B>ERROR:</B> cannot connect to MySQL server.<BR>");/* במקרה של כשלון בנסיון ההתחברות,
הסקריפט ידפיס הודעת שגיאה והתוכנית תעצר. */
$query = mysql_query("insert into gb(fild1,fild2,fild3]) values('123','234','345')")
or die("<BR><BR><B>ERROR:</B> problem.<BR>");
$select_query = "mysql_query(select * from table) or die(mysql_error())";
while(@($query = mysql_fetch_array($select_query))) {
$fild1 = $query[fild1];
$fild2 = $query[fild2];
$fild3 = $query[fild3];
echo "&eth;&uacute;&aring;&eth;&eacute;&iacute;<br><BR> ";
echo "$fild1";
echo "<br>";
echo "$fild2";
echo "<br>";
echo "$fild3";
}
echo "<BR><BR>";

?>



זה כל הפקודה שיש בדף
האם יש בעיות בזה?
כי ז הלא עובד

HaMashiah 09-10-05 22:17

תנסה את זה:
PHP קוד:

<?php
$host
="localhost"
$user="ali_user"
$password="password"
$db="ali_base";
$table="ali_base"//your default table/course name
mysql_connect("$host","$user","$pass"); 
mysql_select_db("$db"); 
or die(
"<BR><BR><B>ERROR:</B> cannot connect to MySQL server.<BR>");/* במקרה של כשלון בנסיון ההתחברות,
הסקריפט ידפיס הודעת שגיאה והתוכנית תעצר. */ 
$query mysql_query("insert into gb(fild1,fild2,fild3]) values('123','234','345')")
or die(
"<BR><BR><B>ERROR:</B> problem.<BR>");
$select_query "mysql_query(select * from table) or die(mysql_error())";
while(@(
$query mysql_fetch_array($select_query))) {
$fild1 $query[fild1];
$fild2 $query[fild2];
$fild3 $query[fild3];
echo 
"&eth;&uacute;&aring;&eth;&eacute;&iacute;<br><BR> ";
echo 
"$fild1";
echo 
"<br>";
echo 
"$fild2";
echo 
"<br>";
echo 
"$fild3";
}
echo 
"<BR><BR>";

?>


adiga000 10-10-05 07:40

זה לא עובד..
זה עדיין כותב שיש לי בעיה

$query = mysql_query("insert into gb(fild1,fild2,fild3]) values('123','234','345')")
or die("<BR><BR><B>ERROR:</B> problem.<BR>");
זה לא מצליח לעשות את זה

WebProject 10-10-05 07:50

יש שגיאה? ואם כן מהי?

HaMashiah 10-10-05 14:56

אתה צריך להתאים את זה לטבלה שלך ולשדות שבפנים

eLad 10-10-05 15:43

ציטוט:

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

$query = mysql_query("insert into gb(fild1,fild2,fild3]) values('123','234','345')")
or die("<BR><BR><B>ERROR:</B> problem.<BR>");
זה לא מצליח לעשות את זה

תוריד את הסוגר המרובע [ מהשאילתא שלך, אחרי ה fild3 ..
כשמשתמשים בו אז עוטפים את שמות השדות ולא כסוגר שורה או משהו כזה..

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


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

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