11-04-2010, 09:01 AM
|
#1 (permalink)
|
|
The Visitor
Join Date: Nov 2010
Posts: 2
Thanks: 0
|
mysqli troubles
Hi, this is my code to get my navigation from the database:
PHP Code:
$navigatie = array();
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, DB_PORT);
if(mysqli_connect_errno())
die("Kon geen connectie maken met de database: " . mysqli_connect_error());
$q = "SELECT anchorText, urlString FROM pagina WHERE parentId = -1 AND showInNavigation = 1 ORDER BY navigationSortIndex";
if($stmt = $mysqli->prepare($q))
{
$stmt->bind_result($anchorText, $urlString);
$i = 0;
echo $stmt->num_rows();
while($stmt->fetch())
{
$navigatie[$i] = array("anchorText" => $anchorText, "urlString" => $urlString);
$i++;
}
$smarty->assign("hoofdnavigatie", $navigatie);
$stmt->close();
}
else
{
die("De hoofdnavigatie kon niet geladen worden: " . $mysqli->error());
}
$mysqli->close();
The problem is that it returns 0 rows, but when i execute the same querry in mysql workbench, it does what it's supposed to do, returning 4 results. Have I made a mistake in my code somewhere?
|
|
|
|