2016-04-30 88 views
0
<form action="send_post.php" method="post"> 
    <p>A: <input type="text" name="A"> 
    <p>B: <input type="text" name="B">          
    <p><input type="submit">  
</form>  
<?php  
    $db = "localhost"; $usr = "blah1"; $pword = "blah2"; $dbname = "blah3"; 
    -----connects to server ok -------    
    $A = mysqli_real_escape_string($conn, $_POST['A']); 
    $B = mysqli_real_escape_string($conn, $_POST['B']); 
    $query="SELECT * FROM blah4 where A=$A and B=$B";  
    $sql=mysqli_query($conn, $query);   
    echo $sql;             
    $conn->clos();                 
?> 

需要什麼來顯示數據從數據庫?無法獲得查詢結果顯示 - php/mysqli

+0

您需要顯示所有代碼。這對我們無能爲力。 – Matt

+0

你應該[準備](http://php.net/manual/en/mysqli.prepare.php)SQL層。比'mysqli_real_escape_string'更安全! –

回答

1

您的查詢字符串的格式不正確

<form action="send_post.php" method="post"> 
    <p>A: <input type="text" name="A"> </p> 
    <p>B: <input type="text" name="B"> </p>          
    <p><input type="submit"> </p> 
</form>  
<?php  
    $db = "localhost"; $usr = "blah1"; $pword = "blah2"; $dbname = "blah3"; 
    -----connects to server ok -------    
    $A = mysqli_real_escape_string($conn, $_POST['A']); 
    $B = mysqli_real_escape_string($conn, $_POST['B']); 
    $query="SELECT * FROM blah4 where A='$A' and B='$B'";  
    $sql=mysqli_query($conn, $query);   
    echo $sql;             
    $conn->close();                 
?> 

$query="SELECT * FROM blah4 where A='". $A ,"' and B='" .$B ."'";  

您還沒有關閉</p>

$conn->close();  
+0

謝謝你,我已經設法解決了...... newbs,sheesh ... –

0

要添加在你沒有真正得到從DB數據試試這個

$row->mysqli_result::fetch_object($query); 

那麼你可以得到某些領域,如如果u有一個用戶名字段

username = $row->username; 

那麼你可以顯示用戶名像

echo $username;