2016-10-08 7 views
0

もう少しお手伝いが必要です。この問題を知っているが、私は不足しているパラメータを見つける傾ける...これが問題ライン警告:mysqli_query()は少なくとも2つのパラメータを必要とし、1はD: wamp64 www magento に1544行目の functions.phpを指定します。

**`$result_template = mysqli_query($select_template) or die(mysql_error());`** 

である私は1つのパラメータが欠落している知っているが、私はwhichoneを知りません?あなたは私を助けることができますか?おかげ

これは多分便利なコードの一部です....

/*function to display the active template*/ 


    function displayTemplate(){ 
     $tableprefix = ""; 
     global $tableprefix,$_SESSION; 
     $template_array = array(); 

     $select_template = "SELECT vtop_filename,vleft_filename,vbottom_filename,vimages_folder,vcss_name,vtemplate_name 
          FROM ".$tableprefix."template_master WHERE vactive_status = 'Y'"; 

1579---->>>> $result_template = mysqli_query($select_template) or die(mysql_error()); 

     $template_row = mysql_fetch_assoc($result_template); 

     array_push($template_array,$template_row['vtop_filename'],$template_row['vleft_filename'],$template_row['vbottom_filename'],$template_row['vimages_folder'],$template_row['vcss_name'],$template_row['vtemplate_name']); 

    return $template_array; 
    } 
+0

あなたはコネクションを渡しましたmysqli関数への変数の変更 –

+1

申し訳ありません@Kinshuk私は理解できません – Murat

+0

あなたはConnectionオブジェクトに欠けていました....ここでは、クイック構文ref '$ res = mysqli_query($ con_object、$ query); ' – RohitS

答えて

1

あなたがどこに接続するように指示する必要があります。 PHPからデータベースに接続するための作業コードの簡単な例を次に示します。あなたが手続き的なスタイルを使用しているので、あなたがあなたのmysqli_queryに

<?php 
$link = mysqli_connect("localhost", "my_user", "my_password", "world"); 

/* check connection */ 
if (mysqli_connect_errno()) { 
    printf("Connect failed: %s\n", mysqli_connect_error()); 
    exit(); 
} 

/* Create table doesn't return a resultset */ 
if (mysqli_query($link, "CREATE TEMPORARY TABLE myCity LIKE City") === TRUE) { 
    printf("Table myCity successfully created.\n"); 
} 

/* Select queries return a resultset */ 
if ($result = mysqli_query($link, "SELECT Name FROM City LIMIT 10")) { 
    printf("Select returned %d rows.\n", mysqli_num_rows($result)); 

    /* free result set */ 
    mysqli_free_result($result); 
} 

/* If we have to retrieve large amount of data we use MYSQLI_USE_RESULT */ 
if ($result = mysqli_query($link, "SELECT * FROM City", MYSQLI_USE_RESULT)) { 

    /* Note, that we can't execute any functions which interact with the 
     server until result set was closed. All calls will return an 
     'out of sync' error */ 
    if (!mysqli_query($link, "SET @a:='this will not work'")) { 
     printf("Error: %s\n", mysqli_error($link)); 
    } 
    mysqli_free_result($result); 
} 

mysqli_close($link); 
?> 

が、私としてはmysqli_connectリソースを渡す必要がありますとして

<php 

//Connect to DB 
$conn = new mysqli("Hostname","Username","Password","Database"); 

//If the connection has errors 
if ($conn->connect_error){ 
    //Display the error 
    die("Connection failed because: " . $conn->connect_error); 
} 

//Otherwise the connection is good so lets create a sql query 
$sql = "SELECT * FROM Database"; 

//Get the results of the query 
$result = $conn->query($sql); 
1

あなたはこのhere

のためのPHPのマニュアルを参照する必要がありますあなたがいくつかの関数でそれを使用していることを知ることができるので、dbのオブジェクトをこの関数に渡してからmysqli_queryで使用してください。

関連する問題