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

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

mayden 01-08-06 20:27

בעיה עם קוד PHP (התחברות למסד הנתונים).
 
אהלן,
יש לי בעיה אשר נוצרת בעת כתיבת קוד ה PHP.

PHP קוד:

<?php 

    $link 
mysql_connect("localhost","root","") or die("Could not connect: " mysql_error());
    
mysql_select_db("test"$link);
     
$query    =  ("SELECT * FROM users ORDER BY id DESC LIMIT 10")or die (mysql_error());
     
while(
$result    =    mysql_fetch_array($query) )

    
$id  $result['id'];  
    
$name    =    $result['name']; 
    
$msg    =    $result['msg']; 




echo 
"$id , $name , $msg";



?>

אני משתמש בEasyPHP, אז אין סיסמא (אבל לא כאן הבעיה.)

בכל מקרה, הרעיון של הקוד שלי זה להציג את עשרת ההודעות האחרונות אשר נמצאים במסד הנתונים.
אשמח אם תעזרו לי,
אגב השגיאה אשר זה מוציא:

קוד:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp1-8\www\archive.php on line 8

Notice: Undefined variable: id in c:\program files\easyphp1-8\www\archive.php on line 17

Notice: Undefined variable: name in c:\program files\easyphp1-8\www\archive.php on line 17

Notice: Undefined variable: msg in c:\program files\easyphp1-8\www\archive.php on line 17
, ,

תודה רבה :)

RS324 01-08-06 20:42

תשנה את
$$query = ("SELECT * FROM users ORDER BY id DESC LIMIT 10")or die (mysql_error());

לא
$$query = mysql_query("SELECT * FROM users ORDER BY id DESC LIMIT 10")or die (mysql_error());

mayden 01-08-06 20:56

אחלה,
תודה רבה.

אפשר לנעול כאן מנהלים,
ואני מודה לך מקרב לב על העזרה.


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

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