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

הוסטס - פורום אחסון האתרים הגדול בישראל (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=28656)

lalamen 13-08-06 11:20

לא, פשוט תקרא לפונקציה
PHP קוד:


$db 
= new db;
$db->connect("localhost","your_db_username","your_db_password","your_db_name"); 


Elad-A 13-08-06 11:44

תודה רבה!! אני ינסה משהו אם אני לא יצליח אני יכתוב כאן.

עריכה:

יש לי בעיה בקוד הזה..
PHP קוד:

<?
class db

var 
$db

function 
connect($host$username$password$db_name){ 

    
$this->db mysql_connect($host,$username,$password
        or die(
"שגיאה"); 
     
    
mysql_select_db($db_name,$this->db
    or die(
"שגיאה"); 
     
    } 
function 
query($query)
    {
        
$res mysql_query("blabla");
    return 
$res;
    }
function 
fetch_rows()
    {
        return 
mysql_fetch_array($res);
    }
function 
num_rows()
    {
        return 
mysql_num_rows($res);
    }

}  
$db = new db
$db->connect("localhost","root","","ea2");
$db->query("SELECT * FROM ibf_thanks");
$rows $db->num_rows();
if(
$rows == 0)
{
echo 
"no";
}
else
{
$users=$db->fetch_rows();
echo 
$users ;
}
?>

ההתחברות עצמה עובדת אבל השאילתה לא בסדר.

drowkid 13-08-06 12:10

שחכתה להגדיר שאילתה לפונקציה: mysql_fetch_array...
אולי תעשה גלובלי

ד"א בתוך הפונקציה:
PHP קוד:

global $res


Elad-A 13-08-06 12:10

אחי פתחתי נושא חדש תענה לי שם.


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

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