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

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

dor77 23-05-11 17:59

מה הבעיה?
 
אני מנסה לשלוף את הנתונים האחרונים שנכנסו למסד..

PHP קוד:

<?php
mysql_connect
("localhost""******""****");
mysql_select_db("*****");
$result mysql_query("SELECT TOP 2 * FROM tutorials ORDER BY id DESC");
$tutorial_title=$row["title"];
$tutorial_text=$row["the_tutorial"];
$tutorial_user=$row["user_name"];
while(
$row mysql_fetch_array($result)){
echo 
'
<div class="popular_new_tutorials_text">
    <div class="tutorials_box">
    <span class="tutorial_title">' 
$row['title'] . '</span>
    <p class="tutorial_text">' 
$row['the_tutorial'] . '</p>
    <span class="tutorial_user">' 
$row['user_name'] . '</span>
    </div>
</div>'
;
}


?>

אני מקבל את השגיאה:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in

ניסיתי הכל..

תודה.

Erez | TrustMedia.co.il 23-05-11 18:42

SELECT * FROM tutorials ORDER BY id LIMIT 2 DESC
תנסה

dor77 23-05-11 19:26

לא עובד..

mysql_fetch_array(): supplied argument is not a valid MySQL result resource

עזרה?

תודה רבה.

IgalSt 23-05-11 19:30

במקור ניסית לכתוב שאילתה שמתאימה ל-Access.
ב-MYSQL השליפה של הרשומות האחרונות מתבצעת קצת אחרת:
קוד:

SELECT * FROM tutorials ORDER BY id DESC LIMIT 2

link 23-05-11 20:17

תוסיף להבא את הדבר הבא אחרי כל mysql_query:
or exit(mysql_error());
ככה יהיה לך מושג מה הייתה הבעיה.

BlueNosE 23-05-11 21:26

שלח לי ניסוח הולם לכותרת של הנושא ואפתח אותו מחדש.


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

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