2015-10-19 40 views
-2

我在MySQL中使用。但我無法打電話給程序。如何在php/mysqli中調用過程?

<?php 
$mysqli = new mysqli("localhost", "user", "pass", "testDB"); 

$query = "SELECT * FROM testTable"; 

if ($result = $mysqli->query($query)) { 
    $row = $result->fetch_assoc(); 

    header("Content-type: audio/mpeg"); 
    echo $row['audioData']; 

    $result->free(); 
} 

$mysqli->close(); 
?> 
+0

我沒有看到你調用任何程序? – Daan

回答

0

試試這個代碼:

<?php 
//database gegevens 
$servername = "localhost"; 
$username = "root"; 
$password = "mysql"; 
$dbname = "db"; 


//maak connectie met database 
$conn = new mysqli($servername, $username, $password, $dbname); 
if ($conn->connect_error) { 
    die("Connection failed: " . $conn->connect_error); 
} 
$result = mysqli_query($conn, "SELECT * FROM testTable") or die(mysqli_error($conn)); 
if (mysqli_num_rows($result)>=1) { 
    while($row = mysqli_fetch_array($result)) { 
     $name = $row['name']; 
    } 
    } 
?> 
相關問題